~clint-fewbar/ubuntu/precise/modemmanager/fix-removed-not-purged

« back to all changes in this revision

Viewing changes to plugins/mm-modem-huawei-gsm.c

  • Committer: Package Import Robot
  • Author(s): Artem Popov
  • Date: 2012-01-02 13:32:18 UTC
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20120102133218-f2xuil48af71xa7b
Tags: upstream-0.5+git.20111231t174444.1e332ab
ImportĀ upstreamĀ versionĀ 0.5+git.20111231t174444.1e332ab

Show diffs side-by-side

added added

removed removed

Lines of Context:
599
599
 
600
600
    mm_callback_info_set_result (info, GUINT_TO_POINTER (attempts_left), NULL);
601
601
 
602
 
    g_match_info_free (match_info);
603
 
 
604
602
done:
 
603
    if (match_info)
 
604
        g_match_info_free (match_info);
605
605
    if (r)
606
606
        g_regex_unref (r);
607
607
    mm_serial_port_close (MM_SERIAL_PORT (port));
888
888
 
889
889
    *scheme = MM_MODEM_GSM_USSD_SCHEME_7BIT;
890
890
    gsm = mm_charset_utf8_to_unpacked_gsm (command, &len);
 
891
 
 
892
    /* If command is a multiple of 7 characters long, Huawei firmwares
 
893
     * apparently want that padded.  Maybe all modems?
 
894
     */
 
895
    if (len % 7 == 0) {
 
896
        gsm = g_realloc (gsm, len + 1);
 
897
        gsm[len] = 0x0d;
 
898
        len++;
 
899
    }
 
900
 
891
901
    packed = gsm_pack (gsm, len, 0, &packed_len);
892
902
    hex = utils_bin2hexstr (packed, packed_len);
893
903
    g_free (packed);
906
916
    guint32 unpacked_len;
907
917
 
908
918
    bin = utils_hexstr2bin (reply, &bin_len);
909
 
    unpacked = gsm_unpack ((guint8*)bin, bin_len, 0, &unpacked_len);
910
 
    utf8 = (char*)mm_charset_gsm_unpacked_to_utf8 (unpacked, unpacked_len);
 
919
    unpacked = gsm_unpack ((guint8*) bin, (bin_len * 8) / 7, 0, &unpacked_len);
 
920
    /* if the last character in a 7-byte block is padding, then drop it */
 
921
    if ((bin_len % 7 == 0) && (unpacked[unpacked_len - 1] == 0x0d))
 
922
        unpacked_len--;
 
923
    utf8 = (char*) mm_charset_gsm_unpacked_to_utf8 (unpacked, unpacked_len);
911
924
 
912
925
    g_free (bin);
913
926
    g_free (unpacked);