[maemo-commits] [maemo-commits] r14974 - projects/haf/trunk/apt-https
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Fri Dec 14 15:44:11 EET 2007
- Previous message: [maemo-commits] r14973 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r14975 - in projects/haf/trunk/apt-https: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: marivoll
Date: 2007-12-14 15:44:07 +0200 (Fri, 14 Dec 2007)
New Revision: 14974
Modified:
projects/haf/trunk/apt-https/https.cc
Log:
* https.cc (maybe_add_device_id): New, to hack our identification
cookie into the URI.
(CurlMethod::Fetch): Use it.
Modified: projects/haf/trunk/apt-https/https.cc
===================================================================
--- projects/haf/trunk/apt-https/https.cc 2007-12-14 13:00:06 UTC (rev 14973)
+++ projects/haf/trunk/apt-https/https.cc 2007-12-14 13:44:07 UTC (rev 14974)
@@ -138,9 +138,14 @@
int stdout_fd, stderr_fd;
GError *error = NULL;
GPid child_pid;
-
- // fprintf (stderr, "[ %s ]\n", argv[0]);
+#if 0
+ fprintf (stderr, "[");
+ for (int i = 0; argv[i]; i++)
+ fprintf (stderr, " %s", argv[i]);
+ fprintf (stderr, " ]\n");
+#endif
+
if (!g_spawn_async_with_pipes (NULL,
(gchar **)argv,
NULL,
@@ -171,6 +176,38 @@
return success;
}
+char *
+maybe_add_device_id (const char *uri)
+{
+ const char *product_hardware = getenv ("OSSO_PRODUCT_HARDWARE");
+ const char *host_part, *host_end, *at_pos;
+ char *result;
+
+ if (product_hardware == NULL)
+ {
+ dont_add_device_id:
+ return strdup (uri);
+ }
+
+ host_part = strstr (uri, "//");
+ if (host_part == NULL)
+ goto dont_add_device_id;
+ host_part += 2;
+
+ host_end = strchr (host_part, '/');
+ if (host_end == NULL)
+ host_end = host_part + strlen (host_part);
+
+ at_pos = strchr (host_part, '@');
+ if (at_pos && at_pos < host_end)
+ goto dont_add_device_id;
+
+ asprintf (&result, "%.*sNOKIA-OSSO-%s:JOSHUA@%s",
+ host_part - uri, uri, product_hardware, host_part);
+
+ return result;
+}
+
bool
CurlMethod::Fetch (FetchItem *Itm)
{
@@ -187,10 +224,12 @@
&& access ("/usr/bin/curl", X_OK) == 0)
prog = "/usr/bin/curl";
+ char *uri = maybe_add_device_id (Itm->Uri.c_str ());
+
const char *argv[] = {
prog,
"-o", Itm->DestFile.c_str (),
- Itm->Uri.c_str (),
+ uri,
NULL
};
@@ -204,6 +243,8 @@
result.Size = Buf.st_size;
URIDone (result);
+ free (uri);
+
return true;
}
- Previous message: [maemo-commits] r14973 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r14975 - in projects/haf/trunk/apt-https: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
