-rw-r--r-- | gammu/emb/gammu/gammu.c | 47 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 6 |
2 files changed, 50 insertions, 3 deletions
diff --git a/gammu/emb/gammu/gammu.c b/gammu/emb/gammu/gammu.c index 1d53fb0..5163d81 100644 --- a/gammu/emb/gammu/gammu.c +++ b/gammu/emb/gammu/gammu.c @@ -6201,2156 +6201,2201 @@ static void EnterSecurityCode(int argc, char *argv[]) GSM_Init(true); error=Phone->EnterSecurityCode(&s,Code); Print_Error(error); GSM_Terminate(); } static void GetProfile(int argc, char *argv[]) { GSM_Profile Profile; int start,stop,j,k; GSM_Bitmap caller[5]; bool callerinit[5],special; GSM_AllRingtonesInfo Info; GetStartStop(&start, &stop, 2, argc, argv); for (i=0;i<5;i++) callerinit[i] = false; GSM_Init(true); error=Phone->GetRingtonesInfo(&s,&Info); if (error != ERR_NONE) Info.Number = 0; for (i=start;i<=stop;i++) { Profile.Location=i; error=Phone->GetProfile(&s,&Profile); Print_Error(error); printmsg("%i. \"%s\"",i,DecodeUnicodeConsole(Profile.Name)); if (Profile.Active) printmsg(" (active)"); if (Profile.DefaultName) printmsg(" (default name)"); if (Profile.HeadSetProfile) printmsg(" (HeadSet profile)"); if (Profile.CarKitProfile) printmsg(" (CarKit profile)"); printf("\n"); for (j=0;j<Profile.FeaturesNumber;j++) { special = false; switch (Profile.FeatureID[j]) { case Profile_MessageToneID: case Profile_RingtoneID: special = true; if (Profile.FeatureID[j] == Profile_RingtoneID) { printmsg("Ringtone ID : "); } else { printmsg("Message alert tone ID : "); } if (UnicodeLength(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))!=0) { printmsg("\"%s\"\n",DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))); } else { printmsg("%i\n",Profile.FeatureValue[j]); } break; case Profile_CallerGroups: special = true; printmsg("Call alert for :"); for (k=0;k<5;k++) { if (Profile.CallerGroups[k]) { if (!callerinit[k]) { caller[k].Type = GSM_CallerGroupLogo; caller[k].Location = k + 1; error=Phone->GetBitmap(&s,&caller[k]); if (error == ERR_SECURITYERROR) { NOKIA_GetDefaultCallerGroupName(&s,&caller[k]); } else { Print_Error(error); } callerinit[k] = true; } printmsg(" \"%s\"",DecodeUnicodeConsole(caller[k].Text)); } } printf("\n"); break; case Profile_ScreenSaverNumber: special = true; printmsg("Screen saver number : "); printmsg("%i\n",Profile.FeatureValue[j]); break; case Profile_CallAlert : printmsg("Incoming call alert : "); break; case Profile_RingtoneVolume : printmsg("Ringtone volume : "); break; case Profile_Vibration : printmsg("Vibrating alert : "); break; case Profile_MessageTone : printmsg("Message alert tone : "); break; case Profile_KeypadTone : printmsg("Keypad tones : "); break; case Profile_WarningTone : printmsg("Warning (games) tones : "); break; case Profile_ScreenSaver : printmsg("Screen saver : "); break; case Profile_ScreenSaverTime : printmsg("Screen saver timeout : "); break; case Profile_AutoAnswer : printmsg("Automatic answer : "); break; case Profile_Lights : printmsg("Lights : "); break; default: printmsg("Unknown\n"); special = true; } if (!special) { switch (Profile.FeatureValue[j]) { case PROFILE_VOLUME_LEVEL1 : case PROFILE_KEYPAD_LEVEL1 : printmsg("Level 1\n"); break; case PROFILE_VOLUME_LEVEL2 : case PROFILE_KEYPAD_LEVEL2 : printmsg("Level 2\n"); break; case PROFILE_VOLUME_LEVEL3 : case PROFILE_KEYPAD_LEVEL3 : printmsg("Level 3\n"); break; case PROFILE_VOLUME_LEVEL4 : printmsg("Level 4\n"); break; case PROFILE_VOLUME_LEVEL5 : printmsg("Level 5\n"); break; case PROFILE_MESSAGE_NOTONE : case PROFILE_AUTOANSWER_OFF : case PROFILE_LIGHTS_OFF : case PROFILE_SAVER_OFF : case PROFILE_WARNING_OFF : case PROFILE_CALLALERT_OFF : case PROFILE_VIBRATION_OFF : case PROFILE_KEYPAD_OFF : printmsg("Off\n"); break; case PROFILE_CALLALERT_RINGING : printmsg("Ringing\n"); break; case PROFILE_CALLALERT_BEEPONCE : case PROFILE_MESSAGE_BEEPONCE : printmsg("Beep once\n"); break; case PROFILE_CALLALERT_RINGONCE : printmsg("Ring once\n"); break; case PROFILE_CALLALERT_ASCENDING : printmsg("Ascending\n"); break; case PROFILE_CALLALERT_CALLERGROUPS : printmsg("Caller groups\n"); break; case PROFILE_MESSAGE_STANDARD : printmsg("Standard\n"); break; case PROFILE_MESSAGE_SPECIAL : printmsg("Special\n"); break; case PROFILE_MESSAGE_ASCENDING : printmsg("Ascending\n"); break; case PROFILE_MESSAGE_PERSONAL : printmsg("Personal\n"); break; case PROFILE_AUTOANSWER_ON : case PROFILE_WARNING_ON : case PROFILE_SAVER_ON : case PROFILE_VIBRATION_ON : printmsg("On\n"); break; case PROFILE_VIBRATION_FIRST : printmsg("Vibrate first\n"); break; case PROFILE_LIGHTS_AUTO : printmsg("Auto\n"); break; case PROFILE_SAVER_TIMEOUT_5SEC : printmsg("5 seconds\n"); break; case PROFILE_SAVER_TIMEOUT_20SEC : printmsg("20 seconds\n"); break; case PROFILE_SAVER_TIMEOUT_1MIN : printmsg("1 minute\n"); break; case PROFILE_SAVER_TIMEOUT_2MIN : printmsg("2 minutes\n"); break; case PROFILE_SAVER_TIMEOUT_5MIN : printmsg("5 minutes\n"); break; case PROFILE_SAVER_TIMEOUT_10MIN : printmsg("10 minutes\n"); break; default : printmsg("UNKNOWN\n"); } } } printf("\n"); } GSM_Terminate(); } static void GetSpeedDial(int argc, char *argv[]) { GSM_SpeedDial SpeedDial; GSM_MemoryEntry Phonebook; int start,stop,Name,Number,Group; GetStartStop(&start, &stop, 2, argc, argv); GSM_Init(true); for (i=start;i<=stop;i++) { SpeedDial.Location=i; error=Phone->GetSpeedDial(&s,&SpeedDial); printmsg("%i.",i); switch (error) { case ERR_EMPTY: printmsg(" speed dial not assigned\n"); break; default: Print_Error(error); Phonebook.Location = SpeedDial.MemoryLocation; Phonebook.MemoryType = SpeedDial.MemoryType; error=Phone->GetMemory(&s,&Phonebook); GSM_PhonebookFindDefaultNameNumberGroup(&Phonebook, &Name, &Number, &Group); if (Name != -1) printmsg(" Name \"%s\",",DecodeUnicodeConsole(Phonebook.Entries[Name].Text)); printmsg(" Number \"%s\"",DecodeUnicodeConsole(Phonebook.Entries[SpeedDial.MemoryNumberID-1].Text)); } printf("\n"); } GSM_Terminate(); } static void ResetPhoneSettings(int argc, char *argv[]) { GSM_ResetSettingsType Type; if (mystrncasecmp(argv[2],"PHONE",0)) { Type = GSM_RESET_PHONESETTINGS; } else if (mystrncasecmp(argv[2],"UIF",0)) { Type = GSM_RESET_USERINTERFACE; } else if (mystrncasecmp(argv[2],"ALL",0)) { Type = GSM_RESET_USERINTERFACE_PHONESETTINGS; } else if (mystrncasecmp(argv[2],"DEV",0)) { Type = GSM_RESET_DEVICE; } else if (mystrncasecmp(argv[2],"FACTORY",0)) { Type = GSM_RESET_FULLFACTORY; } else { printmsg("What type of reset phone settings (\"%s\") ?\n",argv[2]); exit(-1); } GSM_Init(true); error=Phone->ResetPhoneSettings(&s,Type); Print_Error(error); GSM_Terminate(); } #if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) static void NokiaSecurityCode(int argc, char *argv[]) { GSM_Init(true); #ifdef GSM_ENABLE_NOKIA_DCT3 DCT3GetSecurityCode(argc,argv); #endif #ifdef GSM_ENABLE_NOKIA_DCT4 // DCT4ResetSecurityCode(argc, argv); DCT4GetSecurityCode(argc,argv); #endif GSM_Terminate(); } static void NokiaSetPhoneMenus(int argc, char *argv[]) { GSM_Init(true); #ifdef GSM_ENABLE_NOKIA_DCT3 DCT3SetPhoneMenus (argc, argv); #endif #ifdef GSM_ENABLE_NOKIA_DCT4 DCT4SetPhoneMenus (argc, argv); #endif GSM_Terminate(); } static void NokiaSelfTests(int argc, char *argv[]) { GSM_Init(true); #ifdef GSM_ENABLE_NOKIA_DCT3 DCT3SelfTests(argc, argv); #endif #ifdef GSM_ENABLE_NOKIA_DCT4 DCT4SelfTests(argc, argv); #endif GSM_Terminate(); } #endif static void DeleteAllSMS(int argc, char *argv[]) { GSM_MultiSMSMessage sms; GSM_SMSFolders folders; int foldernum; bool start = true; GSM_Init(true); error=Phone->GetSMSFolders(&s, &folders); Print_Error(error); GetStartStop(&foldernum, NULL, 2, argc, argv); if (foldernum > folders.Number) { printmsg("Too high folder number (max. %i)\n",folders.Number); GSM_Terminate(); exit(-1); } printmsg("Deleting SMS from \"%s\" folder: ",DecodeUnicodeConsole(folders.Folder[foldernum-1].Name)); while (error == ERR_NONE) { sms.SMS[0].Folder=0x00; error=Phone->GetNextSMS(&s, &sms, start); switch (error) { case ERR_EMPTY: break; default: Print_Error(error); if (sms.SMS[0].Folder == foldernum) { sms.SMS[0].Folder=0x00; error=Phone->DeleteSMS(&s, &sms.SMS[0]); Print_Error(error); printmsg("*"); } } start=false; } printf("\n"); GSM_Terminate(); } static void SendDTMF(int argc, char *argv[]) { GSM_Init(true); error=Phone->SendDTMF(&s,argv[2]); Print_Error(error); GSM_Terminate(); } static void GetDisplayStatus(int argc, char *argv[]) { GSM_DisplayFeatures Features; int i; GSM_Init(true); error=Phone->GetDisplayStatus(&s,&Features); Print_Error(error); printmsg("Current display features :\n"); for (i=0;i<Features.Number;i++) { switch(Features.Feature[i]) { case GSM_CallActive : printmsg("Call active\n"); break; case GSM_UnreadSMS : printmsg("Unread SMS\n"); break; case GSM_VoiceCall : printmsg("Voice call\n"); break; case GSM_FaxCall : printmsg("Fax call\n"); break; case GSM_DataCall : printmsg("Data call\n"); break; case GSM_KeypadLocked : printmsg("Keypad locked\n"); break; case GSM_SMSMemoryFull : printmsg("SMS memory full\n"); } } GSM_Terminate(); } static void SetAutoNetworkLogin(int argc, char *argv[]) { GSM_Init(true); error=Phone->SetAutoNetworkLogin(&s); Print_Error(error); GSM_Terminate(); } #ifdef DEBUG static void MakeConvertTable(int argc, char *argv[]) { unsigned char InputBuffer[10000], Buffer[10000]; FILE *file; int size,i,j=0; file = fopen(argv[2], "rb"); if (file == NULL) Print_Error(ERR_CANTOPENFILE); size=fread(InputBuffer, 1, 10000-1, file); fclose(file); InputBuffer[size] = 0; InputBuffer[size+1] = 0; ReadUnicodeFile(Buffer,InputBuffer); for(i=0;i<((int)UnicodeLength(Buffer));i++) { j++; if (j==100) { printf("\"\\\n\""); j=0; } printf("\\x%02x\\x%02x",Buffer[i*2],Buffer[i*2+1]); } printf("\\x00\\x00"); } #endif static void ListNetworks(int argc, char *argv[]) { extern unsigned char *GSM_Networks[]; int i=0; printmsg("Network Name\n\n"); while (GSM_Networks[i*2]!=NULL) { printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]); i++; } } static void Version(int argc, char *argv[]) { // unsigned char buff[10]; // int len; printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__); #ifdef DEBUG printf("GSM_SMSMessage - %i\n",sizeof(GSM_SMSMessage)); printf("GSM_SMSC - %i\n",sizeof(GSM_SMSC)); printf("GSM_SMS_State - %i\n",sizeof(GSM_SMS_State)); printf("GSM_UDHHeader - %i\n",sizeof(GSM_UDHHeader)); printf("bool - %i\n",sizeof(bool)); printf("GSM_DateTime - %i\n",sizeof(GSM_DateTime)); printf("int - %i\n",sizeof(int)); printf("GSM_NetworkInfo - %i\n",sizeof(GSM_NetworkInfo)); #endif // len=DecodeBASE64("AXw", buff, 3); // DumpMessage(stdout, buff, len); } static void GetFMStation(int argc, char *argv[]) { GSM_FMStation Station; int start,stop; GetStartStop(&start, &stop, 2, argc, argv); GSM_Init(true); for (i=start;i<=stop;i++) { Station.Location=i; error=Phone->GetFMStation(&s,&Station); switch (error) { case ERR_EMPTY: printmsg("Entry number %i is empty\n",i); break; case ERR_NONE: printmsg("Entry number %i\nStation name : \"%s\"\nFrequency : %.1f MHz\n", i,DecodeUnicodeConsole(Station.StationName), Station.Frequency); break; default: Print_Error(error); } } GSM_Terminate(); } static void GetFileSystemStatus(int argc, char *argv[]) { GSM_FileSystemStatus Status; GSM_Init(true); error = Phone->GetFileSystemStatus(&s,&Status); if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) { Print_Error(error); printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used); } GSM_Terminate(); } static void GetFileSystem(int argc, char *argv[]) { bool Start = true; GSM_File Files; int j; GSM_FileSystemStatus Status; char FolderName[256]; GSM_Init(true); while (1) { error = Phone->GetNextFileFolder(&s,&Files,Start); if (error == ERR_EMPTY) break; Print_Error(error); if (argc <= 2 || !mystrncasecmp(argv[2],"-flatall",0)) { if (strlen(Files.ID_FullName) < 5 && strlen(Files.ID_FullName) != 0) { printf("%5s.",Files.ID_FullName); } if (Files.Protected) { printf("P"); } else { printf(" "); } if (Files.ReadOnly) { printf("R"); } else { printf(" "); } if (Files.Hidden) { printf("H"); } else { printf(" "); } if (Files.System) { printf("S"); } else { printf(" "); } if (argc > 2 && mystrncasecmp(argv[2],"-flat",0)) { if (!Files.Folder) { if (mystrncasecmp(argv[2],"-flatall",0)) { if (!Files.ModifiedEmpty) { printf(" %30s",OSDateTime(Files.Modified,false)); } else printf(" %30c",0x20); printf(" %9i",Files.Used); printf(" "); } else printf("|-- "); } else printf("Folder "); } else { if (Files.Level != 1) { for (j=0;j<Files.Level-2;j++) printf(" | "); printf(" |-- "); } if (Files.Folder) printf("Folder "); } printf("\"%s\"",DecodeUnicodeConsole(Files.Name)); printf("\n"); Start = false; } else if (argc > 2 && mystrncasecmp(argv[2],"-flatall",0)) { /* format for a folder ID;Folder;FOLDER_NAME;[FOLDER_PARAMETERS] * format for a file ID;File;FOLDER_NAME;FILE_NAME;DATESTAMP;FILE_SIZE;[FILE_PARAMETERS] */ if (!Files.Folder) { printf("%s;File;",Files.ID_FullName); printf("\"%s\";",FolderName); printf("\"%s\";",DecodeUnicodeConsole(Files.Name)); if (!Files.ModifiedEmpty) { printf("\"%s\";",OSDateTime(Files.Modified,false)); } else printf("\"%c\";",0x20); printf("%i;",Files.Used); } else { printf("%s;Folder;",Files.ID_FullName); printf("\"%s\";",DecodeUnicodeConsole(Files.Name)); strcpy(FolderName,DecodeUnicodeConsole(Files.Name)); } if (Files.Protected) printf("P"); if (Files.ReadOnly) printf("R"); if (Files.Hidden) printf("H"); if (Files.System) printf("S"); printf("\n"); Start = false; } } error = Phone->GetFileSystemStatus(&s,&Status); if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) { Print_Error(error); printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used); } GSM_Terminate(); } static void GetOneFile(GSM_File *File, bool newtime, int i) { FILE *file; bool start; unsigned char buffer[5000]; struct utimbuf filedate; if (File->Buffer != NULL) { free(File->Buffer); File->Buffer = NULL; } File->Used = 0; start = true; error = ERR_NONE; while (error == ERR_NONE) { error = Phone->GetFilePart(&s,File); if (error == ERR_NONE || error == ERR_EMPTY || error == ERR_WRONGCRC) { if (start) { printmsg("Getting \"%s\": ", DecodeUnicodeConsole(File->Name)); start = false; } if (File->Folder) { free(File->Buffer); GSM_Terminate(); printmsg("it's folder. Please give only file names\n"); exit(-1); } printmsg("*"); if (error == ERR_EMPTY) break; if (error == ERR_WRONGCRC) { printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); break; } } Print_Error(error); } printf("\n"); if (File->Used != 0) { sprintf(buffer,"%s",DecodeUnicodeConsole(File->Name)); file = fopen(buffer,"wb"); if (file == NULL) { sprintf(buffer,"file%s",File->ID_FullName); file = fopen(buffer,"wb"); } if (file == NULL) { sprintf(buffer,"file%i",i); file = fopen(buffer,"wb"); } printmsg(" Saving to %s\n",buffer); if (!file) Print_Error(ERR_CANTOPENFILE); fwrite(File->Buffer,1,File->Used,file); fclose(file); if (!newtime && !File->ModifiedEmpty) { /* access time */ filedate.actime = Fill_Time_T(File->Modified, 8); /* modification time */ filedate.modtime = Fill_Time_T(File->Modified, 8); dbgprintf("Setting date of %s\n",buffer); utime(buffer,&filedate); } } } static void GetFiles(int argc, char *argv[]) { GSM_File File; int i; bool newtime = false; File.Buffer = NULL; GSM_Init(true); for (i=2;i<argc;i++) { if (mystrncasecmp(argv[i],"-newtime",0)) { newtime = true; continue; } strcpy(File.ID_FullName,argv[i]); GetOneFile(&File, newtime, i); } free(File.Buffer); GSM_Terminate(); } static void GetFileFolder(int argc, char *argv[]) { bool Start = true; GSM_File File; int level=0,allnum=0,num=0,filelevel=0; bool newtime = false, found; File.Buffer = NULL; GSM_Init(true); for (i=2;i<argc;i++) { if (mystrncasecmp(argv[i],"-newtime",0)) { newtime = true; continue; } allnum++; } while (allnum != num) { error = Phone->GetNextFileFolder(&s,&File,Start); if (error == ERR_EMPTY) break; Print_Error(error); if (level == 0) { /* We search for file or folder */ found = false; for (i=2;i<argc;i++) { if (mystrncasecmp(argv[i],"-newtime",0)) { continue; } if (!strcmp(File.ID_FullName,argv[i])) { found = true; if (File.Folder) { level = 1; filelevel = File.Level + 1; Start = false; } else { level = 2; } break; } } if (found && File.Folder) continue; } if (level == 1) { /* We have folder */ dbgprintf("%i %i\n",File.Level,filelevel); if (File.Level != filelevel) { level = 0; num++; } } if (level != 0 && !File.Folder) GetOneFile(&File, newtime,num); if (level == 2) { level = 0; num++; } Start = false; } free(File.Buffer); GSM_Terminate(); } static void AddFile(int argc, char *argv[]) { GSM_File File; int Pos = 0,i,nextlong; File.Buffer = NULL; strcpy(File.ID_FullName,argv[2]); error = GSM_ReadFile(argv[3], &File); Print_Error(error); EncodeUnicode(File.Name,argv[3],strlen(argv[3])); GSM_IdentifyFileFormat(&File); File.Protected = false; File.ReadOnly = false; File.Hidden = false; File.System = false; if (argc > 4) { nextlong = 0; for (i=4;i<argc;i++) { switch(nextlong) { case 0: if (mystrncasecmp(argv[i],"-type",0)) { nextlong = 1; continue; } if (mystrncasecmp(argv[i],"-protected",0)) { File.Protected = true; continue; } if (mystrncasecmp(argv[i],"-readonly",0)) { File.ReadOnly = true; continue; } if (mystrncasecmp(argv[i],"-hidden",0)) { File.Hidden = true; continue; } if (mystrncasecmp(argv[i],"-system",0)) { File.System = true; continue; } if (mystrncasecmp(argv[i],"-newtime",0)) { File.ModifiedEmpty = true; continue; } printmsg("Parameter \"%s\" unknown\n",argv[i]); exit(-1); case 1: if (mystrncasecmp(argv[i],"JAR",0)) { File.Type = GSM_File_Java_JAR; } else if (mystrncasecmp(argv[i],"JPG",0)) { File.Type = GSM_File_Image_JPG; } else if (mystrncasecmp(argv[i],"BMP",0)) { File.Type = GSM_File_Image_BMP; } else if (mystrncasecmp(argv[i],"WBMP",0)) { File.Type = GSM_File_Image_WBMP; } else if (mystrncasecmp(argv[i],"GIF",0)) { File.Type = GSM_File_Image_GIF; } else if (mystrncasecmp(argv[i],"PNG",0)) { File.Type = GSM_File_Image_PNG; } else if (mystrncasecmp(argv[i],"MIDI",0)) { File.Type = GSM_File_Sound_MIDI; } else if (mystrncasecmp(argv[i],"AMR",0)) { File.Type = GSM_File_Sound_AMR; } else if (mystrncasecmp(argv[i],"NRT",0)) { File.Type = GSM_File_Sound_NRT; } else if (mystrncasecmp(argv[i],"3GP",0)) { File.Type = GSM_File_Video_3GP; } else { printmsg("What file type (\"%s\") ?\n",argv[i]); exit(-1); } nextlong = 0; break; } } if (nextlong!=0) { printmsg("Parameter missed...\n"); exit(-1); } } GSM_Init(true); error = ERR_NONE; while (error == ERR_NONE) { error = Phone->AddFilePart(&s,&File,&Pos); if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); printmsgerr("%cWriting: %i percent",13,Pos*100/File.Used); } printmsgerr("\n"); if (error == ERR_WRONGCRC) { printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); } free(File.Buffer); GSM_Terminate(); } static void AddFolder(int argc, char *argv[]) { GSM_File File; strcpy(File.ID_FullName,argv[2]); EncodeUnicode(File.Name,argv[3],strlen(argv[3])); File.ReadOnly = false; GSM_Init(true); error = Phone->AddFolder(&s,&File); Print_Error(error); GSM_Terminate(); } struct NokiaFolderInfo { char *model; char *parameter; char *folder; char *level; }; static struct NokiaFolderInfo Folder[] = { /* Language indepedent in DCT4 */ {"", "MMSUnreadInbox", "INBOX", "3"}, {"", "MMSReadInbox", "INBOX", "3"}, {"", "MMSOutbox", "OUTBOX", "3"}, {"", "MMSSent", "SENT", "3"}, {"", "MMSDrafts", "DRAFTS", "3"}, {"", "Application", "applications", "3"}, {"", "Game", "games", "3"}, /* Language depedent in DCT4 */ {"", "Gallery", "Pictures", "2"}, /* 3510 */ {"", "Gallery", "Graphics", "3"}, /* 3510i */ {"", "Gallery", "Images", "3"}, /* 6610 */ {"3510", "Gallery", "", "8"}, {"3510i","Gallery", "", "3"}, {"5100", "Gallery", "", "3"}, {"6220", "Gallery", "", "5"}, {"", "Tones", "Tones", "3"}, {"3510i","Tones", "", "4"}, {"5100", "Tones", "", "4"}, {"6220", "Tones", "", "6"}, /* Language indepedent in OBEX */ {"obex", "MMSUnreadInbox", "", "predefMessages\\predefINBOX" }, {"obex", "MMSReadInbox", "", "predefMessages\\predefINBOX" }, {"obex", "MMSOutbox", "", "predefMessages\\predefOUTBOX" }, {"obex", "MMSSent", "", "predefMessages\\predefSENT" }, {"obex", "MMSDrafts", "", "predefMessages\\predefDRAFTS" }, // {"obex", "Application, "", "predefjava\\predefapplications"}, // {"obex", "Game", "", "predefjava\\predefgames" }, {"obex", "Gallery", "", "predefgallery\\predefgraphics" }, {"obex", "Tones", "", "predefgallery\\predeftones" }, /* End of list */ {"", "", "", ""} }; static void NokiaAddFile(int argc, char *argv[]) { GSM_File File, Files; FILE *file; GSM_DateTime DT,DT2; time_t t_time1,t_time2; unsigned char buffer[10000],JAR[500],Vendor[500],Name[500],Version[500],FileID[400]; bool Start = true, Found = false, wasclr; bool ModEmpty = false; int i = 0, Pos, Size, Size2, nextlong; while (Folder[i].level[0] != 0) { if (mystrncasecmp(argv[2],Folder[i].parameter,0)) { Found = true; break; } i++; } if (!Found) { printmsg("What folder type (\"%s\") ?\n",argv[2]); exit(-1); } GSM_Init(true); if (s.ConnectionType == GCT_IRDAOBEX || s.ConnectionType == GCT_BLUEOBEX) { Found = false; i = 0; while (Folder[i].level[0] != 0) { if (!strcmp("obex",Folder[i].model) && mystrncasecmp(argv[2],Folder[i].parameter,0)) { strcpy(Files.ID_FullName,Folder[i].level); Found = true; break; } i++; } } else { printmsgerr("Searching for phone folder: "); while (1) { error = Phone->GetNextFileFolder(&s,&Files,Start); if (error == ERR_EMPTY) break; Print_Error(error); if (Files.Folder) { dbgprintf("folder %s level %i\n",DecodeUnicodeConsole(Files.Name),Files.Level); Found = false; i = 0; while (Folder[i].level[0] != 0) { EncodeUnicode(buffer,Folder[i].folder,strlen(Folder[i].folder)); dbgprintf("comparing \"%s\" \"%s\" \"%s\"\n",s.Phone.Data.ModelInfo->model,Files.ID_FullName,Folder[i].level); if (mystrncasecmp(argv[2],Folder[i].parameter,0) && mywstrncasecmp(Files.Name,buffer,0) && Files.Level == atoi(Folder[i].level)) { Found = true; break; } if (!strcmp(s.Phone.Data.ModelInfo->model,Folder[i].model) && mystrncasecmp(argv[2],Folder[i].parameter,0) && !strcmp(Files.ID_FullName,Folder[i].level)) { Found = true; break; } i++; } if (Found) break; } printmsgerr("*"); Start = false; } printmsgerr("\n"); } if (!Found) { printmsg("Folder not found. Probably function not supported !\n"); GSM_Terminate(); exit(-1); } File.Buffer = NULL; File.Protected = false; File.ReadOnly = false; File.Hidden = false; File.System = false; if (mystrncasecmp(argv[2],"Application",0) || mystrncasecmp(argv[2],"Game",0)) { sprintf(buffer,"%s.jad",argv[3]); file = fopen(buffer,"rb"); if (file == NULL) Print_Error(ERR_CANTOPENFILE); fclose(file); sprintf(buffer,"%s.jar",argv[3]); file = fopen(buffer,"rb"); if (file == NULL) Print_Error(ERR_CANTOPENFILE); fclose(file); /* reading jar file */ sprintf(buffer,"%s.jar",argv[3]); error = GSM_ReadFile(buffer, &File); Print_Error(error); Size2 = File.Used; /* reading jad file */ sprintf(buffer,"%s.jad",argv[3]); error = GSM_ReadFile(buffer, &File); Print_Error(error); /* Getting values from JAD file */ error = GSM_JADFindData(File, Vendor, Name, JAR, Version, &Size); if (error == ERR_FILENOTSUPPORTED) { if (Vendor[0] == 0x00) { printmsgerr("No vendor info in JAD file\n"); GSM_Terminate(); return; } if (Name[0] == 0x00) { printmsgerr("No name info in JAD file\n"); GSM_Terminate(); return; } if (JAR[0] == 0x00) { printmsgerr("No JAR URL info in JAD file\n"); GSM_Terminate(); return; } if (Size == -1) { printmsgerr("No JAR size info in JAD file\n"); GSM_Terminate(); return; } } if (Size != Size2) { printmsgerr("Declared JAR file size is different than real\n"); GSM_Terminate(); return; } printmsgerr("Adding \"%s\"",Name); if (Version[0] != 0x00) printmsgerr(" version %s",Version); printmsgerr(" created by %s\n",Vendor); /* Bostjan Muller 3200 RH-30 3.08 */ if (strstr(JAR,"http://") != NULL) { i = strlen(JAR)-1; while (JAR[i] != '/') i--; strcpy(buffer,JAR+i+1); strcpy(JAR,buffer); dbgprintf("New file name is \"%s\"\n",JAR); } /* Changing all #13 or #10 to #13#10 in JAD */ Pos = 0; wasclr = false; for (i=0;i<File.Used;i++) { switch (File.Buffer[i]) { case 0x0D: case 0x0A: if (!wasclr) { buffer[Pos++] = 0x0D; buffer[Pos++] = 0x0A; wasclr = true; } else wasclr = false; break; default: buffer[Pos++] = File.Buffer[i]; wasclr = false; } } File.Buffer = realloc(File.Buffer, Pos); File.Used = Pos; memcpy(File.Buffer,buffer,Pos); /* adding folder */ strcpy(buffer,Vendor); strcat(buffer,Name); EncodeUnicode(File.Name,buffer,strlen(buffer)); strcpy(File.ID_FullName,Files.ID_FullName); error = Phone->AddFolder(&s,&File); Print_Error(error); strcpy(FileID,File.ID_FullName); /* adding jad file */ strcpy(buffer,JAR); buffer[strlen(buffer) - 1] = 'd'; EncodeUnicode(File.Name,buffer,strlen(buffer)); File.Type = GSM_File_Other; File.ModifiedEmpty = true; error = ERR_NONE; Pos = 0; while (error == ERR_NONE) { error = Phone->AddFilePart(&s,&File,&Pos); if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); printmsgerr("%cWriting JAD file: %i percent",13,Pos*100/File.Used); } printmsgerr("\n"); if (error == ERR_WRONGCRC) { printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); } if (argc > 4) { if (mystrncasecmp(argv[4],"-readonly",0)) File.ReadOnly = true; } /* reading jar file */ sprintf(buffer,"%s.jar",argv[3]); error = GSM_ReadFile(buffer, &File); Print_Error(error); /* adding jar file */ strcpy(File.ID_FullName,FileID); strcpy(buffer,JAR); EncodeUnicode(File.Name,buffer,strlen(buffer)); File.Type = GSM_File_Java_JAR; File.ModifiedEmpty = true; error = ERR_NONE; Pos = 0; while (error == ERR_NONE) { error = Phone->AddFilePart(&s,&File,&Pos); if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); printmsgerr("%cWriting JAR file: %i percent",13,Pos*100/File.Used); } printmsgerr("\n"); if (error == ERR_WRONGCRC) { printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); } free(File.Buffer); GSM_Terminate(); return; } if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) { strcpy(buffer,argv[3]); if (argc > 4) { nextlong = 0; for (i=4;i<argc;i++) { switch(nextlong) { case 0: if (mystrncasecmp(argv[i],"-name",0)) { nextlong = 1; continue; } if (mystrncasecmp(argv[i],"-protected",0)) { File.Protected = true; continue; } if (mystrncasecmp(argv[i],"-readonly",0)) { File.ReadOnly = true; continue; } if (mystrncasecmp(argv[i],"-hidden",0)) { File.Hidden = true; continue; } if (mystrncasecmp(argv[i],"-system",0)) { File.System = true; continue; } if (mystrncasecmp(argv[i],"-newtime",0)) { ModEmpty = true; continue; } printmsg("Parameter \"%s\" unknown\n",argv[i]); exit(-1); case 1: strcpy(buffer,argv[i]); nextlong = 0; break; } } if (nextlong!=0) { printmsg("Parameter missed...\n"); exit(-1); } } } else { /* MMS things */ DT2.Year = 2001; DT2.Month = 12; DT2.Day = 31; DT2.Hour = 14; DT2.Minute = 00; DT2.Second = 00; t_time2 = Fill_Time_T(DT2,8); GSM_GetCurrentDateTime(&DT); t_time1 = Fill_Time_T(DT,8); sprintf(buffer,"%07X %07X ",(int)(t_time1-t_time2-40),(int)(t_time1-t_time2-40)); #ifdef DEVELOP sprintf(buffer,"2A947BD 2A947DB "); #endif /* 40 = inbox "multimedia message received" message */ /* 30 = outbox sending failed */ if (mystrncasecmp(argv[2],"MMSUnreadInbox",0)) strcat(buffer,"43 "); else if (mystrncasecmp(argv[2],"MMSReadInbox",0)) strcat(buffer,"50 "); else if (mystrncasecmp(argv[2],"MMSOutbox",0)) strcat(buffer,"10 "); else if (mystrncasecmp(argv[2],"MMSSent",0)) strcat(buffer,"20 "); else if (mystrncasecmp(argv[2],"MMSDrafts",0)) strcat(buffer,"61 "); if (argc > 4) { if (!mystrncasecmp(argv[2],"MMSOutbox",0) && !mystrncasecmp(argv[2],"MMSSent",0)) { sprintf(Name,"%s",argv[4]); strcat(buffer,Name); } if (argc > 5) { sprintf(Name,"%zd%s/TYPE=PLMN",strlen(argv[5])+10,argv[5]); strcat(buffer,Name); } } ModEmpty = true; } error = GSM_ReadFile(argv[3], &File); Print_Error(error); if (ModEmpty) File.ModifiedEmpty = true; strcpy(File.ID_FullName,Files.ID_FullName); EncodeUnicode(File.Name,buffer,strlen(buffer)); GSM_IdentifyFileFormat(&File); #ifdef DEVELOP if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) { } else { /* MMS things */ File.Type = GSM_File_MMS; } #endif dbgprintf("Adding file to filesystem now\n"); error = ERR_NONE; Pos = 0; while (error == ERR_NONE) { error = Phone->AddFilePart(&s,&File,&Pos); if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); if (File.Used != 0) printmsgerr("%cWriting file: %i percent",13,Pos*100/File.Used); } printmsgerr("\n"); if (error == ERR_WRONGCRC) { printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); } free(File.Buffer); GSM_Terminate(); } static void DeleteFiles(int argc, char *argv[]) { int i; GSM_Init(true); for (i=2;i<argc;i++) { error = Phone->DeleteFile(&s,argv[i]); Print_Error(error); } GSM_Terminate(); } static void SaveMMSFile(int argc, char *argv[]) { FILE *file; unsigned char Buffer[50000],Buffer2[20][2010]; int i,nextlong = 0,len = 0; GSM_EncodeMultiPartMMSInfo Info; GSM_ClearMultiPartMMSInfo(&Info); for (i=3;i<argc;i++) { switch (nextlong) { case 0: if (mystrncasecmp(argv[i],"-subject",0)) { nextlong=1; continue; } if (mystrncasecmp(argv[i],"-text",0)) { nextlong=2; continue; } if (mystrncasecmp(argv[i],"-from",0)) { nextlong=3; continue; } if (mystrncasecmp(argv[i],"-to",0)) { nextlong=4; continue; } printmsg("Unknown parameter (\"%s\")\n",argv[i]); exit(-1); break; case 1: /* Subject */ EncodeUnicode(Info.Subject,argv[i],strlen(argv[i])); nextlong = 0; break; case 2: /* Text */ EncodeUnicode(Buffer2[Info.EntriesNum],argv[i],strlen(argv[i])); Info.Entries[Info.EntriesNum].ID = MMS_Text; Info.Entries[Info.EntriesNum].Buffer = Buffer2[Info.EntriesNum]; Info.EntriesNum++; nextlong = 0; break; case 3: /* From */ EncodeUnicode(Info.Source,argv[i],strlen(argv[i])); nextlong = 0; break; case 4: /* To */ EncodeUnicode(Info.Destination,argv[i],strlen(argv[i])); nextlong = 0; break; } } if (nextlong!=0) { printmsg("Parameter missed...\n"); exit(-1); } GSM_EncodeMMSFile(&Info,Buffer,&len); file = fopen(argv[2],"wb"); if (file == NULL) Print_Error(ERR_CANTOPENFILE); fwrite(Buffer,1,len,file); fclose(file); } static void CallDivert(int argc, char *argv[]) { GSM_MultiCallDivert cd; if (mystrncasecmp("get", argv[2],0)) {} else if (mystrncasecmp("set", argv[2],0)) {} else { printmsg("Unknown divert action (\"%s\")\n",argv[2]); exit(-1); } if (mystrncasecmp("all" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_AllTypes ;} else if (mystrncasecmp("busy" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_Busy ;} else if (mystrncasecmp("noans" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_NoAnswer ;} else if (mystrncasecmp("outofreach", argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_OutOfReach;} else { printmsg("Unknown divert type (\"%s\")\n",argv[3]); exit(-1); } if (mystrncasecmp("all" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_AllCalls ;} else if (mystrncasecmp("voice", argv[4],0)) {cd.Request.CallType = GSM_DIVERT_VoiceCalls;} else if (mystrncasecmp("fax" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_FaxCalls ;} else if (mystrncasecmp("data" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_DataCalls ;} else { printmsg("Unknown call type (\"%s\")\n",argv[4]); exit(-1); } GSM_Init(true); if (mystrncasecmp("get", argv[2],0)) { error = Phone->GetCallDivert(&s,&cd); Print_Error(error); printmsg("Query:\n Divert type: "); } else { cd.Request.Number[0] = 0; cd.Request.Number[1] = 0; if (argc > 5) EncodeUnicode(cd.Request.Number,argv[5],strlen(argv[5])); cd.Request.Timeout = 0; if (argc > 6) cd.Request.Timeout = atoi(argv[6]); error = Phone->SetCallDivert(&s,&cd); Print_Error(error); printmsg("Changed:\n Divert type: "); } switch (cd.Request.DivertType) { case GSM_DIVERT_Busy : printmsg("when busy"); break; case GSM_DIVERT_NoAnswer : printmsg("when not answered"); break; case GSM_DIVERT_OutOfReach: printmsg("when phone off or no coverage"); break; case GSM_DIVERT_AllTypes : printmsg("all types of diverts"); break; default : printmsg("unknown %i",cd.Request.DivertType); break; } printmsg("\n Calls type : "); switch (cd.Request.CallType) { case GSM_DIVERT_VoiceCalls: printmsg("voice"); break; case GSM_DIVERT_FaxCalls : printmsg("fax"); break; case GSM_DIVERT_DataCalls : printmsg("data"); break; case GSM_DIVERT_AllCalls : printmsg("data & fax & voice"); break; default : printmsg("unknown %i",cd.Request.CallType); break; } printmsg("\nResponse:"); for (i=0;i<cd.Response.EntriesNum;i++) { printmsg("\n Calls type : "); switch (cd.Response.Entries[i].CallType) { case GSM_DIVERT_VoiceCalls: printmsg("voice"); break; case GSM_DIVERT_FaxCalls : printmsg("fax"); break; case GSM_DIVERT_DataCalls : printmsg("data"); break; default : printmsg("unknown %i",cd.Response.Entries[i].CallType);break; } printf("\n"); printmsg(" Timeout : %i seconds\n",cd.Response.Entries[i].Timeout); printmsg(" Number : %s\n",DecodeUnicodeString(cd.Response.Entries[i].Number)); } printf("\n"); GSM_Terminate(); } //#if 0 static void CancelAllDiverts(int argc, char *argv[]) { GSM_Init(true); error = Phone->CancelAllDiverts(&s); Print_Error(error); GSM_Terminate(); } void SearchPhoneThread(OneDeviceInfo *Info) { int j; GSM_Error error; fprintf(stderr,"*********************************** \n"); fprintf(stderr,"*********************************** \n"); fprintf(stderr,"*********************************** \n"); fprintf(stderr,"*********************************** \n"); fprintf(stderr,"*********************************** \n"); #if 0 j = 0; while(strlen(Info->Connections[j].Connection) != 0) { memcpy(&Info->s.di,&s.di,sizeof(Debug_Info)); Info->s.msg = s.msg; Info->s.ConfigNum = 1; Info->s.opened = false; Info->s.Config[0].UseGlobalDebugFile = s.Config[0].UseGlobalDebugFile; Info->s.Config[0].Localize = s.Config[0].Localize; Info->s.Config[0].Device = Info->Device; Info->s.Config[0].Connection = Info->Connections[j].Connection; Info->s.Config[0].SyncTime = "no"; Info->s.Config[0].DebugFile = s.Config[0].DebugFile; Info->s.Config[0].Model[0] = 0; strcpy(Info->s.Config[0].DebugLevel,s.Config[0].DebugLevel); Info->s.Config[0].LockDevice = "no"; Info->s.Config[0].StartInfo = "no"; error = GSM_InitConnection(&Info->s,1); if (SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device); if (error == ERR_NONE) { error=Info->s.Phone.Functions->GetManufacturer(&Info->s); if (error == ERR_NONE) { error=Info->s.Phone.Functions->GetModel(&Info->s); if (error == ERR_NONE) { if (!SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device); printmsg(" Manufacturer : %s\n", Info->s.Phone.Data.Manufacturer); printmsg(" Model : %s (%s)\n", Info->s.Phone.Data.ModelInfo->model, Info->s.Phone.Data.Model); } else { if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg)); } } else { if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg)); } } else { if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg)); } if (error != ERR_DEVICEOPENERROR) { GSM_TerminateConnection(&Info->s); dbgprintf("Closing done\n"); } if (error == ERR_DEVICEOPENERROR || error == ERR_NONE) break; j++; } num--; #endif } //#undef HAVE_PTHREAD //#if 0 #if defined(WIN32) || defined(HAVE_PTHREAD) #ifdef HAVE_PTHREAD pthread_t Thread[100]; #endif void MakeSearchThread(int i) { num++; #ifdef HAVE_PTHREAD if (pthread_create(&Thread[i],NULL,(void *)SearchPhoneThread,&SearchDevices[i])!=0) { dbgprintf("Error creating thread\n"); } #else if (CreateThread((LPSECURITY_ATTRIBUTES)NULL,0, (LPTHREAD_START_ROUTINE)SearchPhoneThread,&SearchDevices[i], 0,NULL)==NULL) { dbgprintf("Error creating thread\n"); } #endif } static void SearchPhone(int argc, char *argv[]) { int i,dev = 0, dev2 = 0; SearchOutput = false; if (argc == 3 && mystrncasecmp(argv[2], "-debug",0)) SearchOutput = true; num = 0; #ifdef WIN32 # ifdef GSM_ENABLE_IRDADEVICE sprintf(SearchDevices[dev].Device,""); sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet"); SearchDevices[dev].Connections[1].Connection[0] = 0; dev++; # endif # ifdef GSM_ENABLE_SERIALDEVICE dev2 = dev; for(i=0;i<10;i++) { sprintf(SearchDevices[dev2].Device,"com%i:",i+1); sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); SearchDevices[dev2].Connections[4].Connection[0] = 0; dev2++; } # endif #endif #ifdef __linux__ # ifdef GSM_ENABLE_IRDADEVICE for(i=0;i<6;i++) { sprintf(SearchDevices[dev].Device,"/dev/ircomm%i",i); sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet"); sprintf(SearchDevices[dev].Connections[1].Connection,"at19200"); SearchDevices[dev].Connections[2].Connection[0] = 0; dev++; } # endif # ifdef GSM_ENABLE_SERIALDEVICE dev2 = dev; for(i=0;i<10;i++) { sprintf(SearchDevices[dev2].Device,"/dev/ttyS%i",i); sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); SearchDevices[dev2].Connections[4].Connection[0] = 0; dev2++; } for(i=0;i<8;i++) { sprintf(SearchDevices[dev2].Device,"/dev/ttyD00%i",i); sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); SearchDevices[dev2].Connections[4].Connection[0] = 0; dev2++; } for(i=0;i<4;i++) { sprintf(SearchDevices[dev2].Device,"/dev/usb/tts/%i",i); sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); SearchDevices[dev2].Connections[4].Connection[0] = 0; dev2++; } # endif #endif for(i=0;i<dev;i++) MakeSearchThread(i); while (num != 0) my_sleep(5); for(i=dev;i<dev2;i++) MakeSearchThread(i); while (num != 0) my_sleep(5); } #endif /*Support for threads */ // #if 0 static void NokiaGetADC(int argc, char *argv[]) { GSM_Init(true); #ifdef GSM_ENABLE_NOKIA_DCT3 DCT3GetADC(argc,argv); #endif #ifdef GSM_ENABLE_NOKIA_DCT4 DCT4GetADC(argc, argv); #endif GSM_Terminate(); } static void NokiaDisplayTest(int argc, char *argv[]) { GSM_Init(true); #ifdef GSM_ENABLE_NOKIA_DCT3 DCT3DisplayTest(argc,argv); #endif #ifdef GSM_ENABLE_NOKIA_DCT4 DCT4DisplayTest(argc, argv); #endif GSM_Terminate(); } static void NokiaGetT9(int argc, char *argv[]) { GSM_Init(true); #ifdef GSM_ENABLE_NOKIA_DCT3 DCT3GetT9(argc,argv); #endif #ifdef GSM_ENABLE_NOKIA_DCT4 DCT4GetT9(argc, argv); #endif GSM_Terminate(); } static void NokiaVibraTest(int argc, char *argv[]) { GSM_Init(true); #ifdef GSM_ENABLE_NOKIA_DCT3 DCT3VibraTest(argc,argv); #endif #ifdef GSM_ENABLE_NOKIA_DCT4 DCT4VibraTest(argc, argv); #endif GSM_Terminate(); } static GSM_Parameters Parameters[] = { {"--identify", 0, 0, Identify, {H_Info,0}, ""}, {"--version", 0, 0, Version, {H_Other,0}, ""}, {"--getdisplaystatus", 0, 0, GetDisplayStatus, {H_Info,0}, ""}, {"--monitor", 0, 1, Monitor, {H_Info,H_Network,H_Call,0}, "[times]"}, {"--setautonetworklogin", 0, 0, SetAutoNetworkLogin, {H_Network,0}, ""}, {"--listnetworks", 0, 0, ListNetworks, {H_Network,0}, ""}, {"--getgprspoint", 1, 2, GetGPRSPoint, {H_Nokia,H_Network,0}, "start [stop]"}, {"--addfolder", 2, 2, AddFolder, {H_Filesystem,0}, "parentfolderID name"}, {"--getfilesystem", 0, 1, GetFileSystem, {H_Filesystem,0}, "[-flatall|-flat]"}, {"--getfilesystemstatus", 0, 0, GetFileSystemStatus, {H_Filesystem,0}, ""}, {"--getfiles", 1,40, GetFiles, {H_Filesystem,0}, "ID1, ID2, ..."}, {"--getfilefolder", 1,40, GetFileFolder, {H_Filesystem,0}, "ID1, ID2, ..."}, {"--addfile", 2, 6, AddFile, {H_Filesystem,0}, "folderID name [-type JAR|BMP|PNG|GIF|JPG|MIDI|WBMP|AMR|3GP|NRT][-readonly][-protected][-system][-hidden][-newtime]"}, {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0}, "MMSUnreadInbox|MMSReadInbox|MMSOutbox|MMSDrafts|MMSSent file sender title"}, {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0}, "Application|Game file [-readonly]"}, {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0}, "Gallery|Tones file [-name name][-protected][-readonly][-system][-hidden][-newtime]"}, {"--deletefiles", 1,20, DeleteFiles, {H_Filesystem,0}, "fileID"}, {"--playringtone", 1, 1, PlayRingtone, {H_Ringtone,0}, "file"}, {"--playsavedringtone", 1, 1, DCT4PlaySavedRingtone, {H_Ringtone,0}, ""}, {"--getdatetime", 0, 0, GetDateTime, {H_DateTime,0}, ""}, {"--setdatetime", 0, 0, SetDateTime, {H_DateTime,0}, ""}, {"--getalarm", 0, 0, GetAlarm, {H_DateTime,0}, ""}, {"--setalarm", 2, 2, SetAlarm, {H_DateTime,0}, "hour minute"}, {"--resetphonesettings", 1, 1, ResetPhoneSettings, {H_Settings,0}, "PHONE|DEV|UIF|ALL|FACTORY"}, {"--getmemory", 2, 3, GetMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD start [stop]"}, {"--getallmemory", 1, 1, GetAllMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD"}, {"--searchmemory", 1, 1, SearchMemory, {H_Memory,0}, "text"}, {"--listmemorycategory", 1, 1, ListMemoryCategory, {H_Memory, H_Category,0}, "text|number"}, {"--getfmstation", 1, 2, GetFMStation, {H_FM,0}, "start [stop]"}, {"--getsmsc", 1, 2, GetSMSC, {H_SMS,0}, "start [stop]"}, {"--getsms", 2, 3, GetSMS, {H_SMS,0}, "folder start [stop]"}, {"--deletesms", 2, 3, DeleteSMS, {H_SMS,0}, "folder start [stop]"}, {"--deleteallsms", 1, 1, DeleteAllSMS, {H_SMS,0}, "folder"}, {"--getsmsfolders", 0, 0, GetSMSFolders, {H_SMS,0}, ""}, {"--getallsms", 0, 0, GetAllSMS, {H_SMS,0}, ""}, {"--geteachsms", 0, 0, GetEachSMS, {H_SMS,0}, ""}, #define SMS_TEXT_OPTIONS "[-inputunicode][-16bit][-flash][-len len][-autolen len][-unicode][-enablevoice][-disablevoice][-enablefax][-disablefax][-enableemail][-disableemail][-voidsms][-replacemessages ID][-replacefile file]" #define SMS_PICTURE_OPTIONS "[-text text][-unicode][-alcatelbmmi]" #define SMS_PROFILE_OPTIONS "[-name name][-bitmap bitmap][-ringtone ringtone]" #define SMS_EMS_OPTIONS "[-unicode][-16bit][-format lcrasbiut][-text text][-unicodefiletext file][-defsound ID][-defanimation ID][-tone10 file][-tone10long file][-tone12 file][-tone12long file][-toneSE file][-toneSElong file][-fixedbitmap file][-variablebitmap file][-variablebitmaplong file][-animation frames file1 ...][-protected number]" #define SMS_SMSTEMPLATE_OPTIONS "[-unicode][-text text][-unicodefiletext file][-defsound ID][-defanimation ID][-tone10 file][-tone10long file][-tone12 file][-tone12long file][-toneSE file][-toneSElong file][-variablebitmap file][-variablebitmaplong file][-animation frames file1 ...]" #define SMS_ANIMATION_OPTIONS "" #define SMS_OPERATOR_OPTIONS "[-netcode netcode][-biglogo]" #define SMS_SAVE_OPTIONS "[-folder id][-unread][-read][-unsent][-sent][-sender number]" #define SMS_SEND_OPTIONS "[-report][-validity HOUR|6HOURS|DAY|3DAYS|WEEK|MAX][-save [-folder number]]" #define SMS_COMMON_OPTIONS "[-smscset number][-smscnumber number][-reply][-maxsms num]" {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS}, {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS}, {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS}, {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION frames file1 file2... " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS}, {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR URL Title Sender " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, #ifdef GSM_ENABLE_BACKUP {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS file location DATA|GPRS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 file SM|ME location [-nokia]" SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, #endif {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PROFILE_OPTIONS}, {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS}, {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS}, {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS}, {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS}, {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS}, {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION destination frames file1 file2... " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS}, {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR destination URL Title Sender " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, #ifdef GSM_ENABLE_BACKUP {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS destination file location DATA|GPRS " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 destination file SM|ME location [-nokia]" SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, #endif {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS ""SMS_PROFILE_OPTIONS}, {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS}, {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS}, {"--displaysms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "... (options like in sendsms)"}, {"--addsmsfolder", 1, 1, AddSMSFolder, {H_SMS,0}, "name"}, #ifdef HAVE_MYSQL_MYSQL_H {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "MYSQL configfile"}, #endif {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "FILES configfile"}, {"--sendsmsdsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Other,0}, "TEXT|WAPSETTINGS|... destination FILES|MYSQL configfile ... (options like in sendsms)"}, {"--getringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"}, {"--getphoneringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"}, {"--getringtoneslist", 0, 0, GetRingtonesList, {H_Ringtone,0}, ""}, {"--setringtone", 1, 6, SetRingtone, {H_Ringtone,0}, "file [-location location][-scale][-name name]"}, {"--nokiacomposer", 1, 1, NokiaComposer, {H_Ringtone,H_Nokia,0}, "file"}, {"--copyringtone", 2, 3, CopyRingtone, {H_Ringtone,0}, "source destination [RTTL|BINARY]"}, {"--getussd", 1, 1, GetUSSD, {H_Call,0}, "code"}, {"--dialvoice", 1, 2, DialVoice, {H_Call,0}, "number [show|hide]"}, {"--getspeeddial", 1, 2, GetSpeedDial, {H_Call,H_Memory,0}, "start [stop]"}, {"--cancelcall", 0, 1, CancelCall, {H_Call,0}, "[ID]"}, {"--answercall", 0, 1, AnswerCall, {H_Call,0}, "[ID]"}, {"--unholdcall", 1, 1, UnholdCall, {H_Call,0}, "ID"}, {"--holdcall", 1, 1, HoldCall, {H_Call,0}, "ID"}, {"--conferencecall", 1, 1, ConferenceCall, {H_Call,0}, "ID"}, {"--splitcall", 1, 1, SplitCall, {H_Call,0}, "ID"}, {"--switchcall", 0, 1, SwitchCall, {H_Call,0}, "[ID]"}, {"--transfercall", 0, 1, TransferCall, {H_Call,0}, "[ID]"}, {"--divert", 3, 5, CallDivert, {H_Call,0}, "get|set all|busy|noans|outofreach all|voice|fax|data [number timeout]"}, {"--canceldiverts", 0, 0, CancelAllDiverts, {H_Call,0}, ""}, {"--senddtmf", 1, 1, SendDTMF, {H_Call,0}, "sequence"}, {"--getcalendarsettings", 0, 0, GetCalendarSettings, {H_Calendar,H_Settings,0}, ""}, {"--getalltodo", 0, 0, GetAllToDo, {H_ToDo,0}, ""}, {"--listtodocategory", 1, 1, ListToDoCategory, {H_ToDo, H_Category,0}, "text|number"}, {"--gettodo", 1, 2, GetToDo, {H_ToDo,0}, "start [stop]"}, {"--deletetodo", 1, 2, DeleteToDo, {H_ToDo,0}, "start [stop]"}, {"--getnote", 1, 2, GetNote, {H_Note,0}, "start [stop]"}, {"--deletecalendar", 1, 2, DeleteCalendar, {H_Calendar,0}, "start [stop]"}, {"--getallcalendar", 0, 0, GetAllCalendar, {H_Calendar,0}, ""}, {"--getcalendar", 1, 2, GetCalendar, {H_Calendar,0}, "start [stop]"}, {"--getcategory", 2, 3, GetCategory, {H_Category,H_ToDo,H_Memory,0}, "TODO|PHONEBOOK start [stop]"}, {"--getallcategory", 1, 1, GetAllCategories, {H_Category,H_ToDo,H_Memory,0}, "TODO|PHONEBOOK"}, {"--reset", 1, 1, Reset, {H_Other,0}, "SOFT|HARD"}, {"--getprofile", 1, 2, GetProfile, {H_Settings,0}, "start [stop]"}, {"--getsecuritystatus", 0, 0, GetSecurityStatus, {H_Info,0}, ""}, {"--entersecuritycode", 2, 2, EnterSecurityCode, {H_Other,0}, "PIN|PUK|PIN2|PUK2 code"}, {"--deletewapbookmark", 1, 2, DeleteWAPBookmark, {H_WAP,0}, "start [stop]"}, {"--getwapbookmark", 1, 2, GetWAPBookmark, {H_WAP,0}, "start [stop]"}, {"--getwapsettings", 1, 2, GetWAPMMSSettings, {H_WAP,0}, "start [stop]"}, {"--getmmssettings", 1, 2, GetWAPMMSSettings, {H_MMS,0}, "start [stop]"}, {"--getsyncmlsettings", 1, 2, GetSyncMLSettings, {H_WAP,0}, "start [stop]"}, {"--getchatsettings", 1, 2, GetChatSettings, {H_WAP,0}, "start [stop]"}, {"--savemmsfile", 3, 15,SaveMMSFile, {H_MMS,0}, "file [-subject text][-text text]"}, {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "STARTUP [file]"}, {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "CALLER location [file]"}, {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "OPERATOR [file]"}, {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "PICTURE location [file]"}, {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "TEXT"}, {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "DEALER"}, {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "STARTUP file|1|2|3"}, {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOURSTARTUP [fileID]"}, {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "WALLPAPER fileID"}, {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "CALLER location [file]"}, {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "OPERATOR [file [netcode]]"}, {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOUROPERATOR [fileID [netcode]]"}, {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "PICTURE file location [text]"}, {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "TEXT text"}, {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "DEALER text"}, {"--copybitmap", 1, 3, CopyBitmap, {H_Logo,0}, "inputfile [outputfile [OPERATOR|PICTURE|STARTUP|CALLER]]"}, {"--presskeysequence", 1, 1, PressKeySequence, {H_Other,0}, "mMnNpPuUdD+-123456789*0#gGrRwW"}, #if defined(WIN32) || defined(HAVE_PTHREAD) {"--searchphone", 0, 1, SearchPhone, {H_Other,0}, "[-debug]"}, #endif #ifdef GSM_ENABLE_BACKUP {"--savefile", 4, 5, SaveFile, {H_Backup,H_Calendar,0}, "CALENDAR target.vcs file location"}, {"--savefile", 4, 5, SaveFile, {H_Backup,H_ToDo,0}, "TODO target.vcs file location"}, {"--savefile", 4, 5, SaveFile, {H_Backup,H_Memory,0}, "VCARD10|VCARD21 target.vcf file SM|ME location"}, {"--savefile", 4, 5, SaveFile, {H_Backup,H_WAP,0}, "BOOKMARK target.url file location"}, {"--backup", 1, 2, Backup, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file [-yes]"}, {"--backupsms", 1, 1, BackupSMS, {H_Backup,H_SMS,0}, "file"}, {"--restore", 1, 1, Restore, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"}, {"--addnew", 1, 1, AddNew, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"}, {"--restoresms", 1, 1, RestoreSMS, {H_Backup,H_SMS,0}, "file"}, {"--addsms", 2, 2, AddSMS, {H_Backup,H_SMS,0}, "folder file"}, #endif {"--clearall", 0, 0, ClearAll, {H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, ""}, {"--networkinfo", 0, 0, NetworkInfo, {H_Network,0}, ""}, #ifdef GSM_ENABLE_AT {"--siemenssatnetmon", 0, 0, ATSIEMENSSATNetmon, {H_Siemens,H_Network,0}, ""}, {"--siemensnetmonact", 1, 1, ATSIEMENSActivateNetmon, {H_Siemens,H_Network,0}, "netmon_type (1-full, 2-simple)"}, {"--siemensnetmonitor", 1, 1, ATSIEMENSNetmonitor, {H_Siemens,H_Network,0}, "test"}, #endif #ifdef GSM_ENABLE_NOKIA6110 {"--nokiagetoperatorname", 0, 0, DCT3GetOperatorName, {H_Nokia,H_Network,0}, ""}, {"--nokiasetoperatorname", 0, 2, DCT3SetOperatorName, {H_Nokia,H_Network,0}, "[networkcode name]"}, {"--nokiadisplayoutput", 0, 0, DCT3DisplayOutput, {H_Nokia,0}, ""}, #endif #ifdef GSM_ENABLE_NOKIA_DCT3 {"--nokianetmonitor", 1, 1, DCT3netmonitor, {H_Nokia,H_Network,0}, "test"}, {"--nokianetmonitor36", 0, 0, DCT3ResetTest36, {H_Nokia,0}, ""}, {"--nokiadebug", 1, 2, DCT3SetDebug, {H_Nokia,H_Network,0}, "filename [[v11-22][,v33-44]...]"}, #endif #ifdef GSM_ENABLE_NOKIA_DCT4 {"--nokiasetvibralevel", 1, 1, DCT4SetVibraLevel, {H_Nokia,H_Other,0}, "level"}, {"--nokiagetvoicerecord", 1, 1, DCT4GetVoiceRecord, {H_Nokia,H_Other,0}, "location"}, {"--nokiasetlights", 2, 2, DCT4SetLight, {H_Nokia,H_Tests,0}, "keypad|display|torch on|off"}, {"--nokiatuneradio", 0, 0, DCT4TuneRadio, {H_Nokia,H_FM,0}, ""}, {"--nokiamakecamerashoot", 0, 0, DCT4MakeCameraShoot, {H_Nokia,H_Other,0}, ""}, {"--nokiagetscreendump", 0, 0, DCT4GetScreenDump, {H_Nokia,H_Other,0}, ""}, #endif #if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) {"--nokiavibratest", 0, 0, NokiaVibraTest, {H_Nokia,H_Tests,0}, ""}, {"--nokiagett9", 0, 0, NokiaGetT9, {H_Nokia,H_SMS,0}, ""}, {"--nokiadisplaytest", 1, 1, NokiaDisplayTest, {H_Nokia,H_Tests,0}, "number"}, {"--nokiagetadc", 0, 0, NokiaGetADC, {H_Nokia,H_Tests,0}, ""}, {"--nokiasecuritycode", 0, 0, NokiaSecurityCode, {H_Nokia,H_Info,0}, ""}, {"--nokiaselftests", 0, 0, NokiaSelfTests, {H_Nokia,H_Tests,0}, ""}, {"--nokiasetphonemenus", 0, 0, NokiaSetPhoneMenus, {H_Nokia,H_Other,0}, ""}, #endif #ifdef DEBUG {"--decodesniff", 2, 3, decodesniff, {H_Decode,0}, "MBUS2|IRDA file [phonemodel]"}, {"--decodebinarydump", 1, 2, decodebinarydump, {H_Decode,0}, "file [phonemodel]"}, {"--makeconverttable", 1, 1, MakeConvertTable, {H_Decode,0}, "file"}, #endif {"", 0, 0, NULL } }; static HelpCategoryDescriptions HelpDescriptions[] = { {H_Call, "call", "Calls",}, {H_SMS, "sms", "SMS and EMS"}, {H_Memory, "memory", "Memory (phonebooks and calls)"}, {H_Filesystem, "filesystem", "Filesystem"}, {H_Logo, "logo", "Logo and pictures"}, {H_Ringtone, "ringtone", "Ringtones"}, {H_Calendar, "calendar", "Calendar notes"}, {H_ToDo, "todo", "To do lists"}, {H_Note, "note", "Notes"}, {H_DateTime, "datetime", "Date, time and alarms"}, {H_Category, "category", "Categories"}, #ifdef GSM_ENABLE_BACKUP {H_Backup, "backup", "Backing up and restoring"}, #endif #if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) {H_Nokia, "nokia", "Nokia specific"}, #endif #ifdef GSM_ENABLE_AT {H_Siemens, "siemens", "Siemens specific"}, #endif {H_Network, "network", "Network"}, {H_WAP, "wap", "WAP settings and bookmarks"}, {H_MMS, "mms", "MMS and MMS settings"}, {H_Tests, "tests", "Phone tests"}, {H_FM, "fm", "FM radio"}, {H_Info, "info", "Phone information"}, {H_Settings, "settings", "Phone settings"}, #ifdef DEBUG {H_Decode, "decode", "Dumps decoding"}, #endif {H_Other, "other", "Functions that don't fit elsewhere"}, {0, NULL, NULL} }; void HelpHeader(void) { printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__); } static void HelpGeneral(void) { int i=0; HelpHeader(); printmsg("Usage: gammu [confign] [nothing|text|textall|binary|errors] [options]\n\n"); printmsg("First parameter optionally specifies which config section to use (by default are probed all).\n"); printmsg("Second parameter optionally controls debug level, next specify actions.\n\n"); /* We might want to put here some most used commands */ printmsg("For more details call help on specific topic (gammu --help topic), topics are:\n\n"); while (HelpDescriptions[i].category != 0) { printf("%11s - %s\n", HelpDescriptions[i].option, HelpDescriptions[i].description); i++; } printf("\n"); } static void HelpSplit(int cols, int len, unsigned char *buff) { int l, len2, pos, split; bool in_opt,first=true; char *remain, spaces[50], buffer[500]; if (cols == 0) { printf(" %s\n", buff); } else { printf(" "); spaces[0] = 0; len2 = strlen(buff); if (len + len2 < cols) { printf("%s\n", buff); } else { for(l = 0; l < len; l++) strcat(spaces, " "); remain = buff; while (strlen(remain) > 0) { split = 0; pos = 0; in_opt = false; if (!first) printf(spaces); while (pos < cols - len && remain[pos] != 0) { if (in_opt && remain[pos] == ']') { in_opt = false; split = pos; } else if (remain[pos] == '[') { in_opt = true; } else if (!in_opt && remain[pos] == ' ') { split = pos - 1; } pos++; } /* Can not be split */ if (split == 0) { printf("%s\n", remain); remain += strlen(remain); } else { first = false; split++; strncpy(buffer, remain, split); buffer[split] = 0; printf("%s\n", buffer); remain += split; if (remain[0] == ' ') remain++; } } } } } static void Help(int argc, char *argv[]) { int i = 0, j = 0, k, cols; bool disp; #ifdef TIOCGWINSZ struct winsize w; #endif #if defined(WIN32) || defined(DJGPP) #else char *columns; #endif /* Just --help */ if (argc == 2) { HelpGeneral(); return; } if (!strcmp(argv[2],"all")) { HelpHeader(); } else { while (HelpDescriptions[i].category != 0) { if (strcmp(argv[2], HelpDescriptions[i].option) == 0) break; i++; } if (HelpDescriptions[i].category == 0) { HelpGeneral(); printmsg("Unknown help topic specified!\n"); return; } HelpHeader(); printmsg("Gammu parameters, topic: %s\n\n", HelpDescriptions[i].description); } #if defined(WIN32) || defined(DJGPP) cols = 80; #else cols = 0; /* If stdout is a tty, we will wrap to columns it has */ if (isatty(1)) { #ifdef TIOCGWINSZ if (ioctl(2, TIOCGWINSZ, &w) == 0) { if (w.ws_col > 0) cols = w.ws_col; } #endif if (cols == 0) { columns = getenv("COLUMNS"); if (columns != NULL) { cols = atoi(columns); if (cols <= 0) cols = 0; } } if (cols == 0) { /* Fallback */ cols = 80; } } #endif while (Parameters[j].Function != NULL) { k = 0; disp = false; if (!strcmp(argv[2],"all")) { if (j==0) disp = true; if (j!=0) { if (strcmp(Parameters[j].help,Parameters[j-1].help)) { disp = true; } else { if (strcmp(Parameters[j].parameter,Parameters[j-1].parameter)) { disp = true; } } } } else { while (Parameters[j].help_cat[k] != 0) { if (Parameters[j].help_cat[k] == HelpDescriptions[i].category) { disp = true; break; } k++; } } if (disp) { printf("%s", Parameters[j].parameter); if (Parameters[j].help[0] == 0) { printf("\n"); } else { HelpSplit(cols - 1, strlen(Parameters[j].parameter) + 1, Parameters[j].help); } } j++; } } #if 0 #endif // 0 int main(int argc, char *argv[]) { //fprintf(stderr,"HIIIIIIIIIIIII \n"); //#if 0 static int z ,start,i; static int only_config ; #if !defined(WIN32) && defined(LOCALE_PATH) static char *locale, locale_file[201]; #endif static char *cp; static bool count_failed; z = 0; start=0;only_config = -1;count_failed = false; s.opened = false; s.msg = NULL; s.ConfigNum = 0; setlocale(LC_ALL, ""); #ifdef DEBUG di.dl = DL_TEXTALL; di.df = stdout; #endif //#if 0 /* Any parameters? */ if (argc == 1) { HelpGeneral(); printmsg("Too few parameters!\n"); exit(1); } /* Help? */ if (strncmp(argv[1 + start], "--help", 6) == 0) { Help(argc - start, argv + start); exit(1); } /* Is first parameter numeric? If so treat it as config that should be loaded. */ if (isdigit(argv[1][0])) { only_config = atoi(argv[1]); if (only_config >= 0) start++; else only_config = -1; } + GSM_ReadConfig(NULL, &s.Config[0], 0); + s.ConfigNum = 1; + GSM_Config *con = &s.Config[0]; + + char* tempC; + tempC = argv[argc-1]+2; + if ( *tempC != 0 ) { + fprintf(stderr,"Using model %s \n",tempC); + strcpy(con->Model,tempC ); + } + tempC = argv[argc-2]+2; + if ( *tempC != 0 ) { + fprintf(stderr,"Using device %s \n",tempC); + con->Device = strdup(tempC); + con->DefaultDevice = false; + } + tempC = argv[argc-3]+2; + if ( *tempC != 0 ) { + fprintf(stderr,"Using connection %s \n",tempC); + con->Connection = strdup(tempC); + con->DefaultConnection = false; + } + argc = argc-3; +#if 0 + if ( ! mConnection.isEmpty() ) { + cfg->Connection = strdup(mConnection.latin1()); + cfg->DefaultConnection = false; + qDebug("Connection set %s ", cfg->Connection ); + + } + if ( ! mDevice.isEmpty() ) { + cfg->Device = strdup(mDevice.latin1()); + cfg->DefaultDevice = false; + qDebug("Device set %s ", cfg->Device); + + } + if ( ! mModel.isEmpty() ) { + strcpy(cfg->Model,mModel.latin1() ); + cfg->DefaultModel = false; + qDebug("Model set %s ",cfg->Model ); + } + +#endif + +#if 0 cfg=GSM_FindGammuRC(); for (i = 0; i <= MAX_CONFIG_NUM; i++) { if (cfg!=NULL) { cp = INI_GetValue(cfg, "gammu", "gammucoding", false); if (cp) di.coding = cp; s.Config[i].Localize = INI_GetValue(cfg, "gammu", "gammuloc", false); if (s.Config[i].Localize) { s.msg=INI_ReadFile(s.Config[i].Localize, true); } else { #if !defined(WIN32) && defined(LOCALE_PATH) locale = setlocale(LC_MESSAGES, NULL); if (locale != NULL) { snprintf(locale_file, 200, "%s/gammu_%c%c.txt", LOCALE_PATH, tolower(locale[0]), tolower(locale[1])); s.msg = INI_ReadFile(locale_file, true); } #endif } } /* Wanted user specific configuration? */ if (only_config != -1) { /* Here we get only in first for loop */ if (!GSM_ReadConfig(cfg, &s.Config[0], only_config)) break; } else { if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; } s.ConfigNum++; /* We want to use only one file descriptor for global and state machine debug output */ s.Config[i].UseGlobalDebugFile = true; /* It makes no sense to open several debug logs... */ if (i != 0) { strcpy(s.Config[i].DebugLevel, s.Config[0].DebugLevel); free(s.Config[i].DebugFile); s.Config[i].DebugFile = strdup(s.Config[0].DebugFile); } else { /* Just for first config */ /* When user gave debug level on command line */ if (argc > 1 + start && GSM_SetDebugLevel(argv[1 + start], &di)) { /* Debug level from command line will be used with phone too */ strcpy(s.Config[i].DebugLevel,argv[1 + start]); start++; } else { /* Try to set debug level from config file */ GSM_SetDebugLevel(s.Config[i].DebugLevel, &di); } /* If user gave debug file in gammurc, we will use it */ error=GSM_SetDebugFile(s.Config[i].DebugFile, &di); Print_Error(error); } /* We wanted to read just user specified configuration. */ if (only_config != -1) {break;} } - +#endif /* Do we have enough parameters? */ if (argc == 1 + start) { HelpGeneral(); printmsg("Too few parameters!\n"); exit(-2); } /* Check used version vs. compiled */ if (!mystrncasecmp(GetGammuVersion(),VERSION,0)) { printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n", GetGammuVersion(),VERSION); exit(-1); } /* Check parameters */ while (Parameters[z].Function != NULL) { if (mystrncasecmp(Parameters[z].parameter,argv[1+start], 0)) { if (argc-2-start >= Parameters[z].min_arg && argc-2-start <= Parameters[z].max_arg) { Parameters[z].Function(argc - start, argv + start); break; } else { count_failed = true; } } z++; } /* Tell user when we did nothing */ if (Parameters[z].Function == NULL) { HelpGeneral(); if (count_failed) { printmsg("Bad parameter count!\n"); } else { printmsg("Bad option!\n"); } } /* Close debug output if opened */ if (di.df!=stdout) fclose(di.df); //#endif // 0 fprintf(stderr,"kammu: Success. End. \n"); exit(0); } /* How should editor hadle tabs in this file? Add editor commands here. * vim: noexpandtab sw=8 ts=8 sts=8: */ diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 0bc9125..2ad1b5a 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp @@ -1,581 +1,583 @@ /* This file is part of libkcal. Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qdatetime.h> #include <qstring.h> #include <qapplication.h> #include <qptrlist.h> #include <qregexp.h> #include <qmessagebox.h> #include <qclipboard.h> #include <qfile.h> #include <qtextstream.h> #include <qtextcodec.h> #include <qxml.h> #include <qlabel.h> #include <kdebug.h> #include <klocale.h> #include <kglobal.h> #include "calendar.h" #include "alarm.h" #include "recurrence.h" #include "calendarlocal.h" #include "phoneformat.h" #include "syncdefines.h" using namespace KCal; class PhoneParser : public QObject { public: PhoneParser( ) { ; } static QString dtToString( const QDateTime& dti, bool useTZ = false ) { QString datestr; QString timestr; int offset = KGlobal::locale()->localTimeOffset( dti ); QDateTime dt; if (useTZ) dt = dti.addSecs ( -(offset*60)); else dt = dti; if(dt.date().isValid()){ const QDate& date = dt.date(); datestr.sprintf("%04d%02d%02d", date.year(), date.month(), date.day()); } if(dt.time().isValid()){ const QTime& time = dt.time(); timestr.sprintf("T%02d%02d%02d", time.hour(), time.minute(), time.second()); } return datestr + timestr; } }; PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) { mProfileName = profileName; mDevice = device; mConnection = connection; mModel = model; } PhoneFormat::~PhoneFormat() { } #if 0 int PhoneFormat::initDevice(GSM_StateMachine *s) { GSM_ReadConfig(NULL, &s->Config[0], 0); s->ConfigNum = 1; GSM_Config *cfg = &s->Config[0]; if ( ! mConnection.isEmpty() ) { cfg->Connection = strdup(mConnection.latin1()); cfg->DefaultConnection = false; qDebug("Connection set %s ", cfg->Connection ); } if ( ! mDevice.isEmpty() ) { cfg->Device = strdup(mDevice.latin1()); cfg->DefaultDevice = false; qDebug("Device set %s ", cfg->Device); } if ( ! mModel.isEmpty() ) { strcpy(cfg->Model,mModel.latin1() ); cfg->DefaultModel = false; qDebug("Model set %s ",cfg->Model ); } int error=GSM_InitConnection(s,3); return error; } #endif ulong PhoneFormat::getCsumTodo( Todo* todo ) { QStringList attList; if ( todo->hasDueDate() ) attList << PhoneParser::dtToString ( todo->dtDue() ); attList << todo->summary(); QString completedString = "no"; if ( todo->isCompleted() ) completedString = "yes"; attList << completedString; attList << QString::number( todo->priority() ); QString alarmString = "na"; Alarm *alarm; if ( todo->alarms().count() > 0 ) { alarm = todo->alarms().first(); if ( alarm->enabled() ) { alarmString = QString::number(alarm->startOffset().asSeconds() ); } } attList << alarmString; attList << todo->categoriesStr(); attList << todo->secrecyStr(); return PhoneFormat::getCsum(attList ); } ulong PhoneFormat::getCsumEvent( Event* event ) { QStringList attList; attList << PhoneParser::dtToString ( event->dtStart() ); attList << PhoneParser::dtToString ( event->dtEnd() ); attList << event->summary(); attList << event->location(); QString alarmString = "na"; Alarm *alarm; if ( event->alarms().count() > 0 ) { alarm = event->alarms().first(); if ( alarm->enabled() ) { alarmString = QString::number( alarm->startOffset().asSeconds() ); } } attList << alarmString; Recurrence* rec = event->recurrence(); QStringList list; bool writeEndDate = false; switch ( rec->doesRecur() ) { case Recurrence::rDaily: // 0 list.append( "0" ); list.append( QString::number( rec->frequency() ));//12 list.append( "0" ); list.append( "0" ); writeEndDate = true; break; case Recurrence::rWeekly:// 1 list.append( "1" ); list.append( QString::number( rec->frequency()) );//12 list.append( "0" ); { int days = 0; QBitArray weekDays = rec->days(); int i; for( i = 1; i <= 7; ++i ) { if ( weekDays[i-1] ) { days += 1 << (i-1); } } list.append( QString::number( days ) ); } //pending weekdays writeEndDate = true; break; case Recurrence::rMonthlyPos:// 2 list.append( "2" ); list.append( QString::number( rec->frequency()) );//12 writeEndDate = true; { int count = 1; QPtrList<Recurrence::rMonthPos> rmp; rmp = rec->monthPositions(); if ( rmp.first()->negative ) count = 5 - rmp.first()->rPos - 1; else count = rmp.first()->rPos - 1; list.append( QString::number( count ) ); } list.append( "0" ); break; case Recurrence::rMonthlyDay:// 3 list.append( "3" ); list.append( QString::number( rec->frequency()) );//12 list.append( "0" ); list.append( "0" ); writeEndDate = true; break; case Recurrence::rYearlyMonth://4 list.append( "4" ); list.append( QString::number( rec->frequency()) );//12 list.append( "0" ); list.append( "0" ); writeEndDate = true; break; default: list.append( "255" ); list.append( QString() ); list.append( "0" ); list.append( QString() ); list.append( "0" ); list.append( "20991231T000000" ); break; } if ( writeEndDate ) { if ( rec->endDate().isValid() ) { // 15 + 16 list.append( "1" ); list.append( PhoneParser::dtToString( rec->endDate()) ); } else { list.append( "0" ); list.append( "20991231T000000" ); } } attList << list.join(""); attList << event->categoriesStr(); attList << event->secrecyStr(); return PhoneFormat::getCsum(attList ); } ulong PhoneFormat::getCsum( const QStringList & attList) { int max = attList.count() -1; ulong cSum = 0; int j,k,i; int add; for ( i = 1; i < max ; ++i ) { QString s = attList[i]; if ( ! s.isEmpty() ){ j = s.length(); for ( k = 0; k < j; ++k ) { int mul = k +1; add = s[k].unicode (); if ( k < 16 ) mul = mul * mul; add = add * mul *i*i*i; cSum += add; } } } return cSum; } //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); #include <stdlib.h> #define DEBUGMODE false bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) { QString fileName; #ifdef _WIN32_ fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; #else fileName = "/tmp/kdepimtemp.vcs"; #endif - QString command ="./kammu --backup " + fileName + " -yes"; + QString command ="./kammu --backup " + fileName + " -yes -C" + + mConnection +" -D" + mDevice +" -M" + mModel; int ret = system ( command.latin1() ); if ( ret != 0 ) return false; VCalFormat vfload; vfload.setLocalTime ( true ); if ( ! vfload.load( calendar, fileName ) ) return false; QPtrList<Event> er = calendar->rawEvents(); Event* ev = er.first(); while ( ev ) { int id = ev->pilotId(); Event *event; event = existingCal->event( mProfileName ,QString::number( id ) ); if ( event ) { event = (Event*)event->clone(); copyEvent( event, ev ); calendar->deleteEvent( ev ); calendar->addEvent( event); } else event = ev; uint cSum; cSum = PhoneFormat::getCsumEvent( event ); event->setCsum( mProfileName, QString::number( cSum )); event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); event->setID( mProfileName,QString::number( id ) ); ev = er.next(); } { QPtrList<Todo> tr = calendar->rawTodos(); Todo* ev = tr.first(); while ( ev ) { QStringList cat = ev->categories(); if ( cat.contains( "MeetingDEF" )) { ev->setCategories( QStringList() ); } int id = ev->pilotId(); Todo *event; event = existingCal->todo( mProfileName ,QString::number( id ) ); if ( event ) { event = (Todo*)event->clone(); copyTodo( event, ev ); calendar->deleteTodo( ev ); calendar->addTodo( event); } else event = ev; uint cSum; cSum = PhoneFormat::getCsumTodo( event ); event->setCsum( mProfileName, QString::number( cSum )); event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); event->setID( mProfileName,QString::number( id ) ); ev = tr.next(); } } return true; } void PhoneFormat::copyEvent( Event* to, Event* from ) { if ( from->dtStart().isValid() ) to->setDtStart( from->dtStart() ); if ( from->dtEnd().isValid() ) to->setDtEnd( from->dtEnd() ); if ( !from->location().isEmpty() ) to->setLocation( from->location() ); if ( !from->description().isEmpty() ) to->setDescription( from->description() ); if ( !from->summary().isEmpty() ) to->setSummary( from->summary() ); QPtrListIterator<Alarm> it( from->alarms() ); to->clearAlarms(); const Alarm *a; while( (a = it.current()) ) { Alarm *b = new Alarm( *a ); b->setParent( to ); to->addAlarm( b ); ++it; } QStringList cat = to->categories(); QStringList catFrom = from->categories(); QString nCat; int iii; for ( iii = 0; iii < catFrom.count();++iii ) { nCat = catFrom[iii]; if ( !nCat.isEmpty() ) if ( !cat.contains( nCat )) { cat << nCat; } } to->setCategories( cat ); Recurrence * r = new Recurrence( *from->recurrence(),to); to->setRecurrence( r ) ; } void PhoneFormat::copyTodo( Todo* to, Todo* from ) { if ( from->dtStart().isValid() ) to->setDtStart( from->dtStart() ); if ( from->dtDue().isValid() ) to->setDtDue( from->dtDue() ); if ( !from->location().isEmpty() ) to->setLocation( from->location() ); if ( !from->description().isEmpty() ) to->setDescription( from->description() ); if ( !from->summary().isEmpty() ) to->setSummary( from->summary() ); QPtrListIterator<Alarm> it( from->alarms() ); to->clearAlarms(); const Alarm *a; while( (a = it.current()) ) { Alarm *b = new Alarm( *a ); b->setParent( to ); to->addAlarm( b ); ++it; } QStringList cat = to->categories(); QStringList catFrom = from->categories(); QString nCat; int iii; for ( iii = 0; iii < catFrom.count();++iii ) { nCat = catFrom[iii]; if ( !nCat.isEmpty() ) if ( !cat.contains( nCat )) { cat << nCat; } } to->setCategories( cat ); if ( from->isCompleted() ) { to->setCompleted( true ); if( from->completed().isValid() ) to->setCompleted( from->completed() ); } else { // set percentcomplete only, if to->isCompleted() if ( to->isCompleted() ) to->setPercentComplete(from->percentComplete()); } to->setPriority(from->priority()); } #include <qcstring.h> void PhoneFormat::afterSave( Incidence* inc) { uint csum; inc->removeID( mProfileName ); if ( inc->type() == "Event") csum = PhoneFormat::getCsumEvent( (Event*) inc ); else csum = PhoneFormat::getCsumTodo( (Todo*) inc ); inc->setCsum( mProfileName, QString::number( csum )); inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); } bool PhoneFormat::save( Calendar *calendar) { QLabel status ( i18n(" Opening device ..."), 0 ); int w = status.sizeHint().width()+20 ; if ( w < 200 ) w = 230; int h = status.sizeHint().height()+20 ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); status.setCaption(i18n("Writing to phone...") ); status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); status.show(); status.raise(); qApp->processEvents(); QString message; #ifdef _WIN32_ QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; #else QString fileName = "/tmp/kdepimtemp.vcs"; #endif // 1 remove events which should be deleted QPtrList<Event> er = calendar->rawEvents(); Event* ev = er.first(); while ( ev ) { if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { calendar->deleteEvent( ev ); } else { } ev = er.next(); } // 2 remove todos which should be deleted QPtrList<Todo> tl = calendar->rawTodos(); Todo* to = tl.first(); while ( to ) { if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { calendar->deleteTodo( to ); } to = tl.next(); } // 3 save file VCalFormat vfsave; vfsave.setLocalTime ( true ); if ( ! vfsave.save( calendar, fileName ) ) return false; // 4 call kammu - QString command ="./kammu --restore " + fileName ; + QString command ="./kammu --restore " + fileName + " -C" + + mConnection +" -D" + mDevice +" -M" + mModel;; int ret = system ( command.latin1() ); if ( ret != 0 ) return false; // 5 reread data message = i18n(" Rereading all data ... "); status.setText ( message ); qApp->processEvents(); CalendarLocal* calendarTemp = new CalendarLocal(); calendarTemp->setTimeZoneId( calendar->timeZoneId()); if ( ! load( calendarTemp,calendar) ){ qDebug("error reloading calendar "); delete calendarTemp; return false; } // 6 compare data //algo 6 compare event er = calendar->rawEvents(); ev = er.first(); message = i18n(" Comparing event # "); QPtrList<Event> er1 = calendarTemp->rawEvents(); Event* ev1; int procCount = 0; while ( ev ) { qDebug("event new ID "); status.setText ( message + QString::number ( ++procCount ) ); qApp->processEvents(); QString cSum = ev->getCsum(mProfileName); ev1 = er1.first(); while ( ev1 ) { if ( ev1->getCsum( mProfileName ) == cSum ) { er1.remove( ev1 ); afterSave( ev ); ev->setID(mProfileName, ev1->getID(mProfileName) ); break; } ev1 = er1.next(); } if ( ! ev1 ) { ev->removeID(mProfileName); qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); } ev = er.next(); } //algo 6 compare todo to = tl.first(); procCount = 0; QPtrList<Todo> tl1 = calendarTemp->rawTodos(); Todo* to1 ; message = i18n(" Comparing todo # "); while ( to ) { qDebug("todo2 %d ", procCount); status.setText ( message + QString::number ( ++procCount ) ); qApp->processEvents(); QString cSum = to->getCsum(mProfileName); Todo* to1 = tl1.first(); while ( to1 ) { if ( to1->getCsum( mProfileName ) == cSum ) { tl1.remove( to1 ); afterSave( to ); to->setID(mProfileName, to1->getID(mProfileName) ); break; } to1 = tl1.next(); } if ( ! to1 ) { to->removeID(mProfileName); qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); } to = tl.next(); } delete calendarTemp; return true; } QString PhoneFormat::toString( Calendar * ) { return QString::null; } bool PhoneFormat::fromString( Calendar *calendar, const QString & text) { return false; } |