\r\n -> \n
[gnokii.git] / common / newmodules / n6110.c
index dc171b7..324b401 100644 (file)
@@ -716,34 +716,35 @@ void N6110_ReplyCallDivert(u16 MessageLength, u8 *MessageBuffer, u8 MessageType)
       fprintf(stdout, _("   Status     : deactivated\n"));     
     }
 #endif /* DEBUG */
-    switch (MessageBuffer[6]) {
-      case 0x43: CurrentCallDivert->DType=GSM_CDV_Busy;break;
-      case 0x3d: CurrentCallDivert->DType=GSM_CDV_NoAnswer;break;
-      case 0x3e: CurrentCallDivert->DType=GSM_CDV_OutOfReach;break;
-      case 0x15: CurrentCallDivert->DType=GSM_CDV_AllTypes;break; //?
-      case 0x02: CurrentCallDivert->DType=GSM_CDV_AllTypes;break; //?
-    }
 
-    if (MessageBuffer[6]==0x02) //?
-      CurrentCallDivert->CType=GSM_CDV_AllCalls;
-    else {
-      switch (MessageBuffer[8]) {
-        case 0x0b: CurrentCallDivert->CType=GSM_CDV_VoiceCalls;break;
-        case 0x0d: CurrentCallDivert->CType=GSM_CDV_FaxCalls;  break;
-        case 0x19: CurrentCallDivert->CType=GSM_CDV_DataCalls; break;
+    if (CurrentCallDivert!=NULL) { 
+      switch (MessageBuffer[6]) {
+        case 0x43: CurrentCallDivert->DType=GSM_CDV_Busy;break;
+        case 0x3d: CurrentCallDivert->DType=GSM_CDV_NoAnswer;break;
+        case 0x3e: CurrentCallDivert->DType=GSM_CDV_OutOfReach;break;
+        case 0x15: CurrentCallDivert->DType=GSM_CDV_AllTypes;break; //?
+        case 0x02: CurrentCallDivert->DType=GSM_CDV_AllTypes;break; //?
       }
-    }
 
-    if (MessageBuffer[10]==0x01) {
-      CurrentCallDivert->Enabled=true;
-      CurrentCallDivert->Timeout=MessageBuffer[45];
-      strcpy(CurrentCallDivert->Number,GSM_UnpackSemiOctetNumber(MessageBuffer+12,true));
-    } else {
-      CurrentCallDivert->Enabled=false;
-    }
+      if (MessageBuffer[6]==0x02) //?
+        CurrentCallDivert->CType=GSM_CDV_AllCalls;
+      else {
+        switch (MessageBuffer[8]) {
+          case 0x0b: CurrentCallDivert->CType=GSM_CDV_VoiceCalls;break;
+          case 0x0d: CurrentCallDivert->CType=GSM_CDV_FaxCalls;  break;
+          case 0x19: CurrentCallDivert->CType=GSM_CDV_DataCalls; break;
+        }
+      }
 
-    CurrentCallDivertError=GE_NONE;
+      if (MessageBuffer[10]==0x01) {
+        CurrentCallDivert->Enabled=true;
+        CurrentCallDivert->Timeout=MessageBuffer[45];
+        strcpy(CurrentCallDivert->Number,GSM_UnpackSemiOctetNumber(MessageBuffer+12,true));
+      } else {
+        CurrentCallDivert->Enabled=false;
+      }
+      CurrentCallDivertError=GE_NONE;
+    }
     break;
 
   case 0x03:
@@ -2468,7 +2469,9 @@ GSM_Error N6110_DialData(char *Number, char type, void (* callpassup)(char c))
                break;
        case 1:
                Protocol->SendMessage(sizeof(req3), 0x01, req3);
+               usleep(1000000);
                Protocol->SendMessage(sizeof(req4), 0x01, req4);
+               usleep(1000000);
                req_end = req_end1;
                size = sizeof(req_end1);
                break;
@@ -2489,7 +2492,12 @@ GSM_Error N6110_DialData(char *Number, char type, void (* callpassup)(char c))
        memcpy(req + 5 + strlen(Number), req_end, size);
 
        Protocol->SendMessage(5 + size + strlen(Number), 0x01, req);
-       if (type != 1) Protocol->SendMessage(26, 0x01, req2);
+        usleep(1000000);
+
+       if (type != 1) {
+          Protocol->SendMessage(26, 0x01, req2);
+         usleep(1000000);
+        }
 
        return (GE_NONE);
 }
@@ -3136,7 +3144,8 @@ void N6110_ReplyGetMemoryLocation(u16 MessageLength, u8 *MessageBuffer, u8 Messa
     while (N6110_GetModel(model)  != GE_NONE)
       sleep(1);
         
-    if (GetModelFeature (FN_PHONEBOOK)==F_PBK33) {//pbk with Unicode
+    if (GetModelFeature (FN_PHONEBOOK)==F_PBK33SIM ||
+        GetModelFeature (FN_PHONEBOOK)==F_PBK33INT) {//pbk with Unicode
       DecodeUnicode (CurrentPhonebookEntry->Name, MessageBuffer+6, count/2);
       CurrentPhonebookEntry->Name[count/2] = 0x00;
     } else {
@@ -3148,7 +3157,8 @@ void N6110_ReplyGetMemoryLocation(u16 MessageLength, u8 *MessageBuffer, u8 Messa
 
     for (tmp=0; tmp <count; tmp++)
     {
-      if (GetModelFeature (FN_PHONEBOOK)==F_PBK33) {//pbk with Unicode
+      if (GetModelFeature (FN_PHONEBOOK)==F_PBK33INT ||
+          GetModelFeature (FN_PHONEBOOK)==F_PBK33SIM) {//pbk with Unicode
         /* We check only 1'st, 3'rd, ... char */
         if (tmp%2!=0 && MessageBuffer[6+tmp]==1) CurrentPhonebookEntry->Name[tmp/2]='~'; //enables/disables blinking
         if (tmp%2!=0 && MessageBuffer[6+tmp]==0) CurrentPhonebookEntry->Name[tmp/2]='`'; //hides rest ot contents
@@ -3305,7 +3315,8 @@ GSM_Error N6110_WritePhonebookLocation(GSM_PhonebookEntry *entry)
 
   current=7;
 
-  if (GetModelFeature (FN_PHONEBOOK)==F_PBK33) {
+  if (GetModelFeature (FN_PHONEBOOK)==F_PBK33INT ||
+      GetModelFeature (FN_PHONEBOOK)==F_PBK33SIM) {
 
      req[6] = strlen(entry->Name)*2;
 
@@ -4789,7 +4800,7 @@ void N6110_Dispatch0x03Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageT
        CurrentGetBitmap->width=MessageBuffer[count++];
         CurrentGetBitmap->height=MessageBuffer[count++];
        count++;
-       tmp=CurrentGetBitmap->height*CurrentGetBitmap->width/8;
+       tmp=GSM_GetBitmapSize(CurrentGetBitmap);
        if (CurrentGetBitmap->size>tmp) CurrentGetBitmap->size=tmp;
        memcpy(CurrentGetBitmap->bitmap,MessageBuffer+count,CurrentGetBitmap->size);
        CurrentGetBitmapError=GE_NONE;
@@ -4873,10 +4884,11 @@ void N6110_Dispatch0x05Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageT
           if (CurrentGetBitmap->type==GSM_StartupLogo) {
             CurrentGetBitmap->height=MessageBuffer[count++];
            CurrentGetBitmap->width=MessageBuffer[count++];
-           CurrentGetBitmap->size=CurrentGetBitmap->height*CurrentGetBitmap->width/8;
+           CurrentGetBitmap->size=GSM_GetBitmapSize(CurrentGetBitmap);
            length=CurrentGetBitmap->size;
            memcpy(CurrentGetBitmap->bitmap,MessageBuffer+count,length);
           } else {
+            //bitmap size
            length=MessageBuffer[count++];
            length=length*MessageBuffer[count++]/8;
          }
@@ -4991,7 +5003,7 @@ void N6110_Dispatch0x05Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageT
       CurrentGetBitmap->width=MessageBuffer[count++];
       CurrentGetBitmap->height=MessageBuffer[count++];
       count++;
-      tmp=CurrentGetBitmap->height*CurrentGetBitmap->width/8;
+      tmp=GSM_GetBitmapSize(CurrentGetBitmap);
       if (CurrentGetBitmap->size>tmp) CurrentGetBitmap->size=tmp;
       memcpy(CurrentGetBitmap->bitmap,MessageBuffer+count,CurrentGetBitmap->size);
       CurrentGetBitmapError=GE_NONE;
@@ -5235,7 +5247,7 @@ void N6110_Dispatch0x47Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageT
 
     CurrentGetBitmap->width=MessageBuffer[count+1];
     CurrentGetBitmap->height=MessageBuffer[count+2]; 
-    CurrentGetBitmap->size=CurrentGetBitmap->height*CurrentGetBitmap->width/8;
+    CurrentGetBitmap->size=GSM_GetBitmapSize(CurrentGetBitmap);
       
     memcpy(CurrentGetBitmap->bitmap,MessageBuffer+count+4,CurrentGetBitmap->size);