[maemo-commits] [maemo-commits] r16502 - projects/haf/trunk/apt
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon Oct 27 18:29:04 EET 2008
- Previous message: [maemo-commits] r16501 - projects/haf/trunk/apt/methods
- Next message: [maemo-commits] r16503 - projects/haf/trunk/apt/debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: marivoll
Date: 2008-10-27 18:29:02 +0200 (Mon, 27 Oct 2008)
New Revision: 16502
Added:
projects/haf/trunk/apt/https-tablet-identification.patch
Log:
New patch.
Added: projects/haf/trunk/apt/https-tablet-identification.patch
===================================================================
--- projects/haf/trunk/apt/https-tablet-identification.patch 2008-10-27 16:27:42 UTC (rev 16501)
+++ projects/haf/trunk/apt/https-tablet-identification.patch 2008-10-27 16:29:02 UTC (rev 16502)
@@ -0,0 +1,100 @@
+diff --git a/methods/https.cc b/methods/https.cc
+index b0b05a4..0daa94e 100644
+--- a/methods/https.cc
++++ b/methods/https.cc
+@@ -33,6 +33,75 @@
+ /*}}}*/
+ using namespace std;
+
++static const char *
++get_osso_product_hardware ()
++{
++ static char *product_hardware = NULL;
++
++ if (product_hardware)
++ return product_hardware;
++
++ /* XXX - There is a library in maemo somewhere to do this, but it is
++ not included in the maemo SDK, so we have to do it
++ ourselves. Ridiculous, I know.
++ */
++
++ product_hardware = "";
++ FILE *f = fopen ("/proc/component_version", "r");
++ if (f)
++ {
++ char *line = NULL;
++ size_t len = 0;
++ ssize_t n;
++
++ while ((n = getline (&line, &len, f)) != -1)
++ {
++ if (n > 0 && line[n-1] == '\n')
++ line[n-1] = '\0';
++
++ if (sscanf (line, "product %as", &product_hardware) == 1)
++ break;
++ }
++
++ free (line);
++ fclose (f);
++ }
++
++ return product_hardware;
++}
++
++char*
++maybe_add_device_id (const char *uri)
++{
++ const char *product_hardware = get_osso_product_hardware ();
++ const char *host_part, *host_end, *at_pos;
++ char *result;
++
++ if (product_hardware == NULL || product_hardware[0] == '\0')
++ {
++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;
++}
++
+ size_t
+ HttpsMethod::write_data(void *buffer, size_t size, size_t nmemb, void *userp)
+ {
+@@ -118,7 +187,8 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
+ SetupProxy();
+
+ // callbacks
+- curl_easy_setopt(curl, CURLOPT_URL, Itm->Uri.c_str());
++ char *url = maybe_add_device_id (Itm->Uri.c_str ());
++ curl_easy_setopt(curl, CURLOPT_URL, url);
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, this);
+ curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
+@@ -261,6 +331,9 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
+ delete File;
+ curl_slist_free_all(headers);
+
++ if (url)
++ free (url);
++
+ return true;
+ };
+
- Previous message: [maemo-commits] r16501 - projects/haf/trunk/apt/methods
- Next message: [maemo-commits] r16503 - projects/haf/trunk/apt/debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
