Changeset 1695

Show
Ignore:
Timestamp:
02/08/07 08:57:57 (22 months ago)
Author:
paule
Message:

Handle when sendHandshakeInfo() sends back response in base64-encoded utf-16 (as Qtopia or Opie with sync setting set to "Qtopia 1.7" seems to do)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • plugins/opie-sync/src/opie_qcop.c

    r1597 r1695  
    350350    temp = g_strndup(start,strstr(start," ")-start); /* from slash to blank is our path */ 
    351351  } 
    352   else 
     352  else if((start=strstr(pc,") ")+2)) 
     353  { 
     354    /* Qtopia sends back a base64 encoded utf-16 (big-endian) string */ 
     355    guchar *decoded; 
     356    char *startc; 
     357    gsize len = 0; 
     358    gsize len2 = 0; 
     359    GError *err = NULL; 
     360 
     361    decoded = g_base64_decode(start, &len); 
     362    if(len > 0) { 
     363      /* first four bytes seem to be \0 \0 \0 (string length) */ 
     364      len = decoded[3]; 
     365      startc = decoded + 4; 
     366      temp = g_convert(startc, len, "UTF8", "UTF16BE", NULL, &len2, &err); 
     367      if (err != NULL) { 
     368        fprintf(stderr, "UTF16 convert error: %s\n", err->message); 
     369        g_error_free(err); 
     370        if(temp) { 
     371          /* Don't accept partial conversions */ 
     372          g_free(temp); 
     373          temp = NULL; 
     374        } 
     375      } 
     376    } 
     377  } 
     378 
     379  if(!temp) 
    353380    qconn->resultmsg = g_strdup_printf("Unrecognised response: %s", pc); 
    354381