Changeset 3512


Ignore:
Timestamp:
11/26/07 16:21:39 (6 years ago)
Author:
chris
Message:
  • src/phone-kit/moko-dialer-mcc-dc.h: Replace "+1-" with "+1"
  • src/phone-kit/moko-dialer.c: (on_network_registered), (start_handling_sms), (net_msghandler), (pb_msghandler), (sms_store_opened_cb), (dialer_init_gsmd), (moko_dialer_check_gsmd), (moko_dialer_send_sms): Try to resolve local numbers (numbers beginning in '0'), make gsmd requests in more reliable places, be a bit better with failures (all to do with SMS code)
  • src/phone-kit/moko-dialer.h: Remove error code PK_DIALER_ERROR_NO_TOOLONG, add error code PK_DIALER_ERROR_INVALID_NUMBER
Location:
trunk/src/target/OM-2007.2/applications/openmoko-dialer2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog

    r3495 r3512  
     12007-11-26  Chris Lord  <chris@openedhand.com> 
     2 
     3        * src/phone-kit/moko-dialer-mcc-dc.h: 
     4        Replace "+1-" with "+1" 
     5 
     6        * src/phone-kit/moko-dialer.c: (on_network_registered), 
     7        (start_handling_sms), (net_msghandler), (pb_msghandler), 
     8        (sms_store_opened_cb), (dialer_init_gsmd), 
     9        (moko_dialer_check_gsmd), (moko_dialer_send_sms): 
     10        Try to resolve local numbers (numbers beginning in '0'), make gsmd 
     11        requests in more reliable places, be a bit better with failures (all to 
     12        do with SMS code) 
     13 
     14        * src/phone-kit/moko-dialer.h: 
     15        Remove error code PK_DIALER_ERROR_NO_TOOLONG, add error code 
     16        PK_DIALER_ERROR_INVALID_NUMBER 
     17 
    1182007-11-23  Chris Lord  <chris@openedhand.com> 
    219 
  • trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-dialer-mcc-dc.h

    r3495 r3512  
    1414{ "276", "+355", "Albania" }, 
    1515{ "603", "+213", "Algeria" }, 
    16 { "544", "+1-684", "American Samoa (US)" }, 
     16{ "544", "+1684", "American Samoa (US)" }, 
    1717{ "213", "+376", "Andorra" }, 
    1818{ "631", "+244", "Angola" }, 
    19 { "365", "+1-264", "Anguilla" }, 
    20 { "344", "+1-268", "Antigua and Barbuda" }, 
     19{ "365", "+1264", "Anguilla" }, 
     20{ "344", "+1268", "Antigua and Barbuda" }, 
    2121{ "722", "+54", "Argentine Republic" }, 
    2222{ "283", "+374", "Armenia" }, 
     
    2525{ "232", "+43", "Austria" }, 
    2626{ "400", "+994", "Azerbaijani Republic" }, 
    27 { "364", "+1-242", "Bahamas" }, 
     27{ "364", "+1242", "Bahamas" }, 
    2828{ "426", "+973", "Bahrain" }, 
    2929{ "470", "+880", "Bangladesh" }, 
    30 { "342", "+1-246", "Barbados" }, 
     30{ "342", "+1246", "Barbados" }, 
    3131{ "257", "+375", "Belarus" }, 
    3232{ "206", "+32", "Belgium" }, 
    3333{ "702", "+501", "Belize" }, 
    3434{ "616", "+229", "Benin" }, 
    35 { "350", "+1-441", "Bermuda (UK)" }, 
     35{ "350", "+1441", "Bermuda (UK)" }, 
    3636{ "402", "+975", "Bhutan" }, 
    3737{ "736", "+591", "Bolivia" }, 
     
    3939{ "652", "+267", "Botswana" }, 
    4040{ "724", "+55", "Brazil" }, 
    41 { "348", "+1-284", "British Virgin Islands (UK)" }, 
     41{ "348", "+1284", "British Virgin Islands (UK)" }, 
    4242{ "528", "+673", "Brunei Darussalam" }, 
    4343{ "284", "+359", "Bulgaria" }, 
     
    4848{ "302", "+1", "Canada" }, 
    4949{ "625", "+238", "Cape Verde" }, 
    50 { "346", "+1-345", "Cayman Islands (UK)" }, 
     50{ "346", "+1345", "Cayman Islands (UK)" }, 
    5151{ "623", "+236", "Central African Republic" }, 
    5252{ "622", "+235", "Chad" }, 
     
    6666{ "238", "+45", "Denmark" }, 
    6767{ "638", "+253", "Djibouti" }, 
    68 { "366", "+1-767", "Dominica" }, 
    69 { "370", "+1-809", "Dominican Republic" }, 
     68{ "366", "+1767", "Dominica" }, 
     69{ "370", "+1809", "Dominican Republic" }, 
    7070{ "514", "+670", "East Timor" }, 
    7171{ "740", "+593", "Ecuador" }, 
     
    9090{ "202", "+30", "Greece" }, 
    9191{ "290", "+299", "Greenland (Denmark)" }, 
    92 { "352", "+1-473", "Grenada" }, 
     92{ "352", "+1473", "Grenada" }, 
    9393{ "340", "+590", "Guadeloupe (France)" }, 
    94 { "535", "+1-671", "Guam (US)" }, 
     94{ "535", "+1671", "Guam (US)" }, 
    9595{ "704", "+502", "Guatemala" }, 
    9696{ "611", "+224", "Guinea" }, 
     
    110110{ "425", "+972", "Israel" }, 
    111111{ "222", "+39", "Italy" }, 
    112 { "338", "+1-876", "Jamaica" }, 
     112{ "338", "+1876", "Jamaica" }, 
    113113{ "441", "+81", "Japan" }, 
    114114{ "440", "+81", "Japan" }, 
     
    147147{ "212", "+377", "Monaco" }, 
    148148{ "428", "+976", "Mongolia" }, 
    149 { "354", "+1-664", "Montserrat (UK)" }, 
     149{ "354", "+1664", "Montserrat (UK)" }, 
    150150{ "604", "+212", "Morocco" }, 
    151151{ "643", "+258", "Mozambique" }, 
     
    161161{ "614", "+227", "Niger" }, 
    162162{ "621", "+234", "Nigeria" }, 
    163 { "534", "+1-670", "Northern Mariana Islands (US)" }, 
     163{ "534", "+1670", "Northern Mariana Islands (US)" }, 
    164164{ "242", "+47", "Norway" }, 
    165165{ "422", "+968", "Oman" }, 
     
    173173{ "260", "+48", "Poland" }, 
    174174{ "351", "+351", "Portugal" }, 
    175 { "330", "+1-787", "Puerto Rico (US)" }, 
     175{ "330", "+1787", "Puerto Rico (US)" }, 
    176176{ "427", "+974", "Qatar" }, 
    177177{ "647", "+262", "Réunion (France)" }, 
     
    179179{ "250", "+7", "Russian Federation" }, 
    180180{ "635", "+250", "Rwandese Republic" }, 
    181 { "356", "+1-869", "Saint Kitts and Nevis" }, 
    182 { "358", "+1-758", "Saint Lucia" }, 
     181{ "356", "+1869", "Saint Kitts and Nevis" }, 
     182{ "358", "+1758", "Saint Lucia" }, 
    183183{ "308", "+508", "Saint Pierre and Miquelon (France)" }, 
    184 { "360", "+1-784", "Saint Vincent and the Grenadines" }, 
     184{ "360", "+1784", "Saint Vincent and the Grenadines" }, 
    185185{ "549", "+685", "Samoa" }, 
    186186{ "292", "+378", "San Marino" }, 
     
    211211{ "615", "+228", "Togolese Republic" }, 
    212212{ "539", "+676", "Tonga" }, 
    213 { "374", "+1-868", "Trinidad and Tobago" }, 
     213{ "374", "+1868", "Trinidad and Tobago" }, 
    214214{ "605", "+216", "Tunisia" }, 
    215215{ "286", "+90", "Turkey" }, 
    216216{ "438", "+993", "Turkmenistan" }, 
    217 { "376", "+1-649", "Turks and Caicos Islands (UK)" }, 
     217{ "376", "+1649", "Turks and Caicos Islands (UK)" }, 
    218218{ "641", "+256", "Uganda" }, 
    219219{ "255", "+380", "Ukraine" }, 
     
    230230{ "315", "+1", "United States of America" }, 
    231231{ "316", "+1", "United States of America" }, 
    232 { "332", "+1-340", "United States Virgin Islands (US)" }, 
     232{ "332", "+1340", "United States Virgin Islands (US)" }, 
    233233{ "748", "+598", "Uruguay" }, 
    234234{ "434", "+998", "Uzbekistan" }, 
  • trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-dialer.c

    r3495 r3512  
    7676  struct lgsm_handle *handle; 
    7777  MokoDialerSource   *source; 
     78  gboolean           handling_sms; 
    7879   
    7980  /* Storage objects */ 
    8081  JanaStore          *sms_store; 
    8182  gboolean           sms_store_open; 
    82         JanaNote           *last_msg; 
     83  JanaNote           *last_msg; 
    8384  MokoJournal        *journal; 
    8485  MokoContacts       *contacts; 
     
    110111 
    111112static void dialer_init_gsmd (MokoDialer *dialer); 
     113 
     114static const gchar *moko_dialer_cc_from_mcc (gchar *mcc); 
    112115 
    113116/* DBus functions */ 
     
    427430    case GSMD_NETREG_REG_ROAMING: 
    428431      g_debug ("Network registered: LocationAreaCode: %x. CellID: %x.", lac, cell); 
    429       priv->gsm_location.lac = lac; 
    430       priv->gsm_location.cid = cell; 
    431432       
    432       if ((priv->registered != GSMD_NETREG_REG_HOME) && 
    433           (priv->registered != GSMD_NETREG_REG_ROAMING)) { 
     433      /* Retrieve details when we switch location/type */ 
     434      if ((priv->registered != type) || (priv->gsm_location.lac != lac)) { 
    434435        /* Retrieve operator name */ 
    435436        lgsm_oper_get (priv->handle); 
     
    441442        lgsm_get_imsi (priv->handle); 
    442443      } 
     444       
     445      priv->gsm_location.lac = lac; 
     446      priv->gsm_location.cid = cell; 
    443447       
    444448      break; 
     
    956960} 
    957961 
     962static void 
     963start_handling_sms (MokoDialer *dialer) 
     964{ 
     965  MokoDialerPrivate *priv = dialer->priv; 
     966   
     967  /* Register SMS handling callback */ 
     968  lgsm_register_handler (priv->handle, GSMD_MSG_SMS, &sms_msghandler); 
     969 
     970  /* List all messages to move to journal */ 
     971  lgsm_sms_list (priv->handle, GSMD_SMS_ALL); 
     972   
     973  priv->handling_sms = TRUE; 
     974} 
     975 
    958976static int 
    959977net_msghandler (struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh) 
     
    971989    case GSMD_NETWORK_GET_NUMBER : 
    972990      g_free (priv->own_number); 
    973       priv->own_number = g_strdup (num->addr.number); 
     991       
     992      if ((num->addr.number) && (num->addr.number[0] == '0') && (priv->imsi)) 
     993        priv->own_number = g_strconcat (moko_dialer_cc_from_mcc (priv->imsi), 
     994                                        num->addr.number + 1, NULL); 
     995      else 
     996        priv->own_number = g_strdup (num->addr.number); 
     997       
     998      if ((priv->sms_store_open) && (!priv->handling_sms)) { 
     999        start_handling_sms (dialer); 
     1000      } 
     1001       
    9741002      break; 
    9751003    case GSMD_NETWORK_OPER_GET : 
     
    10041032    case GSMD_PHONEBOOK_GET_IMSI : 
    10051033      priv->imsi = g_strdup ((char *)gmh + sizeof (*gmh)); 
     1034       
     1035      /* Get phone number */ 
     1036      lgsm_get_subscriber_num (priv->handle); 
    10061037      break; 
    10071038    default : 
     
    10551086  g_debug ("SMS store opened"); 
    10561087   
    1057   if (!priv->handle) return; 
    1058    
    1059   /* Register SMS handling callback */ 
    1060   lgsm_register_handler (priv->handle, GSMD_MSG_SMS, &sms_msghandler); 
    1061  
    1062   /* List all messages to move to journal */ 
    1063   lgsm_sms_list (priv->handle, GSMD_SMS_ALL); 
     1088  if (priv->handle && priv->own_number) { 
     1089    start_handling_sms (self); 
     1090  } 
    10641091} 
    10651092 
     
    11041131  priv->registered = GSMD_NETREG_UNREG; 
    11051132  lgsm_netreg_register (priv->handle, ""); 
    1106  
     1133   
    11071134  /* Get phone number */ 
    11081135  lgsm_get_subscriber_num (priv->handle); 
    1109    
     1136 
    11101137  /* Start polling for events */ 
    11111138  priv->source = (MokoDialerSource *) 
     
    11951222  MokoDialerPrivate *priv = self->priv; 
    11961223   
     1224  if (!priv->handle) dialer_init_gsmd (self); 
     1225   
    11971226  if (!priv->handle) { 
    11981227    *error = g_error_new (PHONE_KIT_DIALER_ERROR, PK_DIALER_ERROR_GSMD, 
     
    12411270  gboolean ascii; 
    12421271  JanaNote *note; 
     1272  const gchar *dialcode; 
    12431273   
    12441274  g_assert (self && number && message); 
     
    12591289  /* Set destination number */ 
    12601290  if (strlen (number) > GSMD_ADDR_MAXLEN + 1) { 
    1261     *error = g_error_new (PHONE_KIT_DIALER_ERROR, PK_DIALER_ERROR_NO_TOOLONG, 
    1262                           "Number too long"); 
     1291    *error = g_error_new (PHONE_KIT_DIALER_ERROR, 
     1292                          PK_DIALER_ERROR_INVALID_NUMBER, 
     1293                          "Invalid number"); 
    12631294    return FALSE; 
    12641295  } else { 
     
    12871318  } else { 
    12881319    sms.alpha = ALPHABET_8BIT; 
    1289     sms.length = strlen (message); 
    12901320    strcpy ((gchar *)sms.data, message); 
    12911321  } 
     1322  sms.length = msg_length; 
    12921323   
    12931324  /* Send message */ 
     
    12961327  /* Store sent message in journal */ 
    12971328  note = jana_ecal_note_new (); 
    1298   jana_note_set_recipient (note, number); 
     1329  if ((number[0] == '0') && (priv->network_number) && 
     1330      (dialcode = moko_dialer_cc_from_mcc (priv->network_number))) { 
     1331    gchar *full_number = g_strconcat (dialcode, number + 1, NULL); 
     1332    jana_note_set_recipient (note, full_number); 
     1333    g_free (full_number); 
     1334  } else 
     1335    jana_note_set_recipient (note, number); 
    12991336  jana_note_set_author (note, priv->own_number); 
    13001337   
  • trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-dialer.h

    r3495 r3512  
    5252  PK_DIALER_ERROR_SMS_STORE, 
    5353  PK_DIALER_ERROR_SMS_TOOLONG, 
    54   PK_DIALER_ERROR_NO_TOOLONG, 
    5554  PK_DIALER_ERROR_NO_PROVIDER, 
    5655  PK_DIALER_ERROR_NO_PROVIDER_NUM, 
    5756  PK_DIALER_ERROR_NO_IMSI, 
    5857  PK_DIALER_ERROR_NO_NUMBER, 
     58  PK_DIALER_ERROR_INVALID_NUMBER, 
    5959} PhoneKitDialerError; 
    6060 
Note: See TracChangeset for help on using the changeset viewer.