summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-12 09:56:56 (UTC)
committer zautrix <zautrix>2004-09-12 09:56:56 (UTC)
commit31fab1d7e531b492d1075964ddcbebe7a563a41a (patch) (unidiff)
tree91fe6d49f28003106cba1adc9aed816a9019888d
parent8d822fd4d97fbb38ab2c4f3f3f64f175ef143cff (diff)
downloadkdepimpi-31fab1d7e531b492d1075964ddcbebe7a563a41a.zip
kdepimpi-31fab1d7e531b492d1075964ddcbebe7a563a41a.tar.gz
kdepimpi-31fab1d7e531b492d1075964ddcbebe7a563a41a.tar.bz2
Kammu fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/gammu/gammu.c47
-rw-r--r--libkcal/phoneformat.cpp6
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
@@ -5177,3180 +5177,3225 @@ static void ClearAll(int argc, char *argv[])
5177 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 5177 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
5178 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { 5178 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) {
5179 Pbk.MemoryType = MEM_SM; 5179 Pbk.MemoryType = MEM_SM;
5180 Pbk.Location= i + 1; 5180 Pbk.Location= i + 1;
5181 Pbk.EntriesNum= 0; 5181 Pbk.EntriesNum= 0;
5182 error=Phone->DeleteMemory(&s, &Pbk); 5182 error=Phone->DeleteMemory(&s, &Pbk);
5183 Print_Error(error); 5183 Print_Error(error);
5184 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); 5184 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree));
5185 if (gshutdown) { 5185 if (gshutdown) {
5186 GSM_Terminate(); 5186 GSM_Terminate();
5187 exit(0); 5187 exit(0);
5188 } 5188 }
5189 } 5189 }
5190 printmsgerr("\n"); 5190 printmsgerr("\n");
5191 } else { 5191 } else {
5192 printmsgerr("Done\n"); 5192 printmsgerr("Done\n");
5193 Print_Error(error); 5193 Print_Error(error);
5194 } 5194 }
5195 } 5195 }
5196 5196
5197 DoClear = false; 5197 DoClear = false;
5198 error = Phone->GetNextCalendar(&s,&Calendar,true); 5198 error = Phone->GetNextCalendar(&s,&Calendar,true);
5199 if (error == ERR_NONE) { 5199 if (error == ERR_NONE) {
5200 if (answer_yes("Delete calendar notes")) DoClear = true; 5200 if (answer_yes("Delete calendar notes")) DoClear = true;
5201 } 5201 }
5202 if (DoClear) { 5202 if (DoClear) {
5203 printmsgerr("Deleting: "); 5203 printmsgerr("Deleting: ");
5204 error=Phone->DeleteAllCalendar(&s); 5204 error=Phone->DeleteAllCalendar(&s);
5205 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 5205 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
5206 while (1) { 5206 while (1) {
5207 error = Phone->GetNextCalendar(&s,&Calendar,true); 5207 error = Phone->GetNextCalendar(&s,&Calendar,true);
5208 if (error != ERR_NONE) break; 5208 if (error != ERR_NONE) break;
5209 error = Phone->DeleteCalendar(&s,&Calendar); 5209 error = Phone->DeleteCalendar(&s,&Calendar);
5210 Print_Error(error); 5210 Print_Error(error);
5211 printmsgerr("*"); 5211 printmsgerr("*");
5212 } 5212 }
5213 printmsgerr("\n"); 5213 printmsgerr("\n");
5214 } else { 5214 } else {
5215 printmsgerr("Done\n"); 5215 printmsgerr("Done\n");
5216 Print_Error(error); 5216 Print_Error(error);
5217 } 5217 }
5218 } 5218 }
5219 5219
5220 DoClear = false; 5220 DoClear = false;
5221 error = Phone->GetToDoStatus(&s,&ToDoStatus); 5221 error = Phone->GetToDoStatus(&s,&ToDoStatus);
5222 if (error == ERR_NONE && ToDoStatus.Used != 0) { 5222 if (error == ERR_NONE && ToDoStatus.Used != 0) {
5223 if (answer_yes("Delete ToDo")) DoClear = true; 5223 if (answer_yes("Delete ToDo")) DoClear = true;
5224 } 5224 }
5225 if (DoClear) { 5225 if (DoClear) {
5226 printmsgerr("Deleting: "); 5226 printmsgerr("Deleting: ");
5227 error=Phone->DeleteAllToDo(&s); 5227 error=Phone->DeleteAllToDo(&s);
5228 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 5228 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
5229 while (1) { 5229 while (1) {
5230 error = Phone->GetNextToDo(&s,&ToDo,true); 5230 error = Phone->GetNextToDo(&s,&ToDo,true);
5231 if (error != ERR_NONE) break; 5231 if (error != ERR_NONE) break;
5232 error = Phone->DeleteToDo(&s,&ToDo); 5232 error = Phone->DeleteToDo(&s,&ToDo);
5233 Print_Error(error); 5233 Print_Error(error);
5234 printmsgerr("*"); 5234 printmsgerr("*");
5235 } 5235 }
5236 printmsgerr("\n"); 5236 printmsgerr("\n");
5237 } else { 5237 } else {
5238 printmsgerr("Done\n"); 5238 printmsgerr("Done\n");
5239 Print_Error(error); 5239 Print_Error(error);
5240 } 5240 }
5241 } 5241 }
5242 5242
5243 Bookmark.Location = 1; 5243 Bookmark.Location = 1;
5244 error = Phone->GetWAPBookmark(&s,&Bookmark); 5244 error = Phone->GetWAPBookmark(&s,&Bookmark);
5245 if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { 5245 if (error == ERR_NONE || error == ERR_INVALIDLOCATION) {
5246 if (answer_yes("Delete WAP bookmarks")) { 5246 if (answer_yes("Delete WAP bookmarks")) {
5247 printmsgerr("Deleting: "); 5247 printmsgerr("Deleting: ");
5248 /* One thing to explain: DCT4 phones seems to have bug here. 5248 /* One thing to explain: DCT4 phones seems to have bug here.
5249 * When delete for example first bookmark, phone change 5249 * When delete for example first bookmark, phone change
5250 * numeration for getting frame, not for deleting. So, we try to 5250 * numeration for getting frame, not for deleting. So, we try to
5251 * get 1'st bookmark. Inside frame is "correct" location. We use 5251 * get 1'st bookmark. Inside frame is "correct" location. We use
5252 * it later 5252 * it later
5253 */ 5253 */
5254 while (error==ERR_NONE) { 5254 while (error==ERR_NONE) {
5255 error = Phone->DeleteWAPBookmark(&s,&Bookmark); 5255 error = Phone->DeleteWAPBookmark(&s,&Bookmark);
5256 Bookmark.Location = 1; 5256 Bookmark.Location = 1;
5257 error = Phone->GetWAPBookmark(&s,&Bookmark); 5257 error = Phone->GetWAPBookmark(&s,&Bookmark);
5258 printmsgerr("*"); 5258 printmsgerr("*");
5259 } 5259 }
5260 printmsgerr("\n"); 5260 printmsgerr("\n");
5261 } 5261 }
5262 } 5262 }
5263 if (Phone->DeleteUserRingtones != NOTSUPPORTED) { 5263 if (Phone->DeleteUserRingtones != NOTSUPPORTED) {
5264 if (answer_yes("Delete all user ringtones")) { 5264 if (answer_yes("Delete all user ringtones")) {
5265 printmsgerr("Deleting: "); 5265 printmsgerr("Deleting: ");
5266 error=Phone->DeleteUserRingtones(&s); 5266 error=Phone->DeleteUserRingtones(&s);
5267 Print_Error(error); 5267 Print_Error(error);
5268 printmsgerr("Done\n"); 5268 printmsgerr("Done\n");
5269 } 5269 }
5270 } 5270 }
5271 Station.Location=i; 5271 Station.Location=i;
5272 error=Phone->GetFMStation(&s,&Station); 5272 error=Phone->GetFMStation(&s,&Station);
5273 if (error == ERR_NONE || error == ERR_EMPTY) { 5273 if (error == ERR_NONE || error == ERR_EMPTY) {
5274 if (answer_yes("Delete all FM station")) { 5274 if (answer_yes("Delete all FM station")) {
5275 error=Phone->ClearFMStations(&s); 5275 error=Phone->ClearFMStations(&s);
5276 Print_Error(error); 5276 Print_Error(error);
5277 } 5277 }
5278 } 5278 }
5279 5279
5280 GSM_Terminate(); 5280 GSM_Terminate();
5281} 5281}
5282 5282
5283static void DisplayConnectionSettings(GSM_MultiWAPSettings *settings,int j) 5283static void DisplayConnectionSettings(GSM_MultiWAPSettings *settings,int j)
5284{ 5284{
5285 if (settings->Settings[j].IsContinuous) { 5285 if (settings->Settings[j].IsContinuous) {
5286 printmsg("Connection type : Continuous\n"); 5286 printmsg("Connection type : Continuous\n");
5287 } else { 5287 } else {
5288 printmsg("Connection type : Temporary\n"); 5288 printmsg("Connection type : Temporary\n");
5289 } 5289 }
5290 if (settings->Settings[j].IsSecurity) { 5290 if (settings->Settings[j].IsSecurity) {
5291 printmsg("Connection security : On\n"); 5291 printmsg("Connection security : On\n");
5292 } else { 5292 } else {
5293 printmsg("Connection security : Off\n"); 5293 printmsg("Connection security : Off\n");
5294 } 5294 }
5295 printmsg("Proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy),settings->ProxyPort); 5295 printmsg("Proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy),settings->ProxyPort);
5296 printmsg("2'nd proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy2),settings->Proxy2Port); 5296 printmsg("2'nd proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy2),settings->Proxy2Port);
5297 switch (settings->Settings[j].Bearer) { 5297 switch (settings->Settings[j].Bearer) {
5298 case WAPSETTINGS_BEARER_SMS: 5298 case WAPSETTINGS_BEARER_SMS:
5299 printmsg("Bearer : SMS"); 5299 printmsg("Bearer : SMS");
5300 if (settings->ActiveBearer == WAPSETTINGS_BEARER_SMS) printf(" (active)"); 5300 if (settings->ActiveBearer == WAPSETTINGS_BEARER_SMS) printf(" (active)");
5301 printmsg("\nServer number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Server)); 5301 printmsg("\nServer number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Server));
5302 printmsg("Service number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); 5302 printmsg("Service number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service));
5303 break; 5303 break;
5304 case WAPSETTINGS_BEARER_DATA: 5304 case WAPSETTINGS_BEARER_DATA:
5305 printmsg("Bearer : Data (CSD)"); 5305 printmsg("Bearer : Data (CSD)");
5306 if (settings->ActiveBearer == WAPSETTINGS_BEARER_DATA) printf(" (active)"); 5306 if (settings->ActiveBearer == WAPSETTINGS_BEARER_DATA) printf(" (active)");
5307 printmsg("\nDial-up number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp)); 5307 printmsg("\nDial-up number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp));
5308 printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress)); 5308 printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress));
5309 if (settings->Settings[j].ManualLogin) { 5309 if (settings->Settings[j].ManualLogin) {
5310 printmsg("Login Type : Manual\n"); 5310 printmsg("Login Type : Manual\n");
5311 } else { 5311 } else {
5312 printmsg("Login Type : Automatic\n"); 5312 printmsg("Login Type : Automatic\n");
5313 } 5313 }
5314 if (settings->Settings[j].IsNormalAuthentication) { 5314 if (settings->Settings[j].IsNormalAuthentication) {
5315 printmsg("Authentication type : Normal\n"); 5315 printmsg("Authentication type : Normal\n");
5316 } else { 5316 } else {
5317 printmsg("Authentication type : Secure\n"); 5317 printmsg("Authentication type : Secure\n");
5318 } 5318 }
5319 if (settings->Settings[j].IsISDNCall) { 5319 if (settings->Settings[j].IsISDNCall) {
5320 printmsg("Data call type : ISDN\n"); 5320 printmsg("Data call type : ISDN\n");
5321 } else { 5321 } else {
5322 printmsg("Data call type : Analogue\n"); 5322 printmsg("Data call type : Analogue\n");
5323 } 5323 }
5324 switch (settings->Settings[j].Speed) { 5324 switch (settings->Settings[j].Speed) {
5325 case WAPSETTINGS_SPEED_9600 : printmsg("Data call speed : 9600\n"); break; 5325 case WAPSETTINGS_SPEED_9600 : printmsg("Data call speed : 9600\n"); break;
5326 case WAPSETTINGS_SPEED_14400 : printmsg("Data call speed : 14400\n"); break; 5326 case WAPSETTINGS_SPEED_14400 : printmsg("Data call speed : 14400\n"); break;
5327 case WAPSETTINGS_SPEED_AUTO : printmsg("Data call speed : Auto\n"); break; 5327 case WAPSETTINGS_SPEED_AUTO : printmsg("Data call speed : Auto\n"); break;
5328 } 5328 }
5329 printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User)); 5329 printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User));
5330 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password)); 5330 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password));
5331 break; 5331 break;
5332 case WAPSETTINGS_BEARER_USSD: 5332 case WAPSETTINGS_BEARER_USSD:
5333 printmsg("Bearer : USSD"); 5333 printmsg("Bearer : USSD");
5334 if (settings->ActiveBearer == WAPSETTINGS_BEARER_USSD) printf(" (active)"); 5334 if (settings->ActiveBearer == WAPSETTINGS_BEARER_USSD) printf(" (active)");
5335 printmsg("\nService code : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Code)); 5335 printmsg("\nService code : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Code));
5336 if (settings->Settings[j].IsIP) { 5336 if (settings->Settings[j].IsIP) {
5337 printmsg("Address type : IP address\nIPaddress : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); 5337 printmsg("Address type : IP address\nIPaddress : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service));
5338 } else { 5338 } else {
5339 printmsg("Address type : Service number\nService number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); 5339 printmsg("Address type : Service number\nService number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service));
5340 } 5340 }
5341 break; 5341 break;
5342 case WAPSETTINGS_BEARER_GPRS: 5342 case WAPSETTINGS_BEARER_GPRS:
5343 printmsg("Bearer : GPRS"); 5343 printmsg("Bearer : GPRS");
5344 if (settings->ActiveBearer == WAPSETTINGS_BEARER_GPRS) printf(" (active)"); 5344 if (settings->ActiveBearer == WAPSETTINGS_BEARER_GPRS) printf(" (active)");
5345 if (settings->Settings[j].ManualLogin) { 5345 if (settings->Settings[j].ManualLogin) {
5346 printmsg("\nLogin Type : Manual\n"); 5346 printmsg("\nLogin Type : Manual\n");
5347 } else { 5347 } else {
5348 printmsg("\nLogin Type : Automatic\n"); 5348 printmsg("\nLogin Type : Automatic\n");
5349 } 5349 }
5350 if (settings->Settings[j].IsNormalAuthentication) { 5350 if (settings->Settings[j].IsNormalAuthentication) {
5351 printmsg("Authentication type : Normal\n"); 5351 printmsg("Authentication type : Normal\n");
5352 } else { 5352 } else {
5353 printmsg("Authentication type : Secure\n"); 5353 printmsg("Authentication type : Secure\n");
5354 } 5354 }
5355 printmsg("Access point : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp)); 5355 printmsg("Access point : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp));
5356 printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress)); 5356 printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress));
5357 printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User)); 5357 printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User));
5358 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password)); 5358 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password));
5359 } 5359 }
5360} 5360}
5361 5361
5362static void GetSyncMLSettings(int argc, char *argv[]) 5362static void GetSyncMLSettings(int argc, char *argv[])
5363{ 5363{
5364 GSM_SyncMLSettingssettings; 5364 GSM_SyncMLSettingssettings;
5365 int start,stop,j; 5365 int start,stop,j;
5366 5366
5367 GetStartStop(&start, &stop, 2, argc, argv); 5367 GetStartStop(&start, &stop, 2, argc, argv);
5368 5368
5369 GSM_Init(true); 5369 GSM_Init(true);
5370 5370
5371 for (i=start;i<=stop;i++) { 5371 for (i=start;i<=stop;i++) {
5372 settings.Location=i; 5372 settings.Location=i;
5373 error=Phone->GetSyncMLSettings(&s,&settings); 5373 error=Phone->GetSyncMLSettings(&s,&settings);
5374 Print_Error(error); 5374 Print_Error(error);
5375 printmsg("%i. ",i); 5375 printmsg("%i. ",i);
5376 if (settings.Name[0]==0 && settings.Name[1]==0) { 5376 if (settings.Name[0]==0 && settings.Name[1]==0) {
5377 printmsg("Set %i",i); 5377 printmsg("Set %i",i);
5378 } else { 5378 } else {
5379 printmsg("%s",DecodeUnicodeConsole(settings.Name)); 5379 printmsg("%s",DecodeUnicodeConsole(settings.Name));
5380 } 5380 }
5381 if (settings.Active) printmsg(" (active)"); 5381 if (settings.Active) printmsg(" (active)");
5382 // if (settings.ReadOnly) printmsg("\nRead only : yes"); 5382 // if (settings.ReadOnly) printmsg("\nRead only : yes");
5383 printmsg("\n"); 5383 printmsg("\n");
5384 printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User)); 5384 printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User));
5385 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password)); 5385 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password));
5386 printmsg("Phonebook database : \"%s\"\n",DecodeUnicodeConsole(settings.PhonebookDataBase)); 5386 printmsg("Phonebook database : \"%s\"\n",DecodeUnicodeConsole(settings.PhonebookDataBase));
5387 printmsg("Calendar database : \"%s\"\n",DecodeUnicodeConsole(settings.CalendarDataBase)); 5387 printmsg("Calendar database : \"%s\"\n",DecodeUnicodeConsole(settings.CalendarDataBase));
5388 printmsg("Server : \"%s\"\n",DecodeUnicodeConsole(settings.Server)); 5388 printmsg("Server : \"%s\"\n",DecodeUnicodeConsole(settings.Server));
5389 printmsg("Sync. phonebook : "); 5389 printmsg("Sync. phonebook : ");
5390 if (settings.SyncPhonebook) printmsg("yes\n"); 5390 if (settings.SyncPhonebook) printmsg("yes\n");
5391 if (!settings.SyncPhonebook) printmsg("no\n"); 5391 if (!settings.SyncPhonebook) printmsg("no\n");
5392 printmsg("Sync. calendar : "); 5392 printmsg("Sync. calendar : ");
5393 if (settings.SyncCalendar) printmsg("yes\n"); 5393 if (settings.SyncCalendar) printmsg("yes\n");
5394 if (!settings.SyncCalendar) printmsg("no\n"); 5394 if (!settings.SyncCalendar) printmsg("no\n");
5395 printmsg("\n"); 5395 printmsg("\n");
5396 for (j=0;j<settings.Connection.Number;j++) { 5396 for (j=0;j<settings.Connection.Number;j++) {
5397 if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { 5397 if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) {
5398 printmsg("Connection set name : Set %i\n",i); 5398 printmsg("Connection set name : Set %i\n",i);
5399 } else { 5399 } else {
5400 printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); 5400 printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title));
5401 } 5401 }
5402 DisplayConnectionSettings(&settings.Connection,j); 5402 DisplayConnectionSettings(&settings.Connection,j);
5403 printf("\n"); 5403 printf("\n");
5404 } 5404 }
5405 } 5405 }
5406 GSM_Terminate(); 5406 GSM_Terminate();
5407} 5407}
5408 5408
5409static void GetChatSettings(int argc, char *argv[]) 5409static void GetChatSettings(int argc, char *argv[])
5410{ 5410{
5411 GSM_ChatSettingssettings; 5411 GSM_ChatSettingssettings;
5412 int start,stop,j; 5412 int start,stop,j;
5413 5413
5414 GetStartStop(&start, &stop, 2, argc, argv); 5414 GetStartStop(&start, &stop, 2, argc, argv);
5415 5415
5416 GSM_Init(true); 5416 GSM_Init(true);
5417 5417
5418 for (i=start;i<=stop;i++) { 5418 for (i=start;i<=stop;i++) {
5419 settings.Location=i; 5419 settings.Location=i;
5420 error=Phone->GetChatSettings(&s,&settings); 5420 error=Phone->GetChatSettings(&s,&settings);
5421 Print_Error(error); 5421 Print_Error(error);
5422 printmsg("%i. ",i); 5422 printmsg("%i. ",i);
5423 if (settings.Name[0]==0 && settings.Name[1]==0) { 5423 if (settings.Name[0]==0 && settings.Name[1]==0) {
5424 printmsg("Set %i",i); 5424 printmsg("Set %i",i);
5425 } else { 5425 } else {
5426 printmsg("%s",DecodeUnicodeConsole(settings.Name)); 5426 printmsg("%s",DecodeUnicodeConsole(settings.Name));
5427 } 5427 }
5428 if (settings.Active) printmsg(" (active)"); 5428 if (settings.Active) printmsg(" (active)");
5429 // if (settings.ReadOnly) printmsg("\nRead only : yes"); 5429 // if (settings.ReadOnly) printmsg("\nRead only : yes");
5430 printmsg("\n"); 5430 printmsg("\n");
5431 printmsg("Homepage : \"%s\"\n",DecodeUnicodeConsole(settings.HomePage)); 5431 printmsg("Homepage : \"%s\"\n",DecodeUnicodeConsole(settings.HomePage));
5432 printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User)); 5432 printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User));
5433 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password)); 5433 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password));
5434 printmsg("\n"); 5434 printmsg("\n");
5435 for (j=0;j<settings.Connection.Number;j++) { 5435 for (j=0;j<settings.Connection.Number;j++) {
5436 if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { 5436 if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) {
5437 printmsg("Connection set name : Set %i\n",i); 5437 printmsg("Connection set name : Set %i\n",i);
5438 } else { 5438 } else {
5439 printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); 5439 printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title));
5440 } 5440 }
5441 DisplayConnectionSettings(&settings.Connection,j); 5441 DisplayConnectionSettings(&settings.Connection,j);
5442 printf("\n"); 5442 printf("\n");
5443 } 5443 }
5444 } 5444 }
5445 GSM_Terminate(); 5445 GSM_Terminate();
5446} 5446}
5447 5447
5448static void GetWAPMMSSettings(int argc, char *argv[]) 5448static void GetWAPMMSSettings(int argc, char *argv[])
5449{ 5449{
5450 GSM_MultiWAPSettingssettings; 5450 GSM_MultiWAPSettingssettings;
5451 int start,stop,j; 5451 int start,stop,j;
5452 5452
5453 GetStartStop(&start, &stop, 2, argc, argv); 5453 GetStartStop(&start, &stop, 2, argc, argv);
5454 5454
5455 GSM_Init(true); 5455 GSM_Init(true);
5456 5456
5457 for (i=start;i<=stop;i++) { 5457 for (i=start;i<=stop;i++) {
5458 settings.Location=i; 5458 settings.Location=i;
5459 if (mystrncasecmp(argv[1],"--getwapsettings",0)) { 5459 if (mystrncasecmp(argv[1],"--getwapsettings",0)) {
5460 error=Phone->GetWAPSettings(&s,&settings); 5460 error=Phone->GetWAPSettings(&s,&settings);
5461 } else { 5461 } else {
5462 error=Phone->GetMMSSettings(&s,&settings); 5462 error=Phone->GetMMSSettings(&s,&settings);
5463 } 5463 }
5464 Print_Error(error); 5464 Print_Error(error);
5465 for (j=0;j<settings.Number;j++) { 5465 for (j=0;j<settings.Number;j++) {
5466 printmsg("%i. ",i); 5466 printmsg("%i. ",i);
5467 if (settings.Settings[j].Title[0]==0 && settings.Settings[j].Title[1]==0) { 5467 if (settings.Settings[j].Title[0]==0 && settings.Settings[j].Title[1]==0) {
5468 printmsg("Set %i",i); 5468 printmsg("Set %i",i);
5469 } else { 5469 } else {
5470 printmsg("%s",DecodeUnicodeConsole(settings.Settings[j].Title)); 5470 printmsg("%s",DecodeUnicodeConsole(settings.Settings[j].Title));
5471 } 5471 }
5472 if (settings.Active) printmsg(" (active)"); 5472 if (settings.Active) printmsg(" (active)");
5473 if (settings.ReadOnly) printmsg("\nRead only : yes"); 5473 if (settings.ReadOnly) printmsg("\nRead only : yes");
5474 printmsg("\nHomepage : \"%s\"\n",DecodeUnicodeConsole(settings.Settings[j].HomePage)); 5474 printmsg("\nHomepage : \"%s\"\n",DecodeUnicodeConsole(settings.Settings[j].HomePage));
5475 DisplayConnectionSettings(&settings,j); 5475 DisplayConnectionSettings(&settings,j);
5476 printf("\n"); 5476 printf("\n");
5477 } 5477 }
5478 } 5478 }
5479 GSM_Terminate(); 5479 GSM_Terminate();
5480} 5480}
5481 5481
5482#ifdef GSM_ENABLE_BACKUP 5482#ifdef GSM_ENABLE_BACKUP
5483static void BackupSMS(int argc, char *argv[]) 5483static void BackupSMS(int argc, char *argv[])
5484{ 5484{
5485 GSM_SMS_Backup Backup; 5485 GSM_SMS_Backup Backup;
5486 GSM_MultiSMSMessage sms; 5486 GSM_MultiSMSMessage sms;
5487 GSM_SMSFolders folders; 5487 GSM_SMSFolders folders;
5488 bool BackupFromFolder[GSM_MAX_SMS_FOLDERS]; 5488 bool BackupFromFolder[GSM_MAX_SMS_FOLDERS];
5489 bool start = true; 5489 bool start = true;
5490 bool DeleteAfter; 5490 bool DeleteAfter;
5491 int j, smsnum; 5491 int j, smsnum;
5492 char buffer[200]; 5492 char buffer[200];
5493 5493
5494 /* We ignore return code, because (when file doesn't exist) we 5494 /* We ignore return code, because (when file doesn't exist) we
5495 * will create new later 5495 * will create new later
5496 */ 5496 */
5497 GSM_ReadSMSBackupFile(argv[2], &Backup); 5497 GSM_ReadSMSBackupFile(argv[2], &Backup);
5498 smsnum = 0; 5498 smsnum = 0;
5499 while (Backup.SMS[smsnum]!=NULL) smsnum++; 5499 while (Backup.SMS[smsnum]!=NULL) smsnum++;
5500 5500
5501 GSM_Init(true); 5501 GSM_Init(true);
5502 5502
5503 error=Phone->GetSMSFolders(&s, &folders); 5503 error=Phone->GetSMSFolders(&s, &folders);
5504 Print_Error(error); 5504 Print_Error(error);
5505 5505
5506 DeleteAfter=answer_yes("Delete each sms after backup"); 5506 DeleteAfter=answer_yes("Delete each sms after backup");
5507 5507
5508 for (j=0;j<folders.Number;j++) { 5508 for (j=0;j<folders.Number;j++) {
5509 BackupFromFolder[j] = false; 5509 BackupFromFolder[j] = false;
5510 sprintf(buffer,"Backup sms from folder \"%s\"",DecodeUnicodeConsole(folders.Folder[j].Name)); 5510 sprintf(buffer,"Backup sms from folder \"%s\"",DecodeUnicodeConsole(folders.Folder[j].Name));
5511 if (answer_yes(buffer)) BackupFromFolder[j] = true; 5511 if (answer_yes(buffer)) BackupFromFolder[j] = true;
5512 } 5512 }
5513 5513
5514 while (error == ERR_NONE) { 5514 while (error == ERR_NONE) {
5515 sms.SMS[0].Folder=0x00; 5515 sms.SMS[0].Folder=0x00;
5516 error=Phone->GetNextSMS(&s, &sms, start); 5516 error=Phone->GetNextSMS(&s, &sms, start);
5517 switch (error) { 5517 switch (error) {
5518 case ERR_EMPTY: 5518 case ERR_EMPTY:
5519 break; 5519 break;
5520 default: 5520 default:
5521 Print_Error(error); 5521 Print_Error(error);
5522 for (j=0;j<sms.Number;j++) { 5522 for (j=0;j<sms.Number;j++) {
5523 if (BackupFromFolder[sms.SMS[j].Folder-1]) { 5523 if (BackupFromFolder[sms.SMS[j].Folder-1]) {
5524 switch (sms.SMS[j].PDU) { 5524 switch (sms.SMS[j].PDU) {
5525 case SMS_Status_Report: 5525 case SMS_Status_Report:
5526 break; 5526 break;
5527 case SMS_Submit: 5527 case SMS_Submit:
5528 case SMS_Deliver: 5528 case SMS_Deliver:
5529 if (sms.SMS[j].Length == 0) break; 5529 if (sms.SMS[j].Length == 0) break;
5530 if (smsnum < GSM_BACKUP_MAX_SMS) { 5530 if (smsnum < GSM_BACKUP_MAX_SMS) {
5531 Backup.SMS[smsnum] = malloc(sizeof(GSM_SMSMessage)); 5531 Backup.SMS[smsnum] = malloc(sizeof(GSM_SMSMessage));
5532 if (Backup.SMS[smsnum] == NULL) Print_Error(ERR_MOREMEMORY); 5532 if (Backup.SMS[smsnum] == NULL) Print_Error(ERR_MOREMEMORY);
5533 Backup.SMS[smsnum+1] = NULL; 5533 Backup.SMS[smsnum+1] = NULL;
5534 } else { 5534 } else {
5535 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMS"); 5535 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMS");
5536 GSM_Terminate(); 5536 GSM_Terminate();
5537 exit(-1); 5537 exit(-1);
5538 } 5538 }
5539 *Backup.SMS[smsnum] = sms.SMS[j]; 5539 *Backup.SMS[smsnum] = sms.SMS[j];
5540 smsnum++; 5540 smsnum++;
5541 break; 5541 break;
5542 } 5542 }
5543 } 5543 }
5544 } 5544 }
5545 } 5545 }
5546 start=false; 5546 start=false;
5547 } 5547 }
5548 5548
5549 error = GSM_SaveSMSBackupFile(argv[2],&Backup); 5549 error = GSM_SaveSMSBackupFile(argv[2],&Backup);
5550 Print_Error(error); 5550 Print_Error(error);
5551 5551
5552 if (DeleteAfter) { 5552 if (DeleteAfter) {
5553 for (j=0;j<smsnum;j++) { 5553 for (j=0;j<smsnum;j++) {
5554 Backup.SMS[j]->Folder = 0; 5554 Backup.SMS[j]->Folder = 0;
5555 error=Phone->DeleteSMS(&s, Backup.SMS[j]); 5555 error=Phone->DeleteSMS(&s, Backup.SMS[j]);
5556 Print_Error(error); 5556 Print_Error(error);
5557 printmsgerr("%cDeleting: %i percent",13,(j+1)*100/smsnum); 5557 printmsgerr("%cDeleting: %i percent",13,(j+1)*100/smsnum);
5558 } 5558 }
5559 } 5559 }
5560 5560
5561 GSM_Terminate(); 5561 GSM_Terminate();
5562} 5562}
5563 5563
5564static void AddSMS(int argc, char *argv[]) 5564static void AddSMS(int argc, char *argv[])
5565{ 5565{
5566 GSM_MultiSMSMessage SMS; 5566 GSM_MultiSMSMessage SMS;
5567 GSM_SMS_Backup Backup; 5567 GSM_SMS_Backup Backup;
5568 int smsnum = 0; 5568 int smsnum = 0;
5569 int folder; 5569 int folder;
5570 5570
5571 folder = atoi(argv[2]); 5571 folder = atoi(argv[2]);
5572 5572
5573 error = GSM_ReadSMSBackupFile(argv[3], &Backup); 5573 error = GSM_ReadSMSBackupFile(argv[3], &Backup);
5574 Print_Error(error); 5574 Print_Error(error);
5575 5575
5576 GSM_Init(true); 5576 GSM_Init(true);
5577 5577
5578 while (Backup.SMS[smsnum] != NULL) { 5578 while (Backup.SMS[smsnum] != NULL) {
5579 Backup.SMS[smsnum]->Folder = folder; 5579 Backup.SMS[smsnum]->Folder = folder;
5580 Backup.SMS[smsnum]->SMSC.Location = 1; 5580 Backup.SMS[smsnum]->SMSC.Location = 1;
5581 SMS.Number = 1; 5581 SMS.Number = 1;
5582 SMS.SMS[0] = *Backup.SMS[smsnum]; 5582 SMS.SMS[0] = *Backup.SMS[smsnum];
5583 displaymultismsinfo(SMS,false,false); 5583 displaymultismsinfo(SMS,false,false);
5584 if (answer_yes("Restore sms")) { 5584 if (answer_yes("Restore sms")) {
5585 error=Phone->AddSMS(&s, Backup.SMS[smsnum]); 5585 error=Phone->AddSMS(&s, Backup.SMS[smsnum]);
5586 Print_Error(error); 5586 Print_Error(error);
5587 } 5587 }
5588 smsnum++; 5588 smsnum++;
5589 } 5589 }
5590 5590
5591 GSM_Terminate(); 5591 GSM_Terminate();
5592} 5592}
5593 5593
5594static void RestoreSMS(int argc, char *argv[]) 5594static void RestoreSMS(int argc, char *argv[])
5595{ 5595{
5596 GSM_MultiSMSMessage SMS; 5596 GSM_MultiSMSMessage SMS;
5597 GSM_SMS_Backup Backup; 5597 GSM_SMS_Backup Backup;
5598 GSM_SMSFolders folders; 5598 GSM_SMSFolders folders;
5599 int smsnum = 0; 5599 int smsnum = 0;
5600 char buffer[200]; 5600 char buffer[200];
5601 5601
5602 error=GSM_ReadSMSBackupFile(argv[2], &Backup); 5602 error=GSM_ReadSMSBackupFile(argv[2], &Backup);
5603 Print_Error(error); 5603 Print_Error(error);
5604 5604
5605 GSM_Init(true); 5605 GSM_Init(true);
5606 5606
5607 error=Phone->GetSMSFolders(&s, &folders); 5607 error=Phone->GetSMSFolders(&s, &folders);
5608 Print_Error(error); 5608 Print_Error(error);
5609 5609
5610 while (Backup.SMS[smsnum] != NULL) { 5610 while (Backup.SMS[smsnum] != NULL) {
5611 SMS.Number = 1; 5611 SMS.Number = 1;
5612 memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage)); 5612 memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage));
5613 displaymultismsinfo(SMS,false,false); 5613 displaymultismsinfo(SMS,false,false);
5614 sprintf(buffer,"Restore sms to folder \"%s\"",DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name)); 5614 sprintf(buffer,"Restore sms to folder \"%s\"",DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name));
5615 if (answer_yes(buffer)) { 5615 if (answer_yes(buffer)) {
5616 Backup.SMS[smsnum]->Location = 0; 5616 Backup.SMS[smsnum]->Location = 0;
5617 error=Phone->SetSMS(&s, Backup.SMS[smsnum]); 5617 error=Phone->SetSMS(&s, Backup.SMS[smsnum]);
5618 Print_Error(error); 5618 Print_Error(error);
5619 } 5619 }
5620 smsnum++; 5620 smsnum++;
5621 } 5621 }
5622 5622
5623 GSM_Terminate(); 5623 GSM_Terminate();
5624} 5624}
5625#endif 5625#endif
5626 5626
5627static void CopyBitmap(int argc, char *argv[]) 5627static void CopyBitmap(int argc, char *argv[])
5628{ 5628{
5629 GSM_MultiBitmap Bitmap; 5629 GSM_MultiBitmap Bitmap;
5630 int i; 5630 int i;
5631 5631
5632 Bitmap.Bitmap[0].Type = GSM_None; 5632 Bitmap.Bitmap[0].Type = GSM_None;
5633 5633
5634 error=GSM_ReadBitmapFile(argv[2],&Bitmap); 5634 error=GSM_ReadBitmapFile(argv[2],&Bitmap);
5635 Print_Error(error); 5635 Print_Error(error);
5636 5636
5637 if (argc==3) { 5637 if (argc==3) {
5638 for (i=0;i<Bitmap.Number;i++) { 5638 for (i=0;i<Bitmap.Number;i++) {
5639 switch (Bitmap.Bitmap[i].Type) { 5639 switch (Bitmap.Bitmap[i].Type) {
5640 case GSM_StartupLogo : printmsg("Startup logo"); break; 5640 case GSM_StartupLogo : printmsg("Startup logo"); break;
5641 case GSM_OperatorLogo: printmsg("Operator logo"); break; 5641 case GSM_OperatorLogo: printmsg("Operator logo"); break;
5642 case GSM_PictureImage: printmsg("Picture Image"); break; 5642 case GSM_PictureImage: printmsg("Picture Image"); break;
5643 case GSM_CallerGroupLogo : printmsg("Caller group logo"); break; 5643 case GSM_CallerGroupLogo : printmsg("Caller group logo"); break;
5644 default : break; 5644 default : break;
5645 } 5645 }
5646 printmsg(", width %i, height %i\n",Bitmap.Bitmap[i].BitmapWidth,Bitmap.Bitmap[i].BitmapHeight); 5646 printmsg(", width %i, height %i\n",Bitmap.Bitmap[i].BitmapWidth,Bitmap.Bitmap[i].BitmapHeight);
5647 GSM_PrintBitmap(stdout,&Bitmap.Bitmap[i]); 5647 GSM_PrintBitmap(stdout,&Bitmap.Bitmap[i]);
5648 } 5648 }
5649 } else { 5649 } else {
5650 if (argc == 5) { 5650 if (argc == 5) {
5651 for (i=0;i<Bitmap.Number;i++) { 5651 for (i=0;i<Bitmap.Number;i++) {
5652 if (mystrncasecmp(argv[4],"PICTURE",0)) { 5652 if (mystrncasecmp(argv[4],"PICTURE",0)) {
5653 Bitmap.Bitmap[i].Type = GSM_PictureImage; 5653 Bitmap.Bitmap[i].Type = GSM_PictureImage;
5654 } else if (mystrncasecmp(argv[4],"STARTUP",0)) { 5654 } else if (mystrncasecmp(argv[4],"STARTUP",0)) {
5655 Bitmap.Bitmap[i].Type = GSM_StartupLogo; 5655 Bitmap.Bitmap[i].Type = GSM_StartupLogo;
5656 } else if (mystrncasecmp(argv[4],"CALLER",0)) { 5656 } else if (mystrncasecmp(argv[4],"CALLER",0)) {
5657 Bitmap.Bitmap[i].Type = GSM_CallerGroupLogo; 5657 Bitmap.Bitmap[i].Type = GSM_CallerGroupLogo;
5658 } else if (mystrncasecmp(argv[4],"OPERATOR",0)) { 5658 } else if (mystrncasecmp(argv[4],"OPERATOR",0)) {
5659 Bitmap.Bitmap[i].Type = GSM_OperatorLogo; 5659 Bitmap.Bitmap[i].Type = GSM_OperatorLogo;
5660 } else { 5660 } else {
5661 printmsg("What format of output file logo (\"%s\") ?\n",argv[4]); 5661 printmsg("What format of output file logo (\"%s\") ?\n",argv[4]);
5662 exit(-1); 5662 exit(-1);
5663 } 5663 }
5664 } 5664 }
5665 } 5665 }
5666 error=GSM_SaveBitmapFile(argv[3],&Bitmap); 5666 error=GSM_SaveBitmapFile(argv[3],&Bitmap);
5667 Print_Error(error); 5667 Print_Error(error);
5668 } 5668 }
5669} 5669}
5670 5670
5671static void NokiaComposer(int argc, char *argv[]) 5671static void NokiaComposer(int argc, char *argv[])
5672{ 5672{
5673 GSM_Ringtone ringtone; 5673 GSM_Ringtone ringtone;
5674 bool started; 5674 bool started;
5675 int i,j; 5675 int i,j;
5676 GSM_RingNote *Note; 5676 GSM_RingNote *Note;
5677 GSM_RingNoteDuration Duration; 5677 GSM_RingNoteDuration Duration;
5678 GSM_RingNoteDuration DefNoteDuration = 32; /* 32 = Duration_1_4 */ 5678 GSM_RingNoteDuration DefNoteDuration = 32; /* 32 = Duration_1_4 */
5679 unsigned int DefNoteScale = Scale_880; 5679 unsigned int DefNoteScale = Scale_880;
5680 5680
5681 ringtone.Format= 0; 5681 ringtone.Format= 0;
5682 error=GSM_ReadRingtoneFile(argv[2],&ringtone); 5682 error=GSM_ReadRingtoneFile(argv[2],&ringtone);
5683 5683
5684 if (ringtone.Format != RING_NOTETONE) { 5684 if (ringtone.Format != RING_NOTETONE) {
5685 printmsg("It can be RTTL ringtone only used with this option\n"); 5685 printmsg("It can be RTTL ringtone only used with this option\n");
5686 exit(-1); 5686 exit(-1);
5687 } 5687 }
5688 5688
5689 started = false; 5689 started = false;
5690 j= 0; 5690 j= 0;
5691 for (i=0;i<ringtone.NoteTone.NrCommands;i++) { 5691 for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
5692 if (ringtone.NoteTone.Commands[i].Type == RING_Note) { 5692 if (ringtone.NoteTone.Commands[i].Type == RING_Note) {
5693 Note = &ringtone.NoteTone.Commands[i].Note; 5693 Note = &ringtone.NoteTone.Commands[i].Note;
5694 if (!started) { 5694 if (!started) {
5695 if (Note->Note != Note_Pause) { 5695 if (Note->Note != Note_Pause) {
5696 printmsg("Ringtone \"%s\" (tempo = %i Beats Per Minute)\n\n",DecodeUnicodeConsole(ringtone.Name),GSM_RTTLGetTempo(Note->Tempo)); 5696 printmsg("Ringtone \"%s\" (tempo = %i Beats Per Minute)\n\n",DecodeUnicodeConsole(ringtone.Name),GSM_RTTLGetTempo(Note->Tempo));
5697 started = true; 5697 started = true;
5698 } 5698 }
5699 } 5699 }
5700 if (started) j++; 5700 if (started) j++;
5701 } 5701 }
5702 } 5702 }
5703 if (j>50) printmsg("WARNING: LENGTH=%i NOTES, BUT YOU WILL ENTER ONLY FIRST 50 TONES.",j); 5703 if (j>50) printmsg("WARNING: LENGTH=%i NOTES, BUT YOU WILL ENTER ONLY FIRST 50 TONES.",j);
5704 5704
5705 printmsg("\n\nThis ringtone in Nokia Composer in phone should look: "); 5705 printmsg("\n\nThis ringtone in Nokia Composer in phone should look: ");
5706 started = false; 5706 started = false;
5707 for (i=0;i<ringtone.NoteTone.NrCommands;i++) { 5707 for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
5708 if (ringtone.NoteTone.Commands[i].Type == RING_Note) { 5708 if (ringtone.NoteTone.Commands[i].Type == RING_Note) {
5709 Note = &ringtone.NoteTone.Commands[i].Note; 5709 Note = &ringtone.NoteTone.Commands[i].Note;
5710 if (!started) { 5710 if (!started) {
5711 if (Note->Note != Note_Pause) started = true; 5711 if (Note->Note != Note_Pause) started = true;
5712 } 5712 }
5713 if (started) { 5713 if (started) {
5714 switch (Note->Duration) { 5714 switch (Note->Duration) {
5715 case Duration_Full: printmsg("1"); break; 5715 case Duration_Full: printmsg("1"); break;
5716 case Duration_1_2 : printmsg("2"); break; 5716 case Duration_1_2 : printmsg("2"); break;
5717 case Duration_1_4 : printmsg("4"); break; 5717 case Duration_1_4 : printmsg("4"); break;
5718 case Duration_1_8 : printmsg("8"); break; 5718 case Duration_1_8 : printmsg("8"); break;
5719 case Duration_1_16: printmsg("16");break; 5719 case Duration_1_16: printmsg("16");break;
5720 case Duration_1_32: printmsg("32");break; 5720 case Duration_1_32: printmsg("32");break;
5721 } 5721 }
5722 if (Note->DurationSpec == DottedNote) printmsg("."); 5722 if (Note->DurationSpec == DottedNote) printmsg(".");
5723 switch (Note->Note) { 5723 switch (Note->Note) {
5724 case Note_C : printmsg("c");break; 5724 case Note_C : printmsg("c");break;
5725 case Note_Cis : printmsg("#c");break; 5725 case Note_Cis : printmsg("#c");break;
5726 case Note_D :printmsg("d");break; 5726 case Note_D :printmsg("d");break;
5727 case Note_Dis : printmsg("#d");break; 5727 case Note_Dis : printmsg("#d");break;
5728 case Note_E : printmsg("e");break; 5728 case Note_E : printmsg("e");break;
5729 case Note_F : printmsg("f");break; 5729 case Note_F : printmsg("f");break;
5730 case Note_Fis : printmsg("#f");break; 5730 case Note_Fis : printmsg("#f");break;
5731 case Note_G : printmsg("g");break; 5731 case Note_G : printmsg("g");break;
5732 case Note_Gis : printmsg("#g");break; 5732 case Note_Gis : printmsg("#g");break;
5733 case Note_A : printmsg("a");break; 5733 case Note_A : printmsg("a");break;
5734 case Note_Ais : printmsg("#a");break; 5734 case Note_Ais : printmsg("#a");break;
5735 case Note_H : printmsg("h");break; 5735 case Note_H : printmsg("h");break;
5736 case Note_Pause : printmsg("-");break; 5736 case Note_Pause : printmsg("-");break;
5737 } 5737 }
5738 if (Note->Note != Note_Pause) printmsg("%i",Note->Scale - 4); 5738 if (Note->Note != Note_Pause) printmsg("%i",Note->Scale - 4);
5739 printmsg(" "); 5739 printmsg(" ");
5740 } 5740 }
5741 } 5741 }
5742 } 5742 }
5743 5743
5744 printmsg("\n\nTo enter it please press: "); 5744 printmsg("\n\nTo enter it please press: ");
5745 started = false; 5745 started = false;
5746 for (i=0;i<ringtone.NoteTone.NrCommands;i++) { 5746 for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
5747 if (ringtone.NoteTone.Commands[i].Type == RING_Note) { 5747 if (ringtone.NoteTone.Commands[i].Type == RING_Note) {
5748 Note = &ringtone.NoteTone.Commands[i].Note; 5748 Note = &ringtone.NoteTone.Commands[i].Note;
5749 if (!started) { 5749 if (!started) {
5750 if (Note->Note != Note_Pause) started = true; 5750 if (Note->Note != Note_Pause) started = true;
5751 } 5751 }
5752 if (started) { 5752 if (started) {
5753 switch (Note->Note) { 5753 switch (Note->Note) {
5754 case Note_C : case Note_Cis:printmsg("1");break; 5754 case Note_C : case Note_Cis:printmsg("1");break;
5755 case Note_D : case Note_Dis:printmsg("2");break; 5755 case Note_D : case Note_Dis:printmsg("2");break;
5756 case Note_E : printmsg("3");break; 5756 case Note_E : printmsg("3");break;
5757 case Note_F : case Note_Fis:printmsg("4");break; 5757 case Note_F : case Note_Fis:printmsg("4");break;
5758 case Note_G : case Note_Gis:printmsg("5");break; 5758 case Note_G : case Note_Gis:printmsg("5");break;
5759 case Note_A : case Note_Ais:printmsg("6");break; 5759 case Note_A : case Note_Ais:printmsg("6");break;
5760 case Note_H : printmsg("7");break; 5760 case Note_H : printmsg("7");break;
5761 default : printmsg("0");break; 5761 default : printmsg("0");break;
5762 } 5762 }
5763 if (Note->DurationSpec == DottedNote) printmsg("(longer)"); 5763 if (Note->DurationSpec == DottedNote) printmsg("(longer)");
5764 switch (Note->Note) { 5764 switch (Note->Note) {
5765 case Note_Cis: case Note_Dis: 5765 case Note_Cis: case Note_Dis:
5766 case Note_Fis: case Note_Gis: 5766 case Note_Fis: case Note_Gis:
5767 case Note_Ais: 5767 case Note_Ais:
5768 printmsg("#"); 5768 printmsg("#");
5769 break; 5769 break;
5770 default : 5770 default :
5771 break; 5771 break;
5772 } 5772 }
5773 if (Note->Note != Note_Pause) { 5773 if (Note->Note != Note_Pause) {
5774 if ((unsigned int)Note->Scale != DefNoteScale) { 5774 if ((unsigned int)Note->Scale != DefNoteScale) {
5775 while (DefNoteScale != (unsigned int)Note->Scale) { 5775 while (DefNoteScale != (unsigned int)Note->Scale) {
5776 printmsg("*"); 5776 printmsg("*");
5777 DefNoteScale++; 5777 DefNoteScale++;
5778 if (DefNoteScale==Scale_7040) DefNoteScale = Scale_880; 5778 if (DefNoteScale==Scale_7040) DefNoteScale = Scale_880;
5779 } 5779 }
5780 } 5780 }
5781 } 5781 }
5782 Duration = 0; 5782 Duration = 0;
5783 switch (Note->Duration) { 5783 switch (Note->Duration) {
5784 case Duration_Full : Duration = 128;break; 5784 case Duration_Full : Duration = 128;break;
5785 case Duration_1_2 : Duration = 64;break; 5785 case Duration_1_2 : Duration = 64;break;
5786 case Duration_1_4 : Duration = 32;break; 5786 case Duration_1_4 : Duration = 32;break;
5787 case Duration_1_8 : Duration = 16;break; 5787 case Duration_1_8 : Duration = 16;break;
5788 case Duration_1_16 : Duration = 8;break; 5788 case Duration_1_16 : Duration = 8;break;
5789 case Duration_1_32 : Duration = 4;break; 5789 case Duration_1_32 : Duration = 4;break;
5790 default : dbgprintf("error\n");break; 5790 default : dbgprintf("error\n");break;
5791 } 5791 }
5792 if (Duration > DefNoteDuration) { 5792 if (Duration > DefNoteDuration) {
5793 while (DefNoteDuration != Duration) { 5793 while (DefNoteDuration != Duration) {
5794 printmsg("9"); 5794 printmsg("9");
5795 DefNoteDuration = DefNoteDuration * 2; 5795 DefNoteDuration = DefNoteDuration * 2;
5796 } 5796 }
5797 } 5797 }
5798 if (Duration < DefNoteDuration) { 5798 if (Duration < DefNoteDuration) {
5799 while (DefNoteDuration != Duration) { 5799 while (DefNoteDuration != Duration) {
5800 printmsg("8"); 5800 printmsg("8");
5801 DefNoteDuration = DefNoteDuration / 2; 5801 DefNoteDuration = DefNoteDuration / 2;
5802 } 5802 }
5803 } 5803 }
5804 printmsg(" "); 5804 printmsg(" ");
5805 } 5805 }
5806 } 5806 }
5807 } 5807 }
5808 5808
5809 printf("\n"); 5809 printf("\n");
5810} 5810}
5811//#if 0 5811//#if 0
5812static void CopyRingtone(int argc, char *argv[]) 5812static void CopyRingtone(int argc, char *argv[])
5813{ 5813{
5814 GSM_Ringtone ringtone, ringtone2; 5814 GSM_Ringtone ringtone, ringtone2;
5815 GSM_RingtoneFormatFormat; 5815 GSM_RingtoneFormatFormat;
5816 5816
5817 ringtone.Format= 0; 5817 ringtone.Format= 0;
5818 error=GSM_ReadRingtoneFile(argv[2],&ringtone); 5818 error=GSM_ReadRingtoneFile(argv[2],&ringtone);
5819 Print_Error(error); 5819 Print_Error(error);
5820 5820
5821 Format = ringtone.Format; 5821 Format = ringtone.Format;
5822 if (argc == 5) { 5822 if (argc == 5) {
5823 if (mystrncasecmp(argv[4],"RTTL",0)) { Format = RING_NOTETONE; 5823 if (mystrncasecmp(argv[4],"RTTL",0)) { Format = RING_NOTETONE;
5824 } else if (mystrncasecmp(argv[4],"BINARY",0)) {Format = RING_NOKIABINARY; 5824 } else if (mystrncasecmp(argv[4],"BINARY",0)) {Format = RING_NOKIABINARY;
5825 } else { 5825 } else {
5826 printmsg("What format of output ringtone file (\"%s\") ?\n",argv[4]); 5826 printmsg("What format of output ringtone file (\"%s\") ?\n",argv[4]);
5827 exit(-1); 5827 exit(-1);
5828 } 5828 }
5829 } 5829 }
5830 5830
5831 error=GSM_RingtoneConvert(&ringtone2,&ringtone,Format); 5831 error=GSM_RingtoneConvert(&ringtone2,&ringtone,Format);
5832 Print_Error(error); 5832 Print_Error(error);
5833 5833
5834 error=GSM_SaveRingtoneFile(argv[3],&ringtone2); 5834 error=GSM_SaveRingtoneFile(argv[3],&ringtone2);
5835 Print_Error(error); 5835 Print_Error(error);
5836} 5836}
5837 5837
5838static void PressKeySequence(int argc, char *argv[]) 5838static void PressKeySequence(int argc, char *argv[])
5839{ 5839{
5840 int i,Length; 5840 int i,Length;
5841 GSM_KeyCodeKeyCode[500]; 5841 GSM_KeyCodeKeyCode[500];
5842 5842
5843 error = MakeKeySequence(argv[2], KeyCode, &Length); 5843 error = MakeKeySequence(argv[2], KeyCode, &Length);
5844 if (error == ERR_NOTSUPPORTED) { 5844 if (error == ERR_NOTSUPPORTED) {
5845 printmsg("Unknown key/function name: \"%c\"\n",argv[2][Length]); 5845 printmsg("Unknown key/function name: \"%c\"\n",argv[2][Length]);
5846 exit(-1); 5846 exit(-1);
5847 } 5847 }
5848 5848
5849 GSM_Init(true); 5849 GSM_Init(true);
5850 5850
5851 for (i=0;i<Length;i++) { 5851 for (i=0;i<Length;i++) {
5852 error=Phone->PressKey(&s, KeyCode[i], true); 5852 error=Phone->PressKey(&s, KeyCode[i], true);
5853 Print_Error(error); 5853 Print_Error(error);
5854 error=Phone->PressKey(&s, KeyCode[i], false); 5854 error=Phone->PressKey(&s, KeyCode[i], false);
5855 Print_Error(error); 5855 Print_Error(error);
5856 } 5856 }
5857 5857
5858 GSM_Terminate(); 5858 GSM_Terminate();
5859} 5859}
5860 5860
5861static void GetAllCategories(int argc, char *argv[]) 5861static void GetAllCategories(int argc, char *argv[])
5862{ 5862{
5863 GSM_Category Category; 5863 GSM_Category Category;
5864 GSM_CategoryStatusStatus; 5864 GSM_CategoryStatusStatus;
5865 int j, count; 5865 int j, count;
5866 5866
5867 if (mystrncasecmp(argv[2],"TODO",0)) { 5867 if (mystrncasecmp(argv[2],"TODO",0)) {
5868 Category.Type = Category_ToDo; 5868 Category.Type = Category_ToDo;
5869 Status.Type = Category_ToDo; 5869 Status.Type = Category_ToDo;
5870 } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) { 5870 } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) {
5871 Category.Type = Category_Phonebook; 5871 Category.Type = Category_Phonebook;
5872 Status.Type = Category_Phonebook; 5872 Status.Type = Category_Phonebook;
5873 } else { 5873 } else {
5874 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]); 5874 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]);
5875 exit(-1); 5875 exit(-1);
5876 } 5876 }
5877 5877
5878 GSM_Init(true); 5878 GSM_Init(true);
5879 5879
5880 error=Phone->GetCategoryStatus(&s, &Status); 5880 error=Phone->GetCategoryStatus(&s, &Status);
5881 Print_Error(error); 5881 Print_Error(error);
5882 5882
5883 for (count=0,j=1;count<Status.Used;j++) 5883 for (count=0,j=1;count<Status.Used;j++)
5884 { 5884 {
5885 Category.Location=j; 5885 Category.Location=j;
5886 error=Phone->GetCategory(&s, &Category); 5886 error=Phone->GetCategory(&s, &Category);
5887 5887
5888 if (error != ERR_EMPTY) { 5888 if (error != ERR_EMPTY) {
5889 printmsg("Location: %i\n",j); 5889 printmsg("Location: %i\n",j);
5890 5890
5891 Print_Error(error); 5891 Print_Error(error);
5892 5892
5893 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name)); 5893 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name));
5894 count++; 5894 count++;
5895 } 5895 }
5896 } 5896 }
5897 5897
5898 GSM_Terminate(); 5898 GSM_Terminate();
5899} 5899}
5900 5900
5901static void GetCategory(int argc, char *argv[]) 5901static void GetCategory(int argc, char *argv[])
5902{ 5902{
5903 GSM_CategoryCategory; 5903 GSM_CategoryCategory;
5904 int start,stop,j; 5904 int start,stop,j;
5905 5905
5906 if (mystrncasecmp(argv[2],"TODO",0)) { 5906 if (mystrncasecmp(argv[2],"TODO",0)) {
5907 Category.Type = Category_ToDo; 5907 Category.Type = Category_ToDo;
5908 } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) { 5908 } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) {
5909 Category.Type = Category_Phonebook; 5909 Category.Type = Category_Phonebook;
5910 } else { 5910 } else {
5911 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]); 5911 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]);
5912 exit(-1); 5912 exit(-1);
5913 } 5913 }
5914 5914
5915 GetStartStop(&start, &stop, 2, argc - 1, argv + 1); 5915 GetStartStop(&start, &stop, 2, argc - 1, argv + 1);
5916 5916
5917 GSM_Init(true); 5917 GSM_Init(true);
5918 5918
5919 for (j=start;j<=stop;j++) 5919 for (j=start;j<=stop;j++)
5920 { 5920 {
5921 printmsg("Location: %i\n",j); 5921 printmsg("Location: %i\n",j);
5922 5922
5923 Category.Location=j; 5923 Category.Location=j;
5924 5924
5925 error=Phone->GetCategory(&s, &Category); 5925 error=Phone->GetCategory(&s, &Category);
5926 if (error != ERR_EMPTY) Print_Error(error); 5926 if (error != ERR_EMPTY) Print_Error(error);
5927 5927
5928 if (error == ERR_EMPTY) { 5928 if (error == ERR_EMPTY) {
5929 printmsg("Entry is empty\n\n"); 5929 printmsg("Entry is empty\n\n");
5930 } else { 5930 } else {
5931 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name)); 5931 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name));
5932 } 5932 }
5933 } 5933 }
5934 5934
5935 GSM_Terminate(); 5935 GSM_Terminate();
5936} 5936}
5937 5937
5938static void DeleteToDo(int argc, char *argv[]) 5938static void DeleteToDo(int argc, char *argv[])
5939{ 5939{
5940 GSM_ToDoEntryToDo; 5940 GSM_ToDoEntryToDo;
5941 int i; 5941 int i;
5942 int start,stop; 5942 int start,stop;
5943 5943
5944 GetStartStop(&start, &stop, 2, argc, argv); 5944 GetStartStop(&start, &stop, 2, argc, argv);
5945 5945
5946 GSM_Init(true); 5946 GSM_Init(true);
5947 5947
5948 for (i=start;i<=stop;i++) { 5948 for (i=start;i<=stop;i++) {
5949 ToDo.Location=i; 5949 ToDo.Location=i;
5950 printmsg("Location : %i\n",i); 5950 printmsg("Location : %i\n",i);
5951 error=Phone->DeleteToDo(&s,&ToDo); 5951 error=Phone->DeleteToDo(&s,&ToDo);
5952 if (error != ERR_EMPTY) Print_Error(error); 5952 if (error != ERR_EMPTY) Print_Error(error);
5953 5953
5954 if (error == ERR_EMPTY) { 5954 if (error == ERR_EMPTY) {
5955 printmsg("Entry was empty\n"); 5955 printmsg("Entry was empty\n");
5956 } else { 5956 } else {
5957 printmsg("Entry was deleted\n"); 5957 printmsg("Entry was deleted\n");
5958 } 5958 }
5959 printf("\n"); 5959 printf("\n");
5960 } 5960 }
5961 5961
5962 GSM_Terminate(); 5962 GSM_Terminate();
5963} 5963}
5964 5964
5965static void PrintToDo(GSM_ToDoEntry *ToDo) 5965static void PrintToDo(GSM_ToDoEntry *ToDo)
5966{ 5966{
5967 int j; 5967 int j;
5968 GSM_MemoryEntry entry; 5968 GSM_MemoryEntry entry;
5969 unsigned char *name; 5969 unsigned char *name;
5970 GSM_Category Category; 5970 GSM_Category Category;
5971 5971
5972 printmsg("Location : %i\n",ToDo->Location); 5972 printmsg("Location : %i\n",ToDo->Location);
5973 printmsg("Priority : "); 5973 printmsg("Priority : ");
5974 switch (ToDo->Priority) { 5974 switch (ToDo->Priority) {
5975 case GSM_Priority_Low : printmsg("Low\n"); break; 5975 case GSM_Priority_Low : printmsg("Low\n"); break;
5976 case GSM_Priority_Medium : printmsg("Medium\n"); break; 5976 case GSM_Priority_Medium : printmsg("Medium\n"); break;
5977 case GSM_Priority_High : printmsg("High\n"); break; 5977 case GSM_Priority_High : printmsg("High\n"); break;
5978 default : printmsg("Unknown\n");break; 5978 default : printmsg("Unknown\n");break;
5979 } 5979 }
5980 for (j=0;j<ToDo->EntriesNum;j++) { 5980 for (j=0;j<ToDo->EntriesNum;j++) {
5981 switch (ToDo->Entries[j].EntryType) { 5981 switch (ToDo->Entries[j].EntryType) {
5982 case TODO_END_DATETIME: 5982 case TODO_END_DATETIME:
5983 printmsg("DueTime : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); 5983 printmsg("DueTime : %s\n",OSDateTime(ToDo->Entries[j].Date,false));
5984 break; 5984 break;
5985 case TODO_COMPLETED: 5985 case TODO_COMPLETED:
5986 printmsg("Completed : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No"); 5986 printmsg("Completed : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No");
5987 break; 5987 break;
5988 case TODO_ALARM_DATETIME: 5988 case TODO_ALARM_DATETIME:
5989 printmsg("Alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); 5989 printmsg("Alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false));
5990 break; 5990 break;
5991 case TODO_SILENT_ALARM_DATETIME: 5991 case TODO_SILENT_ALARM_DATETIME:
5992 printmsg("Silent alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); 5992 printmsg("Silent alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false));
5993 break; 5993 break;
5994 case TODO_TEXT: 5994 case TODO_TEXT:
5995 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); 5995 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
5996 break; 5996 break;
5997 case TODO_PRIVATE: 5997 case TODO_PRIVATE:
5998 printmsg("Private : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No"); 5998 printmsg("Private : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No");
5999 break; 5999 break;
6000 case TODO_CATEGORY: 6000 case TODO_CATEGORY:
6001 Category.Location = ToDo->Entries[j].Number; 6001 Category.Location = ToDo->Entries[j].Number;
6002 Category.Type = Category_ToDo; 6002 Category.Type = Category_ToDo;
6003 error=Phone->GetCategory(&s, &Category); 6003 error=Phone->GetCategory(&s, &Category);
6004 if (error == ERR_NONE) { 6004 if (error == ERR_NONE) {
6005 printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), ToDo->Entries[j].Number); 6005 printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), ToDo->Entries[j].Number);
6006 } else { 6006 } else {
6007 printmsg("Category : %i\n", ToDo->Entries[j].Number); 6007 printmsg("Category : %i\n", ToDo->Entries[j].Number);
6008 } 6008 }
6009 break; 6009 break;
6010 case TODO_CONTACTID: 6010 case TODO_CONTACTID:
6011 entry.Location = ToDo->Entries[j].Number; 6011 entry.Location = ToDo->Entries[j].Number;
6012 entry.MemoryType = MEM_ME; 6012 entry.MemoryType = MEM_ME;
6013 error=Phone->GetMemory(&s, &entry); 6013 error=Phone->GetMemory(&s, &entry);
6014 if (error == ERR_NONE) { 6014 if (error == ERR_NONE) {
6015 name = GSM_PhonebookGetEntryName(&entry); 6015 name = GSM_PhonebookGetEntryName(&entry);
6016 if (name != NULL) { 6016 if (name != NULL) {
6017 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); 6017 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number);
6018 } else { 6018 } else {
6019 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); 6019 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number);
6020 } 6020 }
6021 } else { 6021 } else {
6022 printmsg("Contact : %d\n",ToDo->Entries[j].Number); 6022 printmsg("Contact : %d\n",ToDo->Entries[j].Number);
6023 } 6023 }
6024 break; 6024 break;
6025 case TODO_PHONE: 6025 case TODO_PHONE:
6026 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); 6026 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
6027 break; 6027 break;
6028 } 6028 }
6029 } 6029 }
6030 printf("\n"); 6030 printf("\n");
6031} 6031}
6032 6032
6033static void ListToDoCategoryEntries(int Category) 6033static void ListToDoCategoryEntries(int Category)
6034{ 6034{
6035 GSM_ToDoEntry Entry; 6035 GSM_ToDoEntry Entry;
6036 bool start = true; 6036 bool start = true;
6037 int j; 6037 int j;
6038 6038
6039 while (!gshutdown) { 6039 while (!gshutdown) {
6040 error = Phone->GetNextToDo(&s, &Entry, start); 6040 error = Phone->GetNextToDo(&s, &Entry, start);
6041 if (error == ERR_EMPTY) break; 6041 if (error == ERR_EMPTY) break;
6042 Print_Error(error); 6042 Print_Error(error);
6043 for (j=0;j<Entry.EntriesNum;j++) { 6043 for (j=0;j<Entry.EntriesNum;j++) {
6044 if (Entry.Entries[j].EntryType == TODO_CATEGORY && Entry.Entries[j].Number == (unsigned int)Category) 6044 if (Entry.Entries[j].EntryType == TODO_CATEGORY && Entry.Entries[j].Number == (unsigned int)Category)
6045 PrintToDo(&Entry); 6045 PrintToDo(&Entry);
6046 } 6046 }
6047 start = false; 6047 start = false;
6048 } 6048 }
6049} 6049}
6050 6050
6051static void ListToDoCategory(int argc, char *argv[]) 6051static void ListToDoCategory(int argc, char *argv[])
6052{ 6052{
6053 GSM_Category Category; 6053 GSM_Category Category;
6054 GSM_CategoryStatusStatus; 6054 GSM_CategoryStatusStatus;
6055 int j, count; 6055 int j, count;
6056 6056
6057 unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2]; 6057 unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2];
6058 int Length; 6058 int Length;
6059 bool Number = true;; 6059 bool Number = true;;
6060 6060
6061 GSM_Init(true); 6061 GSM_Init(true);
6062 6062
6063 signal(SIGINT, interrupt); 6063 signal(SIGINT, interrupt);
6064 printmsgerr("Press Ctrl+C to break...\n"); 6064 printmsgerr("Press Ctrl+C to break...\n");
6065 6065
6066 Length = strlen(argv[2]); 6066 Length = strlen(argv[2]);
6067 for (j = 0; j < Length; j++) { 6067 for (j = 0; j < Length; j++) {
6068 if (!isdigit(argv[2][j])) { 6068 if (!isdigit(argv[2][j])) {
6069 Number = false; 6069 Number = false;
6070 break; 6070 break;
6071 } 6071 }
6072 } 6072 }
6073 6073
6074 if (Number) { 6074 if (Number) {
6075 j = atoi(argv[2]); 6075 j = atoi(argv[2]);
6076 if (j > 0) { 6076 if (j > 0) {
6077 ListToDoCategoryEntries(j); 6077 ListToDoCategoryEntries(j);
6078 } 6078 }
6079 } else { 6079 } else {
6080 if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) { 6080 if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) {
6081 printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH); 6081 printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH);
6082 Length = GSM_MAX_CATEGORY_NAME_LENGTH; 6082 Length = GSM_MAX_CATEGORY_NAME_LENGTH;
6083 } 6083 }
6084 EncodeUnicode(Text, argv[2], Length); 6084 EncodeUnicode(Text, argv[2], Length);
6085 6085
6086 Category.Type = Category_ToDo; 6086 Category.Type = Category_ToDo;
6087 Status.Type = Category_ToDo; 6087 Status.Type = Category_ToDo;
6088 6088
6089 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) { 6089 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) {
6090 for (count=0,j=1;count<Status.Used;j++) { 6090 for (count=0,j=1;count<Status.Used;j++) {
6091 Category.Location=j; 6091 Category.Location=j;
6092 error=Phone->GetCategory(&s, &Category); 6092 error=Phone->GetCategory(&s, &Category);
6093 6093
6094 if (error != ERR_EMPTY) { 6094 if (error != ERR_EMPTY) {
6095 count++; 6095 count++;
6096 if (mystrstr(Category.Name, Text) != NULL) { 6096 if (mystrstr(Category.Name, Text) != NULL) {
6097 ListToDoCategoryEntries(j); 6097 ListToDoCategoryEntries(j);
6098 } 6098 }
6099 } 6099 }
6100 } 6100 }
6101 } 6101 }
6102 } 6102 }
6103 GSM_Terminate(); 6103 GSM_Terminate();
6104} 6104}
6105 6105
6106 6106
6107static void GetToDo(int argc, char *argv[]) 6107static void GetToDo(int argc, char *argv[])
6108{ 6108{
6109 GSM_ToDoEntryToDo; 6109 GSM_ToDoEntryToDo;
6110 int i; 6110 int i;
6111 int start,stop; 6111 int start,stop;
6112 6112
6113 GetStartStop(&start, &stop, 2, argc, argv); 6113 GetStartStop(&start, &stop, 2, argc, argv);
6114 6114
6115 GSM_Init(true); 6115 GSM_Init(true);
6116 6116
6117 for (i=start;i<=stop;i++) { 6117 for (i=start;i<=stop;i++) {
6118 ToDo.Location=i; 6118 ToDo.Location=i;
6119 error = Phone->GetToDo(&s,&ToDo); 6119 error = Phone->GetToDo(&s,&ToDo);
6120 if (error == ERR_EMPTY) continue; 6120 if (error == ERR_EMPTY) continue;
6121 Print_Error(error); 6121 Print_Error(error);
6122 PrintToDo(&ToDo); 6122 PrintToDo(&ToDo);
6123 } 6123 }
6124 6124
6125 GSM_Terminate(); 6125 GSM_Terminate();
6126} 6126}
6127 6127
6128static void GetAllToDo(int argc, char *argv[]) 6128static void GetAllToDo(int argc, char *argv[])
6129{ 6129{
6130 GSM_ToDoEntry ToDo; 6130 GSM_ToDoEntry ToDo;
6131 bool start = true; 6131 bool start = true;
6132 6132
6133 signal(SIGINT, interrupt); 6133 signal(SIGINT, interrupt);
6134 printmsgerr("Press Ctrl+C to break...\n"); 6134 printmsgerr("Press Ctrl+C to break...\n");
6135 6135
6136 GSM_Init(true); 6136 GSM_Init(true);
6137 6137
6138 while (!gshutdown) { 6138 while (!gshutdown) {
6139 error = Phone->GetNextToDo(&s, &ToDo, start); 6139 error = Phone->GetNextToDo(&s, &ToDo, start);
6140 if (error == ERR_EMPTY) break; 6140 if (error == ERR_EMPTY) break;
6141 Print_Error(error); 6141 Print_Error(error);
6142 PrintToDo(&ToDo); 6142 PrintToDo(&ToDo);
6143 start = false; 6143 start = false;
6144 } 6144 }
6145 6145
6146 GSM_Terminate(); 6146 GSM_Terminate();
6147} 6147}
6148 6148
6149static void GetNote(int argc, char *argv[]) 6149static void GetNote(int argc, char *argv[])
6150{ 6150{
6151 GSM_NoteEntry Note; 6151 GSM_NoteEntry Note;
6152 int start,stop; 6152 int start,stop;
6153 bool refresh=true; 6153 bool refresh=true;
6154 6154
6155 GetStartStop(&start, &stop, 2, argc, argv); 6155 GetStartStop(&start, &stop, 2, argc, argv);
6156 6156
6157 GSM_Init(true); 6157 GSM_Init(true);
6158 6158
6159 for (i=start;i<=stop;i++) { 6159 for (i=start;i<=stop;i++) {
6160 Note.Location=i; 6160 Note.Location=i;
6161 printmsg("Location : %i\n",i); 6161 printmsg("Location : %i\n",i);
6162 error=Phone->GetNote(&s,&Note,refresh); 6162 error=Phone->GetNote(&s,&Note,refresh);
6163 if (error != ERR_EMPTY) Print_Error(error); 6163 if (error != ERR_EMPTY) Print_Error(error);
6164 6164
6165 if (error == ERR_EMPTY) { 6165 if (error == ERR_EMPTY) {
6166 printmsg("Entry is empty\n\n"); 6166 printmsg("Entry is empty\n\n");
6167 } else { 6167 } else {
6168 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note.Text)); 6168 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note.Text));
6169 printf("\n"); 6169 printf("\n");
6170 refresh=false; 6170 refresh=false;
6171 } 6171 }
6172 } 6172 }
6173 6173
6174 GSM_Terminate(); 6174 GSM_Terminate();
6175} 6175}
6176 6176
6177static void GetSecurityStatus(int argc, char *argv[]) 6177static void GetSecurityStatus(int argc, char *argv[])
6178{ 6178{
6179 GSM_Init(true); 6179 GSM_Init(true);
6180 6180
6181 PrintSecurityStatus(); 6181 PrintSecurityStatus();
6182 6182
6183 GSM_Terminate(); 6183 GSM_Terminate();
6184} 6184}
6185 6185
6186static void EnterSecurityCode(int argc, char *argv[]) 6186static void EnterSecurityCode(int argc, char *argv[])
6187{ 6187{
6188 GSM_SecurityCode Code; 6188 GSM_SecurityCode Code;
6189 6189
6190 if (mystrncasecmp(argv[2],"PIN",0)) { Code.Type = SEC_Pin; 6190 if (mystrncasecmp(argv[2],"PIN",0)) { Code.Type = SEC_Pin;
6191 } else if (mystrncasecmp(argv[2],"PUK",0)) {Code.Type = SEC_Puk; 6191 } else if (mystrncasecmp(argv[2],"PUK",0)) {Code.Type = SEC_Puk;
6192 } else if (mystrncasecmp(argv[2],"PIN2",0)) {Code.Type = SEC_Pin2; 6192 } else if (mystrncasecmp(argv[2],"PIN2",0)) {Code.Type = SEC_Pin2;
6193 } else if (mystrncasecmp(argv[2],"PUK2",0)) {Code.Type = SEC_Puk2; 6193 } else if (mystrncasecmp(argv[2],"PUK2",0)) {Code.Type = SEC_Puk2;
6194 } else { 6194 } else {
6195 printmsg("What security code (\"%s\") ?\n",argv[2]); 6195 printmsg("What security code (\"%s\") ?\n",argv[2]);
6196 exit(-1); 6196 exit(-1);
6197 } 6197 }
6198 6198
6199 strcpy(Code.Code,argv[3]); 6199 strcpy(Code.Code,argv[3]);
6200 6200
6201 GSM_Init(true); 6201 GSM_Init(true);
6202 6202
6203 error=Phone->EnterSecurityCode(&s,Code); 6203 error=Phone->EnterSecurityCode(&s,Code);
6204 Print_Error(error); 6204 Print_Error(error);
6205 6205
6206 GSM_Terminate(); 6206 GSM_Terminate();
6207} 6207}
6208 6208
6209static void GetProfile(int argc, char *argv[]) 6209static void GetProfile(int argc, char *argv[])
6210{ 6210{
6211 GSM_Profile Profile; 6211 GSM_Profile Profile;
6212 int start,stop,j,k; 6212 int start,stop,j,k;
6213 GSM_Bitmap caller[5]; 6213 GSM_Bitmap caller[5];
6214 bool callerinit[5],special; 6214 bool callerinit[5],special;
6215 GSM_AllRingtonesInfo Info; 6215 GSM_AllRingtonesInfo Info;
6216 6216
6217 GetStartStop(&start, &stop, 2, argc, argv); 6217 GetStartStop(&start, &stop, 2, argc, argv);
6218 6218
6219 for (i=0;i<5;i++) callerinit[i] = false; 6219 for (i=0;i<5;i++) callerinit[i] = false;
6220 6220
6221 GSM_Init(true); 6221 GSM_Init(true);
6222 6222
6223 error=Phone->GetRingtonesInfo(&s,&Info); 6223 error=Phone->GetRingtonesInfo(&s,&Info);
6224 if (error != ERR_NONE) Info.Number = 0; 6224 if (error != ERR_NONE) Info.Number = 0;
6225 6225
6226 for (i=start;i<=stop;i++) { 6226 for (i=start;i<=stop;i++) {
6227 Profile.Location=i; 6227 Profile.Location=i;
6228 error=Phone->GetProfile(&s,&Profile); 6228 error=Phone->GetProfile(&s,&Profile);
6229 Print_Error(error); 6229 Print_Error(error);
6230 6230
6231 printmsg("%i. \"%s\"",i,DecodeUnicodeConsole(Profile.Name)); 6231 printmsg("%i. \"%s\"",i,DecodeUnicodeConsole(Profile.Name));
6232 if (Profile.Active) printmsg(" (active)"); 6232 if (Profile.Active) printmsg(" (active)");
6233 if (Profile.DefaultName) printmsg(" (default name)"); 6233 if (Profile.DefaultName) printmsg(" (default name)");
6234 if (Profile.HeadSetProfile) printmsg(" (HeadSet profile)"); 6234 if (Profile.HeadSetProfile) printmsg(" (HeadSet profile)");
6235 if (Profile.CarKitProfile) printmsg(" (CarKit profile)"); 6235 if (Profile.CarKitProfile) printmsg(" (CarKit profile)");
6236 printf("\n"); 6236 printf("\n");
6237 for (j=0;j<Profile.FeaturesNumber;j++) { 6237 for (j=0;j<Profile.FeaturesNumber;j++) {
6238 special = false; 6238 special = false;
6239 switch (Profile.FeatureID[j]) { 6239 switch (Profile.FeatureID[j]) {
6240 case Profile_MessageToneID: 6240 case Profile_MessageToneID:
6241 case Profile_RingtoneID: 6241 case Profile_RingtoneID:
6242 special = true; 6242 special = true;
6243 if (Profile.FeatureID[j] == Profile_RingtoneID) { 6243 if (Profile.FeatureID[j] == Profile_RingtoneID) {
6244 printmsg("Ringtone ID : "); 6244 printmsg("Ringtone ID : ");
6245 } else { 6245 } else {
6246 printmsg("Message alert tone ID : "); 6246 printmsg("Message alert tone ID : ");
6247 } 6247 }
6248 if (UnicodeLength(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))!=0) { 6248 if (UnicodeLength(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))!=0) {
6249 printmsg("\"%s\"\n",DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))); 6249 printmsg("\"%s\"\n",DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j])));
6250 } else { 6250 } else {
6251 printmsg("%i\n",Profile.FeatureValue[j]); 6251 printmsg("%i\n",Profile.FeatureValue[j]);
6252 } 6252 }
6253 break; 6253 break;
6254 case Profile_CallerGroups: 6254 case Profile_CallerGroups:
6255 special = true; 6255 special = true;
6256 printmsg("Call alert for :"); 6256 printmsg("Call alert for :");
6257 for (k=0;k<5;k++) { 6257 for (k=0;k<5;k++) {
6258 if (Profile.CallerGroups[k]) { 6258 if (Profile.CallerGroups[k]) {
6259 if (!callerinit[k]) { 6259 if (!callerinit[k]) {
6260 caller[k].Type = GSM_CallerGroupLogo; 6260 caller[k].Type = GSM_CallerGroupLogo;
6261 caller[k].Location = k + 1; 6261 caller[k].Location = k + 1;
6262 error=Phone->GetBitmap(&s,&caller[k]); 6262 error=Phone->GetBitmap(&s,&caller[k]);
6263 if (error == ERR_SECURITYERROR) { 6263 if (error == ERR_SECURITYERROR) {
6264 NOKIA_GetDefaultCallerGroupName(&s,&caller[k]); 6264 NOKIA_GetDefaultCallerGroupName(&s,&caller[k]);
6265 } else { 6265 } else {
6266 Print_Error(error); 6266 Print_Error(error);
6267 } 6267 }
6268 callerinit[k]= true; 6268 callerinit[k]= true;
6269 } 6269 }
6270 printmsg(" \"%s\"",DecodeUnicodeConsole(caller[k].Text)); 6270 printmsg(" \"%s\"",DecodeUnicodeConsole(caller[k].Text));
6271 } 6271 }
6272 } 6272 }
6273 printf("\n"); 6273 printf("\n");
6274 break; 6274 break;
6275 case Profile_ScreenSaverNumber: 6275 case Profile_ScreenSaverNumber:
6276 special = true; 6276 special = true;
6277 printmsg("Screen saver number : "); 6277 printmsg("Screen saver number : ");
6278 printmsg("%i\n",Profile.FeatureValue[j]); 6278 printmsg("%i\n",Profile.FeatureValue[j]);
6279 break; 6279 break;
6280 case Profile_CallAlert : printmsg("Incoming call alert : "); break; 6280 case Profile_CallAlert : printmsg("Incoming call alert : "); break;
6281 case Profile_RingtoneVolume : printmsg("Ringtone volume : "); break; 6281 case Profile_RingtoneVolume : printmsg("Ringtone volume : "); break;
6282 case Profile_Vibration : printmsg("Vibrating alert : "); break; 6282 case Profile_Vibration : printmsg("Vibrating alert : "); break;
6283 case Profile_MessageTone: printmsg("Message alert tone : "); break; 6283 case Profile_MessageTone: printmsg("Message alert tone : "); break;
6284 case Profile_KeypadTone : printmsg("Keypad tones : "); break; 6284 case Profile_KeypadTone : printmsg("Keypad tones : "); break;
6285 case Profile_WarningTone: printmsg("Warning (games) tones : "); break; 6285 case Profile_WarningTone: printmsg("Warning (games) tones : "); break;
6286 case Profile_ScreenSaver: printmsg("Screen saver : "); break; 6286 case Profile_ScreenSaver: printmsg("Screen saver : "); break;
6287 case Profile_ScreenSaverTime: printmsg("Screen saver timeout : "); break; 6287 case Profile_ScreenSaverTime: printmsg("Screen saver timeout : "); break;
6288 case Profile_AutoAnswer : printmsg("Automatic answer : "); break; 6288 case Profile_AutoAnswer : printmsg("Automatic answer : "); break;
6289 case Profile_Lights : printmsg("Lights : "); break; 6289 case Profile_Lights : printmsg("Lights : "); break;
6290 default: 6290 default:
6291 printmsg("Unknown\n"); 6291 printmsg("Unknown\n");
6292 special = true; 6292 special = true;
6293 } 6293 }
6294 if (!special) { 6294 if (!special) {
6295 switch (Profile.FeatureValue[j]) { 6295 switch (Profile.FeatureValue[j]) {
6296 case PROFILE_VOLUME_LEVEL1 : 6296 case PROFILE_VOLUME_LEVEL1 :
6297 case PROFILE_KEYPAD_LEVEL1 : printmsg("Level 1\n"); break; 6297 case PROFILE_KEYPAD_LEVEL1 : printmsg("Level 1\n"); break;
6298 case PROFILE_VOLUME_LEVEL2 : 6298 case PROFILE_VOLUME_LEVEL2 :
6299 case PROFILE_KEYPAD_LEVEL2 : printmsg("Level 2\n"); break; 6299 case PROFILE_KEYPAD_LEVEL2 : printmsg("Level 2\n"); break;
6300 case PROFILE_VOLUME_LEVEL3 : 6300 case PROFILE_VOLUME_LEVEL3 :
6301 case PROFILE_KEYPAD_LEVEL3 : printmsg("Level 3\n"); break; 6301 case PROFILE_KEYPAD_LEVEL3 : printmsg("Level 3\n"); break;
6302 case PROFILE_VOLUME_LEVEL4 : printmsg("Level 4\n"); break; 6302 case PROFILE_VOLUME_LEVEL4 : printmsg("Level 4\n"); break;
6303 case PROFILE_VOLUME_LEVEL5 : printmsg("Level 5\n"); break; 6303 case PROFILE_VOLUME_LEVEL5 : printmsg("Level 5\n"); break;
6304 case PROFILE_MESSAGE_NOTONE : 6304 case PROFILE_MESSAGE_NOTONE :
6305 case PROFILE_AUTOANSWER_OFF : 6305 case PROFILE_AUTOANSWER_OFF :
6306 case PROFILE_LIGHTS_OFF : 6306 case PROFILE_LIGHTS_OFF :
6307 case PROFILE_SAVER_OFF : 6307 case PROFILE_SAVER_OFF :
6308 case PROFILE_WARNING_OFF : 6308 case PROFILE_WARNING_OFF :
6309 case PROFILE_CALLALERT_OFF : 6309 case PROFILE_CALLALERT_OFF :
6310 case PROFILE_VIBRATION_OFF : 6310 case PROFILE_VIBRATION_OFF :
6311 case PROFILE_KEYPAD_OFF : printmsg("Off\n"); break; 6311 case PROFILE_KEYPAD_OFF : printmsg("Off\n"); break;
6312 case PROFILE_CALLALERT_RINGING : printmsg("Ringing\n"); break; 6312 case PROFILE_CALLALERT_RINGING : printmsg("Ringing\n"); break;
6313 case PROFILE_CALLALERT_BEEPONCE : 6313 case PROFILE_CALLALERT_BEEPONCE :
6314 case PROFILE_MESSAGE_BEEPONCE : printmsg("Beep once\n"); break; 6314 case PROFILE_MESSAGE_BEEPONCE : printmsg("Beep once\n"); break;
6315 case PROFILE_CALLALERT_RINGONCE : printmsg("Ring once\n");break; 6315 case PROFILE_CALLALERT_RINGONCE : printmsg("Ring once\n");break;
6316 case PROFILE_CALLALERT_ASCENDING : printmsg("Ascending\n"); break; 6316 case PROFILE_CALLALERT_ASCENDING : printmsg("Ascending\n"); break;
6317 case PROFILE_CALLALERT_CALLERGROUPS : printmsg("Caller groups\n");break; 6317 case PROFILE_CALLALERT_CALLERGROUPS : printmsg("Caller groups\n");break;
6318 case PROFILE_MESSAGE_STANDARD : printmsg("Standard\n"); break; 6318 case PROFILE_MESSAGE_STANDARD : printmsg("Standard\n"); break;
6319 case PROFILE_MESSAGE_SPECIAL : printmsg("Special\n"); break; 6319 case PROFILE_MESSAGE_SPECIAL : printmsg("Special\n"); break;
6320 case PROFILE_MESSAGE_ASCENDING : printmsg("Ascending\n"); break; 6320 case PROFILE_MESSAGE_ASCENDING : printmsg("Ascending\n"); break;
6321 case PROFILE_MESSAGE_PERSONAL : printmsg("Personal\n"); break; 6321 case PROFILE_MESSAGE_PERSONAL : printmsg("Personal\n"); break;
6322 case PROFILE_AUTOANSWER_ON : 6322 case PROFILE_AUTOANSWER_ON :
6323 case PROFILE_WARNING_ON : 6323 case PROFILE_WARNING_ON :
6324 case PROFILE_SAVER_ON : 6324 case PROFILE_SAVER_ON :
6325 case PROFILE_VIBRATION_ON : printmsg("On\n"); break; 6325 case PROFILE_VIBRATION_ON : printmsg("On\n"); break;
6326 case PROFILE_VIBRATION_FIRST : printmsg("Vibrate first\n");break; 6326 case PROFILE_VIBRATION_FIRST : printmsg("Vibrate first\n");break;
6327 case PROFILE_LIGHTS_AUTO : printmsg("Auto\n"); break; 6327 case PROFILE_LIGHTS_AUTO : printmsg("Auto\n"); break;
6328 case PROFILE_SAVER_TIMEOUT_5SEC : printmsg("5 seconds\n"); break; 6328 case PROFILE_SAVER_TIMEOUT_5SEC : printmsg("5 seconds\n"); break;
6329 case PROFILE_SAVER_TIMEOUT_20SEC : printmsg("20 seconds\n"); break; 6329 case PROFILE_SAVER_TIMEOUT_20SEC : printmsg("20 seconds\n"); break;
6330 case PROFILE_SAVER_TIMEOUT_1MIN : printmsg("1 minute\n"); break; 6330 case PROFILE_SAVER_TIMEOUT_1MIN : printmsg("1 minute\n"); break;
6331 case PROFILE_SAVER_TIMEOUT_2MIN : printmsg("2 minutes\n");break; 6331 case PROFILE_SAVER_TIMEOUT_2MIN : printmsg("2 minutes\n");break;
6332 case PROFILE_SAVER_TIMEOUT_5MIN : printmsg("5 minutes\n");break; 6332 case PROFILE_SAVER_TIMEOUT_5MIN : printmsg("5 minutes\n");break;
6333 case PROFILE_SAVER_TIMEOUT_10MIN : printmsg("10 minutes\n");break; 6333 case PROFILE_SAVER_TIMEOUT_10MIN : printmsg("10 minutes\n");break;
6334 default : printmsg("UNKNOWN\n"); 6334 default : printmsg("UNKNOWN\n");
6335 } 6335 }
6336 } 6336 }
6337 } 6337 }
6338 printf("\n"); 6338 printf("\n");
6339 } 6339 }
6340 6340
6341 GSM_Terminate(); 6341 GSM_Terminate();
6342} 6342}
6343 6343
6344static void GetSpeedDial(int argc, char *argv[]) 6344static void GetSpeedDial(int argc, char *argv[])
6345{ 6345{
6346 GSM_SpeedDial SpeedDial; 6346 GSM_SpeedDial SpeedDial;
6347 GSM_MemoryEntry Phonebook; 6347 GSM_MemoryEntry Phonebook;
6348 int start,stop,Name,Number,Group; 6348 int start,stop,Name,Number,Group;
6349 6349
6350 GetStartStop(&start, &stop, 2, argc, argv); 6350 GetStartStop(&start, &stop, 2, argc, argv);
6351 6351
6352 GSM_Init(true); 6352 GSM_Init(true);
6353 6353
6354 for (i=start;i<=stop;i++) { 6354 for (i=start;i<=stop;i++) {
6355 SpeedDial.Location=i; 6355 SpeedDial.Location=i;
6356 error=Phone->GetSpeedDial(&s,&SpeedDial); 6356 error=Phone->GetSpeedDial(&s,&SpeedDial);
6357 printmsg("%i.",i); 6357 printmsg("%i.",i);
6358 switch (error) { 6358 switch (error) {
6359 case ERR_EMPTY: 6359 case ERR_EMPTY:
6360 printmsg(" speed dial not assigned\n"); 6360 printmsg(" speed dial not assigned\n");
6361 break; 6361 break;
6362 default: 6362 default:
6363 Print_Error(error); 6363 Print_Error(error);
6364 6364
6365 Phonebook.Location= SpeedDial.MemoryLocation; 6365 Phonebook.Location= SpeedDial.MemoryLocation;
6366 Phonebook.MemoryType = SpeedDial.MemoryType; 6366 Phonebook.MemoryType = SpeedDial.MemoryType;
6367 error=Phone->GetMemory(&s,&Phonebook); 6367 error=Phone->GetMemory(&s,&Phonebook);
6368 6368
6369 GSM_PhonebookFindDefaultNameNumberGroup(&Phonebook, &Name, &Number, &Group); 6369 GSM_PhonebookFindDefaultNameNumberGroup(&Phonebook, &Name, &Number, &Group);
6370 6370
6371 if (Name != -1) printmsg(" Name \"%s\",",DecodeUnicodeConsole(Phonebook.Entries[Name].Text)); 6371 if (Name != -1) printmsg(" Name \"%s\",",DecodeUnicodeConsole(Phonebook.Entries[Name].Text));
6372 printmsg(" Number \"%s\"",DecodeUnicodeConsole(Phonebook.Entries[SpeedDial.MemoryNumberID-1].Text)); 6372 printmsg(" Number \"%s\"",DecodeUnicodeConsole(Phonebook.Entries[SpeedDial.MemoryNumberID-1].Text));
6373 } 6373 }
6374 printf("\n"); 6374 printf("\n");
6375 } 6375 }
6376 6376
6377 GSM_Terminate(); 6377 GSM_Terminate();
6378} 6378}
6379 6379
6380static void ResetPhoneSettings(int argc, char *argv[]) 6380static void ResetPhoneSettings(int argc, char *argv[])
6381{ 6381{
6382 GSM_ResetSettingsType Type; 6382 GSM_ResetSettingsType Type;
6383 6383
6384 if (mystrncasecmp(argv[2],"PHONE",0)) { Type = GSM_RESET_PHONESETTINGS; 6384 if (mystrncasecmp(argv[2],"PHONE",0)) { Type = GSM_RESET_PHONESETTINGS;
6385 } else if (mystrncasecmp(argv[2],"UIF",0)) { Type = GSM_RESET_USERINTERFACE; 6385 } else if (mystrncasecmp(argv[2],"UIF",0)) { Type = GSM_RESET_USERINTERFACE;
6386 } else if (mystrncasecmp(argv[2],"ALL",0)) { Type = GSM_RESET_USERINTERFACE_PHONESETTINGS; 6386 } else if (mystrncasecmp(argv[2],"ALL",0)) { Type = GSM_RESET_USERINTERFACE_PHONESETTINGS;
6387 } else if (mystrncasecmp(argv[2],"DEV",0)) { Type = GSM_RESET_DEVICE; 6387 } else if (mystrncasecmp(argv[2],"DEV",0)) { Type = GSM_RESET_DEVICE;
6388 } else if (mystrncasecmp(argv[2],"FACTORY",0)) { Type = GSM_RESET_FULLFACTORY; 6388 } else if (mystrncasecmp(argv[2],"FACTORY",0)) { Type = GSM_RESET_FULLFACTORY;
6389 } else { 6389 } else {
6390 printmsg("What type of reset phone settings (\"%s\") ?\n",argv[2]); 6390 printmsg("What type of reset phone settings (\"%s\") ?\n",argv[2]);
6391 exit(-1); 6391 exit(-1);
6392 } 6392 }
6393 6393
6394 GSM_Init(true); 6394 GSM_Init(true);
6395 6395
6396 error=Phone->ResetPhoneSettings(&s,Type); 6396 error=Phone->ResetPhoneSettings(&s,Type);
6397 Print_Error(error); 6397 Print_Error(error);
6398 6398
6399 GSM_Terminate(); 6399 GSM_Terminate();
6400} 6400}
6401 6401
6402#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) 6402#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
6403static void NokiaSecurityCode(int argc, char *argv[]) 6403static void NokiaSecurityCode(int argc, char *argv[])
6404{ 6404{
6405 GSM_Init(true); 6405 GSM_Init(true);
6406 6406
6407#ifdef GSM_ENABLE_NOKIA_DCT3 6407#ifdef GSM_ENABLE_NOKIA_DCT3
6408 DCT3GetSecurityCode(argc,argv); 6408 DCT3GetSecurityCode(argc,argv);
6409#endif 6409#endif
6410#ifdef GSM_ENABLE_NOKIA_DCT4 6410#ifdef GSM_ENABLE_NOKIA_DCT4
6411 //DCT4ResetSecurityCode(argc, argv); 6411 //DCT4ResetSecurityCode(argc, argv);
6412 DCT4GetSecurityCode(argc,argv); 6412 DCT4GetSecurityCode(argc,argv);
6413#endif 6413#endif
6414 6414
6415 GSM_Terminate(); 6415 GSM_Terminate();
6416} 6416}
6417 6417
6418static void NokiaSetPhoneMenus(int argc, char *argv[]) 6418static void NokiaSetPhoneMenus(int argc, char *argv[])
6419{ 6419{
6420 GSM_Init(true); 6420 GSM_Init(true);
6421 6421
6422#ifdef GSM_ENABLE_NOKIA_DCT3 6422#ifdef GSM_ENABLE_NOKIA_DCT3
6423 DCT3SetPhoneMenus (argc, argv); 6423 DCT3SetPhoneMenus (argc, argv);
6424#endif 6424#endif
6425#ifdef GSM_ENABLE_NOKIA_DCT4 6425#ifdef GSM_ENABLE_NOKIA_DCT4
6426 DCT4SetPhoneMenus (argc, argv); 6426 DCT4SetPhoneMenus (argc, argv);
6427#endif 6427#endif
6428 6428
6429 GSM_Terminate(); 6429 GSM_Terminate();
6430} 6430}
6431 6431
6432static void NokiaSelfTests(int argc, char *argv[]) 6432static void NokiaSelfTests(int argc, char *argv[])
6433{ 6433{
6434 GSM_Init(true); 6434 GSM_Init(true);
6435 6435
6436#ifdef GSM_ENABLE_NOKIA_DCT3 6436#ifdef GSM_ENABLE_NOKIA_DCT3
6437 DCT3SelfTests(argc, argv); 6437 DCT3SelfTests(argc, argv);
6438#endif 6438#endif
6439#ifdef GSM_ENABLE_NOKIA_DCT4 6439#ifdef GSM_ENABLE_NOKIA_DCT4
6440 DCT4SelfTests(argc, argv); 6440 DCT4SelfTests(argc, argv);
6441#endif 6441#endif
6442 6442
6443 GSM_Terminate(); 6443 GSM_Terminate();
6444} 6444}
6445#endif 6445#endif
6446 6446
6447static void DeleteAllSMS(int argc, char *argv[]) 6447static void DeleteAllSMS(int argc, char *argv[])
6448{ 6448{
6449 GSM_MultiSMSMessage sms; 6449 GSM_MultiSMSMessage sms;
6450 GSM_SMSFolders folders; 6450 GSM_SMSFolders folders;
6451 int foldernum; 6451 int foldernum;
6452 bool start = true; 6452 bool start = true;
6453 6453
6454 GSM_Init(true); 6454 GSM_Init(true);
6455 6455
6456 error=Phone->GetSMSFolders(&s, &folders); 6456 error=Phone->GetSMSFolders(&s, &folders);
6457 Print_Error(error); 6457 Print_Error(error);
6458 6458
6459 GetStartStop(&foldernum, NULL, 2, argc, argv); 6459 GetStartStop(&foldernum, NULL, 2, argc, argv);
6460 if (foldernum > folders.Number) { 6460 if (foldernum > folders.Number) {
6461 printmsg("Too high folder number (max. %i)\n",folders.Number); 6461 printmsg("Too high folder number (max. %i)\n",folders.Number);
6462 GSM_Terminate(); 6462 GSM_Terminate();
6463 exit(-1); 6463 exit(-1);
6464 } 6464 }
6465 6465
6466 printmsg("Deleting SMS from \"%s\" folder: ",DecodeUnicodeConsole(folders.Folder[foldernum-1].Name)); 6466 printmsg("Deleting SMS from \"%s\" folder: ",DecodeUnicodeConsole(folders.Folder[foldernum-1].Name));
6467 6467
6468 while (error == ERR_NONE) { 6468 while (error == ERR_NONE) {
6469 sms.SMS[0].Folder=0x00; 6469 sms.SMS[0].Folder=0x00;
6470 error=Phone->GetNextSMS(&s, &sms, start); 6470 error=Phone->GetNextSMS(&s, &sms, start);
6471 switch (error) { 6471 switch (error) {
6472 case ERR_EMPTY: 6472 case ERR_EMPTY:
6473 break; 6473 break;
6474 default: 6474 default:
6475 Print_Error(error); 6475 Print_Error(error);
6476 if (sms.SMS[0].Folder == foldernum) { 6476 if (sms.SMS[0].Folder == foldernum) {
6477 sms.SMS[0].Folder=0x00; 6477 sms.SMS[0].Folder=0x00;
6478 error=Phone->DeleteSMS(&s, &sms.SMS[0]); 6478 error=Phone->DeleteSMS(&s, &sms.SMS[0]);
6479 Print_Error(error); 6479 Print_Error(error);
6480 printmsg("*"); 6480 printmsg("*");
6481 } 6481 }
6482 } 6482 }
6483 start=false; 6483 start=false;
6484 } 6484 }
6485 6485
6486 printf("\n"); 6486 printf("\n");
6487 6487
6488 GSM_Terminate(); 6488 GSM_Terminate();
6489} 6489}
6490 6490
6491static void SendDTMF(int argc, char *argv[]) 6491static void SendDTMF(int argc, char *argv[])
6492{ 6492{
6493 GSM_Init(true); 6493 GSM_Init(true);
6494 6494
6495 error=Phone->SendDTMF(&s,argv[2]); 6495 error=Phone->SendDTMF(&s,argv[2]);
6496 Print_Error(error); 6496 Print_Error(error);
6497 6497
6498 GSM_Terminate(); 6498 GSM_Terminate();
6499} 6499}
6500 6500
6501static void GetDisplayStatus(int argc, char *argv[]) 6501static void GetDisplayStatus(int argc, char *argv[])
6502{ 6502{
6503 GSM_DisplayFeatures Features; 6503 GSM_DisplayFeatures Features;
6504 int i; 6504 int i;
6505 6505
6506 GSM_Init(true); 6506 GSM_Init(true);
6507 6507
6508 error=Phone->GetDisplayStatus(&s,&Features); 6508 error=Phone->GetDisplayStatus(&s,&Features);
6509 Print_Error(error); 6509 Print_Error(error);
6510 6510
6511 printmsg("Current display features :\n"); 6511 printmsg("Current display features :\n");
6512 6512
6513 for (i=0;i<Features.Number;i++) { 6513 for (i=0;i<Features.Number;i++) {
6514 switch(Features.Feature[i]) { 6514 switch(Features.Feature[i]) {
6515 case GSM_CallActive : printmsg("Call active\n");break; 6515 case GSM_CallActive : printmsg("Call active\n");break;
6516 case GSM_UnreadSMS : printmsg("Unread SMS\n");break; 6516 case GSM_UnreadSMS : printmsg("Unread SMS\n");break;
6517 case GSM_VoiceCall : printmsg("Voice call\n");break; 6517 case GSM_VoiceCall : printmsg("Voice call\n");break;
6518 case GSM_FaxCall : printmsg("Fax call\n");break; 6518 case GSM_FaxCall : printmsg("Fax call\n");break;
6519 case GSM_DataCall : printmsg("Data call\n");break; 6519 case GSM_DataCall : printmsg("Data call\n");break;
6520 case GSM_KeypadLocked : printmsg("Keypad locked\n");break; 6520 case GSM_KeypadLocked : printmsg("Keypad locked\n");break;
6521 case GSM_SMSMemoryFull: printmsg("SMS memory full\n"); 6521 case GSM_SMSMemoryFull: printmsg("SMS memory full\n");
6522 } 6522 }
6523 } 6523 }
6524 6524
6525 GSM_Terminate(); 6525 GSM_Terminate();
6526} 6526}
6527 6527
6528static void SetAutoNetworkLogin(int argc, char *argv[]) 6528static void SetAutoNetworkLogin(int argc, char *argv[])
6529{ 6529{
6530 GSM_Init(true); 6530 GSM_Init(true);
6531 6531
6532 error=Phone->SetAutoNetworkLogin(&s); 6532 error=Phone->SetAutoNetworkLogin(&s);
6533 Print_Error(error); 6533 Print_Error(error);
6534 6534
6535 GSM_Terminate(); 6535 GSM_Terminate();
6536} 6536}
6537 6537
6538#ifdef DEBUG 6538#ifdef DEBUG
6539static void MakeConvertTable(int argc, char *argv[]) 6539static void MakeConvertTable(int argc, char *argv[])
6540{ 6540{
6541 unsigned char InputBuffer[10000], Buffer[10000]; 6541 unsigned char InputBuffer[10000], Buffer[10000];
6542 FILE *file; 6542 FILE *file;
6543 int size,i,j=0; 6543 int size,i,j=0;
6544 6544
6545 file = fopen(argv[2], "rb"); 6545 file = fopen(argv[2], "rb");
6546 if (file == NULL) Print_Error(ERR_CANTOPENFILE); 6546 if (file == NULL) Print_Error(ERR_CANTOPENFILE);
6547 size=fread(InputBuffer, 1, 10000-1, file); 6547 size=fread(InputBuffer, 1, 10000-1, file);
6548 fclose(file); 6548 fclose(file);
6549 InputBuffer[size] = 0; 6549 InputBuffer[size] = 0;
6550 InputBuffer[size+1] = 0; 6550 InputBuffer[size+1] = 0;
6551 6551
6552 ReadUnicodeFile(Buffer,InputBuffer); 6552 ReadUnicodeFile(Buffer,InputBuffer);
6553 6553
6554 for(i=0;i<((int)UnicodeLength(Buffer));i++) { 6554 for(i=0;i<((int)UnicodeLength(Buffer));i++) {
6555 j++; 6555 j++;
6556 if (j==100) { 6556 if (j==100) {
6557 printf("\"\\\n\""); 6557 printf("\"\\\n\"");
6558 j=0; 6558 j=0;
6559 } 6559 }
6560 printf("\\x%02x\\x%02x",Buffer[i*2],Buffer[i*2+1]); 6560 printf("\\x%02x\\x%02x",Buffer[i*2],Buffer[i*2+1]);
6561 } 6561 }
6562 printf("\\x00\\x00"); 6562 printf("\\x00\\x00");
6563} 6563}
6564#endif 6564#endif
6565 6565
6566static void ListNetworks(int argc, char *argv[]) 6566static void ListNetworks(int argc, char *argv[])
6567{ 6567{
6568 extern unsigned char *GSM_Networks[]; 6568 extern unsigned char *GSM_Networks[];
6569 int i=0; 6569 int i=0;
6570 6570
6571 printmsg("Network Name\n\n"); 6571 printmsg("Network Name\n\n");
6572 while (GSM_Networks[i*2]!=NULL) { 6572 while (GSM_Networks[i*2]!=NULL) {
6573 printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]); 6573 printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]);
6574 i++; 6574 i++;
6575 } 6575 }
6576} 6576}
6577 6577
6578static void Version(int argc, char *argv[]) 6578static void Version(int argc, char *argv[])
6579{ 6579{
6580 // unsigned char buff[10]; 6580 // unsigned char buff[10];
6581 // int len; 6581 // int len;
6582 6582
6583 printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__); 6583 printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__);
6584 6584
6585#ifdef DEBUG 6585#ifdef DEBUG
6586 printf("GSM_SMSMessage - %i\n",sizeof(GSM_SMSMessage)); 6586 printf("GSM_SMSMessage - %i\n",sizeof(GSM_SMSMessage));
6587 printf("GSM_SMSC - %i\n",sizeof(GSM_SMSC)); 6587 printf("GSM_SMSC - %i\n",sizeof(GSM_SMSC));
6588 printf("GSM_SMS_State - %i\n",sizeof(GSM_SMS_State)); 6588 printf("GSM_SMS_State - %i\n",sizeof(GSM_SMS_State));
6589 printf("GSM_UDHHeader - %i\n",sizeof(GSM_UDHHeader)); 6589 printf("GSM_UDHHeader - %i\n",sizeof(GSM_UDHHeader));
6590 printf("bool - %i\n",sizeof(bool)); 6590 printf("bool - %i\n",sizeof(bool));
6591 printf("GSM_DateTime - %i\n",sizeof(GSM_DateTime)); 6591 printf("GSM_DateTime - %i\n",sizeof(GSM_DateTime));
6592 printf("int - %i\n",sizeof(int)); 6592 printf("int - %i\n",sizeof(int));
6593 printf("GSM_NetworkInfo - %i\n",sizeof(GSM_NetworkInfo)); 6593 printf("GSM_NetworkInfo - %i\n",sizeof(GSM_NetworkInfo));
6594#endif 6594#endif
6595 6595
6596 //len=DecodeBASE64("AXw", buff, 3); 6596 //len=DecodeBASE64("AXw", buff, 3);
6597 //DumpMessage(stdout, buff, len); 6597 //DumpMessage(stdout, buff, len);
6598} 6598}
6599 6599
6600static void GetFMStation(int argc, char *argv[]) 6600static void GetFMStation(int argc, char *argv[])
6601{ 6601{
6602 GSM_FMStation Station; 6602 GSM_FMStation Station;
6603 int start,stop; 6603 int start,stop;
6604 6604
6605 GetStartStop(&start, &stop, 2, argc, argv); 6605 GetStartStop(&start, &stop, 2, argc, argv);
6606 6606
6607 GSM_Init(true); 6607 GSM_Init(true);
6608 6608
6609 for (i=start;i<=stop;i++) { 6609 for (i=start;i<=stop;i++) {
6610 Station.Location=i; 6610 Station.Location=i;
6611 error=Phone->GetFMStation(&s,&Station); 6611 error=Phone->GetFMStation(&s,&Station);
6612 switch (error) { 6612 switch (error) {
6613 case ERR_EMPTY: 6613 case ERR_EMPTY:
6614 printmsg("Entry number %i is empty\n",i); 6614 printmsg("Entry number %i is empty\n",i);
6615 break; 6615 break;
6616 case ERR_NONE: 6616 case ERR_NONE:
6617 printmsg("Entry number %i\nStation name : \"%s\"\nFrequency : %.1f MHz\n", 6617 printmsg("Entry number %i\nStation name : \"%s\"\nFrequency : %.1f MHz\n",
6618 i,DecodeUnicodeConsole(Station.StationName), 6618 i,DecodeUnicodeConsole(Station.StationName),
6619 Station.Frequency); 6619 Station.Frequency);
6620 break; 6620 break;
6621 default: 6621 default:
6622 Print_Error(error); 6622 Print_Error(error);
6623 } 6623 }
6624 } 6624 }
6625 GSM_Terminate(); 6625 GSM_Terminate();
6626} 6626}
6627 6627
6628static void GetFileSystemStatus(int argc, char *argv[]) 6628static void GetFileSystemStatus(int argc, char *argv[])
6629{ 6629{
6630 GSM_FileSystemStatusStatus; 6630 GSM_FileSystemStatusStatus;
6631 6631
6632 GSM_Init(true); 6632 GSM_Init(true);
6633 6633
6634 error = Phone->GetFileSystemStatus(&s,&Status); 6634 error = Phone->GetFileSystemStatus(&s,&Status);
6635 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) { 6635 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) {
6636 Print_Error(error); 6636 Print_Error(error);
6637 printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used); 6637 printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used);
6638 } 6638 }
6639 6639
6640 GSM_Terminate(); 6640 GSM_Terminate();
6641} 6641}
6642 6642
6643static void GetFileSystem(int argc, char *argv[]) 6643static void GetFileSystem(int argc, char *argv[])
6644{ 6644{
6645 bool Start = true; 6645 bool Start = true;
6646 GSM_File Files; 6646 GSM_File Files;
6647 int j; 6647 int j;
6648 GSM_FileSystemStatusStatus; 6648 GSM_FileSystemStatusStatus;
6649 char FolderName[256]; 6649 char FolderName[256];
6650 6650
6651 GSM_Init(true); 6651 GSM_Init(true);
6652 6652
6653 while (1) { 6653 while (1) {
6654 error = Phone->GetNextFileFolder(&s,&Files,Start); 6654 error = Phone->GetNextFileFolder(&s,&Files,Start);
6655 if (error == ERR_EMPTY) break; 6655 if (error == ERR_EMPTY) break;
6656 Print_Error(error); 6656 Print_Error(error);
6657 6657
6658 if (argc <= 2 || !mystrncasecmp(argv[2],"-flatall",0)) { 6658 if (argc <= 2 || !mystrncasecmp(argv[2],"-flatall",0)) {
6659 if (strlen(Files.ID_FullName) < 5 && strlen(Files.ID_FullName) != 0) { 6659 if (strlen(Files.ID_FullName) < 5 && strlen(Files.ID_FullName) != 0) {
6660 printf("%5s.",Files.ID_FullName); 6660 printf("%5s.",Files.ID_FullName);
6661 } 6661 }
6662 if (Files.Protected) { 6662 if (Files.Protected) {
6663 printf("P"); 6663 printf("P");
6664 } else { 6664 } else {
6665 printf(" "); 6665 printf(" ");
6666 } 6666 }
6667 if (Files.ReadOnly) { 6667 if (Files.ReadOnly) {
6668 printf("R"); 6668 printf("R");
6669 } else { 6669 } else {
6670 printf(" "); 6670 printf(" ");
6671 } 6671 }
6672 if (Files.Hidden) { 6672 if (Files.Hidden) {
6673 printf("H"); 6673 printf("H");
6674 } else { 6674 } else {
6675 printf(" "); 6675 printf(" ");
6676 } 6676 }
6677 if (Files.System) { 6677 if (Files.System) {
6678 printf("S"); 6678 printf("S");
6679 } else { 6679 } else {
6680 printf(" "); 6680 printf(" ");
6681 } 6681 }
6682 if (argc > 2 && mystrncasecmp(argv[2],"-flat",0)) { 6682 if (argc > 2 && mystrncasecmp(argv[2],"-flat",0)) {
6683 if (!Files.Folder) { 6683 if (!Files.Folder) {
6684 if (mystrncasecmp(argv[2],"-flatall",0)) { 6684 if (mystrncasecmp(argv[2],"-flatall",0)) {
6685 if (!Files.ModifiedEmpty) { 6685 if (!Files.ModifiedEmpty) {
6686 printf(" %30s",OSDateTime(Files.Modified,false)); 6686 printf(" %30s",OSDateTime(Files.Modified,false));
6687 } else printf(" %30c",0x20); 6687 } else printf(" %30c",0x20);
6688 printf(" %9i",Files.Used); 6688 printf(" %9i",Files.Used);
6689 printf(" "); 6689 printf(" ");
6690 } else printf("|-- "); 6690 } else printf("|-- ");
6691 } else printf("Folder "); 6691 } else printf("Folder ");
6692 } else { 6692 } else {
6693 if (Files.Level != 1) { 6693 if (Files.Level != 1) {
6694 for (j=0;j<Files.Level-2;j++) printf(" | "); 6694 for (j=0;j<Files.Level-2;j++) printf(" | ");
6695 printf(" |-- "); 6695 printf(" |-- ");
6696 } 6696 }
6697 if (Files.Folder) printf("Folder "); 6697 if (Files.Folder) printf("Folder ");
6698 } 6698 }
6699 printf("\"%s\"",DecodeUnicodeConsole(Files.Name)); 6699 printf("\"%s\"",DecodeUnicodeConsole(Files.Name));
6700 printf("\n"); 6700 printf("\n");
6701 6701
6702 Start = false; 6702 Start = false;
6703 } else if (argc > 2 && mystrncasecmp(argv[2],"-flatall",0)) { 6703 } else if (argc > 2 && mystrncasecmp(argv[2],"-flatall",0)) {
6704 /* format for a folder ID;Folder;FOLDER_NAME;[FOLDER_PARAMETERS] 6704 /* format for a folder ID;Folder;FOLDER_NAME;[FOLDER_PARAMETERS]
6705 * format for a file ID;File;FOLDER_NAME;FILE_NAME;DATESTAMP;FILE_SIZE;[FILE_PARAMETERS] */ 6705 * format for a file ID;File;FOLDER_NAME;FILE_NAME;DATESTAMP;FILE_SIZE;[FILE_PARAMETERS] */
6706 if (!Files.Folder) { 6706 if (!Files.Folder) {
6707 printf("%s;File;",Files.ID_FullName); 6707 printf("%s;File;",Files.ID_FullName);
6708 printf("\"%s\";",FolderName); 6708 printf("\"%s\";",FolderName);
6709 printf("\"%s\";",DecodeUnicodeConsole(Files.Name)); 6709 printf("\"%s\";",DecodeUnicodeConsole(Files.Name));
6710 if (!Files.ModifiedEmpty) { 6710 if (!Files.ModifiedEmpty) {
6711 printf("\"%s\";",OSDateTime(Files.Modified,false)); 6711 printf("\"%s\";",OSDateTime(Files.Modified,false));
6712 } else printf("\"%c\";",0x20); 6712 } else printf("\"%c\";",0x20);
6713 printf("%i;",Files.Used); 6713 printf("%i;",Files.Used);
6714 } else { 6714 } else {
6715 printf("%s;Folder;",Files.ID_FullName); 6715 printf("%s;Folder;",Files.ID_FullName);
6716 printf("\"%s\";",DecodeUnicodeConsole(Files.Name)); 6716 printf("\"%s\";",DecodeUnicodeConsole(Files.Name));
6717 strcpy(FolderName,DecodeUnicodeConsole(Files.Name)); 6717 strcpy(FolderName,DecodeUnicodeConsole(Files.Name));
6718 } 6718 }
6719 6719
6720 if (Files.Protected) printf("P"); 6720 if (Files.Protected) printf("P");
6721 if (Files.ReadOnly) printf("R"); 6721 if (Files.ReadOnly) printf("R");
6722 if (Files.Hidden) printf("H"); 6722 if (Files.Hidden) printf("H");
6723 if (Files.System) printf("S"); 6723 if (Files.System) printf("S");
6724 6724
6725 printf("\n"); 6725 printf("\n");
6726 6726
6727 Start = false; 6727 Start = false;
6728 } 6728 }
6729 } 6729 }
6730 6730
6731 error = Phone->GetFileSystemStatus(&s,&Status); 6731 error = Phone->GetFileSystemStatus(&s,&Status);
6732 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) { 6732 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) {
6733 Print_Error(error); 6733 Print_Error(error);
6734 printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used); 6734 printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used);
6735 } 6735 }
6736 6736
6737 GSM_Terminate(); 6737 GSM_Terminate();
6738} 6738}
6739 6739
6740static void GetOneFile(GSM_File *File, bool newtime, int i) 6740static void GetOneFile(GSM_File *File, bool newtime, int i)
6741{ 6741{
6742 FILE *file; 6742 FILE *file;
6743 bool start; 6743 bool start;
6744 unsigned char buffer[5000]; 6744 unsigned char buffer[5000];
6745 struct utimbuf filedate; 6745 struct utimbuf filedate;
6746 6746
6747 if (File->Buffer != NULL) { 6747 if (File->Buffer != NULL) {
6748 free(File->Buffer); 6748 free(File->Buffer);
6749 File->Buffer = NULL; 6749 File->Buffer = NULL;
6750 } 6750 }
6751 File->Used = 0; 6751 File->Used = 0;
6752 start = true; 6752 start = true;
6753 6753
6754 error = ERR_NONE; 6754 error = ERR_NONE;
6755 while (error == ERR_NONE) { 6755 while (error == ERR_NONE) {
6756 error = Phone->GetFilePart(&s,File); 6756 error = Phone->GetFilePart(&s,File);
6757 if (error == ERR_NONE || error == ERR_EMPTY || error == ERR_WRONGCRC) { 6757 if (error == ERR_NONE || error == ERR_EMPTY || error == ERR_WRONGCRC) {
6758 if (start) { 6758 if (start) {
6759 printmsg("Getting \"%s\": ", DecodeUnicodeConsole(File->Name)); 6759 printmsg("Getting \"%s\": ", DecodeUnicodeConsole(File->Name));
6760 start = false; 6760 start = false;
6761 } 6761 }
6762 if (File->Folder) { 6762 if (File->Folder) {
6763 free(File->Buffer); 6763 free(File->Buffer);
6764 GSM_Terminate(); 6764 GSM_Terminate();
6765 printmsg("it's folder. Please give only file names\n"); 6765 printmsg("it's folder. Please give only file names\n");
6766 exit(-1); 6766 exit(-1);
6767 } 6767 }
6768 printmsg("*"); 6768 printmsg("*");
6769 if (error == ERR_EMPTY) break; 6769 if (error == ERR_EMPTY) break;
6770 if (error == ERR_WRONGCRC) { 6770 if (error == ERR_WRONGCRC) {
6771 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); 6771 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
6772 break; 6772 break;
6773 } 6773 }
6774 } 6774 }
6775 Print_Error(error); 6775 Print_Error(error);
6776 } 6776 }
6777 printf("\n"); 6777 printf("\n");
6778 if (File->Used != 0) { 6778 if (File->Used != 0) {
6779 sprintf(buffer,"%s",DecodeUnicodeConsole(File->Name)); 6779 sprintf(buffer,"%s",DecodeUnicodeConsole(File->Name));
6780 file = fopen(buffer,"wb"); 6780 file = fopen(buffer,"wb");
6781 if (file == NULL) { 6781 if (file == NULL) {
6782 sprintf(buffer,"file%s",File->ID_FullName); 6782 sprintf(buffer,"file%s",File->ID_FullName);
6783 file = fopen(buffer,"wb"); 6783 file = fopen(buffer,"wb");
6784 } 6784 }
6785 if (file == NULL) { 6785 if (file == NULL) {
6786 sprintf(buffer,"file%i",i); 6786 sprintf(buffer,"file%i",i);
6787 file = fopen(buffer,"wb"); 6787 file = fopen(buffer,"wb");
6788 } 6788 }
6789 printmsg(" Saving to %s\n",buffer); 6789 printmsg(" Saving to %s\n",buffer);
6790 if (!file) Print_Error(ERR_CANTOPENFILE); 6790 if (!file) Print_Error(ERR_CANTOPENFILE);
6791 fwrite(File->Buffer,1,File->Used,file); 6791 fwrite(File->Buffer,1,File->Used,file);
6792 fclose(file); 6792 fclose(file);
6793 if (!newtime && !File->ModifiedEmpty) { 6793 if (!newtime && !File->ModifiedEmpty) {
6794 /* access time */ 6794 /* access time */
6795 filedate.actime = Fill_Time_T(File->Modified, 8); 6795 filedate.actime = Fill_Time_T(File->Modified, 8);
6796 /* modification time */ 6796 /* modification time */
6797 filedate.modtime = Fill_Time_T(File->Modified, 8); 6797 filedate.modtime = Fill_Time_T(File->Modified, 8);
6798 dbgprintf("Setting date of %s\n",buffer); 6798 dbgprintf("Setting date of %s\n",buffer);
6799 utime(buffer,&filedate); 6799 utime(buffer,&filedate);
6800 } 6800 }
6801 } 6801 }
6802} 6802}
6803 6803
6804static void GetFiles(int argc, char *argv[]) 6804static void GetFiles(int argc, char *argv[])
6805{ 6805{
6806 GSM_File File; 6806 GSM_File File;
6807 int i; 6807 int i;
6808 bool newtime = false; 6808 bool newtime = false;
6809 6809
6810 File.Buffer = NULL; 6810 File.Buffer = NULL;
6811 6811
6812 GSM_Init(true); 6812 GSM_Init(true);
6813 6813
6814 for (i=2;i<argc;i++) { 6814 for (i=2;i<argc;i++) {
6815 if (mystrncasecmp(argv[i],"-newtime",0)) { 6815 if (mystrncasecmp(argv[i],"-newtime",0)) {
6816 newtime = true; 6816 newtime = true;
6817 continue; 6817 continue;
6818 } 6818 }
6819 6819
6820 strcpy(File.ID_FullName,argv[i]); 6820 strcpy(File.ID_FullName,argv[i]);
6821 GetOneFile(&File, newtime, i); 6821 GetOneFile(&File, newtime, i);
6822 } 6822 }
6823 6823
6824 free(File.Buffer); 6824 free(File.Buffer);
6825 GSM_Terminate(); 6825 GSM_Terminate();
6826} 6826}
6827 6827
6828static void GetFileFolder(int argc, char *argv[]) 6828static void GetFileFolder(int argc, char *argv[])
6829{ 6829{
6830 bool Start = true; 6830 bool Start = true;
6831 GSM_File File; 6831 GSM_File File;
6832 int level=0,allnum=0,num=0,filelevel=0; 6832 int level=0,allnum=0,num=0,filelevel=0;
6833 bool newtime = false, found; 6833 bool newtime = false, found;
6834 6834
6835 File.Buffer = NULL; 6835 File.Buffer = NULL;
6836 6836
6837 GSM_Init(true); 6837 GSM_Init(true);
6838 6838
6839 for (i=2;i<argc;i++) { 6839 for (i=2;i<argc;i++) {
6840 if (mystrncasecmp(argv[i],"-newtime",0)) { 6840 if (mystrncasecmp(argv[i],"-newtime",0)) {
6841 newtime = true; 6841 newtime = true;
6842 continue; 6842 continue;
6843 } 6843 }
6844 allnum++; 6844 allnum++;
6845 } 6845 }
6846 6846
6847 while (allnum != num) { 6847 while (allnum != num) {
6848 error = Phone->GetNextFileFolder(&s,&File,Start); 6848 error = Phone->GetNextFileFolder(&s,&File,Start);
6849 if (error == ERR_EMPTY) break; 6849 if (error == ERR_EMPTY) break;
6850 Print_Error(error); 6850 Print_Error(error);
6851 6851
6852 if (level == 0) { 6852 if (level == 0) {
6853 /* We search for file or folder */ 6853 /* We search for file or folder */
6854 found = false; 6854 found = false;
6855 for (i=2;i<argc;i++) { 6855 for (i=2;i<argc;i++) {
6856 if (mystrncasecmp(argv[i],"-newtime",0)) { 6856 if (mystrncasecmp(argv[i],"-newtime",0)) {
6857 continue; 6857 continue;
6858 } 6858 }
6859 if (!strcmp(File.ID_FullName,argv[i])) { 6859 if (!strcmp(File.ID_FullName,argv[i])) {
6860 found = true; 6860 found = true;
6861 if (File.Folder) { 6861 if (File.Folder) {
6862 level = 1; 6862 level = 1;
6863 filelevel = File.Level + 1; 6863 filelevel = File.Level + 1;
6864 Start = false; 6864 Start = false;
6865 } else { 6865 } else {
6866 level = 2; 6866 level = 2;
6867 } 6867 }
6868 break; 6868 break;
6869 } 6869 }
6870 } 6870 }
6871 if (found && File.Folder) continue; 6871 if (found && File.Folder) continue;
6872 } 6872 }
6873 if (level == 1) { 6873 if (level == 1) {
6874 /* We have folder */ 6874 /* We have folder */
6875 dbgprintf("%i %i\n",File.Level,filelevel); 6875 dbgprintf("%i %i\n",File.Level,filelevel);
6876 if (File.Level != filelevel) { 6876 if (File.Level != filelevel) {
6877 level = 0; 6877 level = 0;
6878 num++; 6878 num++;
6879 } 6879 }
6880 } 6880 }
6881 6881
6882 if (level != 0 && !File.Folder) GetOneFile(&File, newtime,num); 6882 if (level != 0 && !File.Folder) GetOneFile(&File, newtime,num);
6883 6883
6884 if (level == 2) { 6884 if (level == 2) {
6885 level = 0; 6885 level = 0;
6886 num++; 6886 num++;
6887 } 6887 }
6888 6888
6889 Start = false; 6889 Start = false;
6890 } 6890 }
6891 6891
6892 free(File.Buffer); 6892 free(File.Buffer);
6893 GSM_Terminate(); 6893 GSM_Terminate();
6894} 6894}
6895 6895
6896static void AddFile(int argc, char *argv[]) 6896static void AddFile(int argc, char *argv[])
6897{ 6897{
6898 GSM_File File; 6898 GSM_File File;
6899 int Pos = 0,i,nextlong; 6899 int Pos = 0,i,nextlong;
6900 6900
6901 File.Buffer = NULL; 6901 File.Buffer = NULL;
6902 strcpy(File.ID_FullName,argv[2]); 6902 strcpy(File.ID_FullName,argv[2]);
6903 error = GSM_ReadFile(argv[3], &File); 6903 error = GSM_ReadFile(argv[3], &File);
6904 Print_Error(error); 6904 Print_Error(error);
6905 EncodeUnicode(File.Name,argv[3],strlen(argv[3])); 6905 EncodeUnicode(File.Name,argv[3],strlen(argv[3]));
6906 GSM_IdentifyFileFormat(&File); 6906 GSM_IdentifyFileFormat(&File);
6907 6907
6908 File.Protected = false; 6908 File.Protected = false;
6909 File.ReadOnly= false; 6909 File.ReadOnly= false;
6910 File.Hidden= false; 6910 File.Hidden= false;
6911 File.System= false; 6911 File.System= false;
6912 6912
6913 if (argc > 4) { 6913 if (argc > 4) {
6914 nextlong = 0; 6914 nextlong = 0;
6915 for (i=4;i<argc;i++) { 6915 for (i=4;i<argc;i++) {
6916 switch(nextlong) { 6916 switch(nextlong) {
6917 case 0: 6917 case 0:
6918 if (mystrncasecmp(argv[i],"-type",0)) { 6918 if (mystrncasecmp(argv[i],"-type",0)) {
6919 nextlong = 1; 6919 nextlong = 1;
6920 continue; 6920 continue;
6921 } 6921 }
6922 if (mystrncasecmp(argv[i],"-protected",0)) { 6922 if (mystrncasecmp(argv[i],"-protected",0)) {
6923 File.Protected = true; 6923 File.Protected = true;
6924 continue; 6924 continue;
6925 } 6925 }
6926 if (mystrncasecmp(argv[i],"-readonly",0)) { 6926 if (mystrncasecmp(argv[i],"-readonly",0)) {
6927 File.ReadOnly = true; 6927 File.ReadOnly = true;
6928 continue; 6928 continue;
6929 } 6929 }
6930 if (mystrncasecmp(argv[i],"-hidden",0)) { 6930 if (mystrncasecmp(argv[i],"-hidden",0)) {
6931 File.Hidden = true; 6931 File.Hidden = true;
6932 continue; 6932 continue;
6933 } 6933 }
6934 if (mystrncasecmp(argv[i],"-system",0)) { 6934 if (mystrncasecmp(argv[i],"-system",0)) {
6935 File.System = true; 6935 File.System = true;
6936 continue; 6936 continue;
6937 } 6937 }
6938 if (mystrncasecmp(argv[i],"-newtime",0)) { 6938 if (mystrncasecmp(argv[i],"-newtime",0)) {
6939 File.ModifiedEmpty = true; 6939 File.ModifiedEmpty = true;
6940 continue; 6940 continue;
6941 } 6941 }
6942 printmsg("Parameter \"%s\" unknown\n",argv[i]); 6942 printmsg("Parameter \"%s\" unknown\n",argv[i]);
6943 exit(-1); 6943 exit(-1);
6944 case 1: 6944 case 1:
6945 if (mystrncasecmp(argv[i],"JAR",0)) { 6945 if (mystrncasecmp(argv[i],"JAR",0)) {
6946 File.Type = GSM_File_Java_JAR; 6946 File.Type = GSM_File_Java_JAR;
6947 } else if (mystrncasecmp(argv[i],"JPG",0)) { 6947 } else if (mystrncasecmp(argv[i],"JPG",0)) {
6948 File.Type = GSM_File_Image_JPG; 6948 File.Type = GSM_File_Image_JPG;
6949 } else if (mystrncasecmp(argv[i],"BMP",0)) { 6949 } else if (mystrncasecmp(argv[i],"BMP",0)) {
6950 File.Type = GSM_File_Image_BMP; 6950 File.Type = GSM_File_Image_BMP;
6951 } else if (mystrncasecmp(argv[i],"WBMP",0)) { 6951 } else if (mystrncasecmp(argv[i],"WBMP",0)) {
6952 File.Type = GSM_File_Image_WBMP; 6952 File.Type = GSM_File_Image_WBMP;
6953 } else if (mystrncasecmp(argv[i],"GIF",0)) { 6953 } else if (mystrncasecmp(argv[i],"GIF",0)) {
6954 File.Type = GSM_File_Image_GIF; 6954 File.Type = GSM_File_Image_GIF;
6955 } else if (mystrncasecmp(argv[i],"PNG",0)) { 6955 } else if (mystrncasecmp(argv[i],"PNG",0)) {
6956 File.Type = GSM_File_Image_PNG; 6956 File.Type = GSM_File_Image_PNG;
6957 } else if (mystrncasecmp(argv[i],"MIDI",0)) { 6957 } else if (mystrncasecmp(argv[i],"MIDI",0)) {
6958 File.Type = GSM_File_Sound_MIDI; 6958 File.Type = GSM_File_Sound_MIDI;
6959 } else if (mystrncasecmp(argv[i],"AMR",0)) { 6959 } else if (mystrncasecmp(argv[i],"AMR",0)) {
6960 File.Type = GSM_File_Sound_AMR; 6960 File.Type = GSM_File_Sound_AMR;
6961 } else if (mystrncasecmp(argv[i],"NRT",0)) { 6961 } else if (mystrncasecmp(argv[i],"NRT",0)) {
6962 File.Type = GSM_File_Sound_NRT; 6962 File.Type = GSM_File_Sound_NRT;
6963 } else if (mystrncasecmp(argv[i],"3GP",0)) { 6963 } else if (mystrncasecmp(argv[i],"3GP",0)) {
6964 File.Type = GSM_File_Video_3GP; 6964 File.Type = GSM_File_Video_3GP;
6965 } else { 6965 } else {
6966 printmsg("What file type (\"%s\") ?\n",argv[i]); 6966 printmsg("What file type (\"%s\") ?\n",argv[i]);
6967 exit(-1); 6967 exit(-1);
6968 } 6968 }
6969 nextlong = 0; 6969 nextlong = 0;
6970 break; 6970 break;
6971 } 6971 }
6972 } 6972 }
6973 if (nextlong!=0) { 6973 if (nextlong!=0) {
6974 printmsg("Parameter missed...\n"); 6974 printmsg("Parameter missed...\n");
6975 exit(-1); 6975 exit(-1);
6976 } 6976 }
6977 } 6977 }
6978 6978
6979 GSM_Init(true); 6979 GSM_Init(true);
6980 6980
6981 error = ERR_NONE; 6981 error = ERR_NONE;
6982 while (error == ERR_NONE) { 6982 while (error == ERR_NONE) {
6983 error = Phone->AddFilePart(&s,&File,&Pos); 6983 error = Phone->AddFilePart(&s,&File,&Pos);
6984 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); 6984 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
6985 printmsgerr("%cWriting: %i percent",13,Pos*100/File.Used); 6985 printmsgerr("%cWriting: %i percent",13,Pos*100/File.Used);
6986 } 6986 }
6987 printmsgerr("\n"); 6987 printmsgerr("\n");
6988 if (error == ERR_WRONGCRC) { 6988 if (error == ERR_WRONGCRC) {
6989 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); 6989 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
6990 } 6990 }
6991 6991
6992 free(File.Buffer); 6992 free(File.Buffer);
6993 GSM_Terminate(); 6993 GSM_Terminate();
6994} 6994}
6995 6995
6996static void AddFolder(int argc, char *argv[]) 6996static void AddFolder(int argc, char *argv[])
6997{ 6997{
6998 GSM_File File; 6998 GSM_File File;
6999 6999
7000 strcpy(File.ID_FullName,argv[2]); 7000 strcpy(File.ID_FullName,argv[2]);
7001 EncodeUnicode(File.Name,argv[3],strlen(argv[3])); 7001 EncodeUnicode(File.Name,argv[3],strlen(argv[3]));
7002 File.ReadOnly = false; 7002 File.ReadOnly = false;
7003 7003
7004 GSM_Init(true); 7004 GSM_Init(true);
7005 7005
7006 error = Phone->AddFolder(&s,&File); 7006 error = Phone->AddFolder(&s,&File);
7007 Print_Error(error); 7007 Print_Error(error);
7008 7008
7009 GSM_Terminate(); 7009 GSM_Terminate();
7010} 7010}
7011 7011
7012struct NokiaFolderInfo { 7012struct NokiaFolderInfo {
7013 char*model; 7013 char*model;
7014 char *parameter; 7014 char *parameter;
7015 char*folder; 7015 char*folder;
7016 char *level; 7016 char *level;
7017}; 7017};
7018 7018
7019static struct NokiaFolderInfo Folder[] = { 7019static struct NokiaFolderInfo Folder[] = {
7020 /* Language indepedent in DCT4 */ 7020 /* Language indepedent in DCT4 */
7021 {"", "MMSUnreadInbox", "INBOX","3"}, 7021 {"", "MMSUnreadInbox", "INBOX","3"},
7022 {"", "MMSReadInbox", "INBOX","3"}, 7022 {"", "MMSReadInbox", "INBOX","3"},
7023 {"", "MMSOutbox", "OUTBOX","3"}, 7023 {"", "MMSOutbox", "OUTBOX","3"},
7024 {"", "MMSSent", "SENT", "3"}, 7024 {"", "MMSSent", "SENT", "3"},
7025 {"", "MMSDrafts", "DRAFTS","3"}, 7025 {"", "MMSDrafts", "DRAFTS","3"},
7026 {"", "Application", "applications","3"}, 7026 {"", "Application", "applications","3"},
7027 {"", "Game", "games","3"}, 7027 {"", "Game", "games","3"},
7028 /* Language depedent in DCT4 */ 7028 /* Language depedent in DCT4 */
7029 {"", "Gallery", "Pictures","2"}, /* 3510 */ 7029 {"", "Gallery", "Pictures","2"}, /* 3510 */
7030 {"", "Gallery", "Graphics","3"}, /* 3510i */ 7030 {"", "Gallery", "Graphics","3"}, /* 3510i */
7031 {"", "Gallery", "Images","3"}, /* 6610 */ 7031 {"", "Gallery", "Images","3"}, /* 6610 */
7032 {"3510", "Gallery", "", "8"}, 7032 {"3510", "Gallery", "", "8"},
7033 {"3510i","Gallery", "", "3"}, 7033 {"3510i","Gallery", "", "3"},
7034 {"5100", "Gallery", "", "3"}, 7034 {"5100", "Gallery", "", "3"},
7035 {"6220", "Gallery", "", "5"}, 7035 {"6220", "Gallery", "", "5"},
7036 {"", "Tones", "Tones","3"}, 7036 {"", "Tones", "Tones","3"},
7037 {"3510i","Tones", "", "4"}, 7037 {"3510i","Tones", "", "4"},
7038 {"5100", "Tones", "", "4"}, 7038 {"5100", "Tones", "", "4"},
7039 {"6220", "Tones", "", "6"}, 7039 {"6220", "Tones", "", "6"},
7040 /* Language indepedent in OBEX */ 7040 /* Language indepedent in OBEX */
7041 {"obex", "MMSUnreadInbox", "", "predefMessages\\predefINBOX"}, 7041 {"obex", "MMSUnreadInbox", "", "predefMessages\\predefINBOX"},
7042 {"obex", "MMSReadInbox", "", "predefMessages\\predefINBOX"}, 7042 {"obex", "MMSReadInbox", "", "predefMessages\\predefINBOX"},
7043 {"obex", "MMSOutbox", "", "predefMessages\\predefOUTBOX"}, 7043 {"obex", "MMSOutbox", "", "predefMessages\\predefOUTBOX"},
7044 {"obex", "MMSSent", "", "predefMessages\\predefSENT" }, 7044 {"obex", "MMSSent", "", "predefMessages\\predefSENT" },
7045 {"obex", "MMSDrafts", "", "predefMessages\\predefDRAFTS"}, 7045 {"obex", "MMSDrafts", "", "predefMessages\\predefDRAFTS"},
7046 // {"obex", "Application, "", "predefjava\\predefapplications"}, 7046 // {"obex", "Application, "", "predefjava\\predefapplications"},
7047 // {"obex", "Game", "", "predefjava\\predefgames"}, 7047 // {"obex", "Game", "", "predefjava\\predefgames"},
7048 {"obex", "Gallery", "", "predefgallery\\predefgraphics"}, 7048 {"obex", "Gallery", "", "predefgallery\\predefgraphics"},
7049 {"obex", "Tones", "", "predefgallery\\predeftones"}, 7049 {"obex", "Tones", "", "predefgallery\\predeftones"},
7050 7050
7051 /* End of list */ 7051 /* End of list */
7052 {"", "", "", ""} 7052 {"", "", "", ""}
7053}; 7053};
7054 7054
7055static void NokiaAddFile(int argc, char *argv[]) 7055static void NokiaAddFile(int argc, char *argv[])
7056{ 7056{
7057 GSM_File File, Files; 7057 GSM_File File, Files;
7058 FILE *file; 7058 FILE *file;
7059 GSM_DateTime DT,DT2; 7059 GSM_DateTime DT,DT2;
7060 time_t t_time1,t_time2; 7060 time_t t_time1,t_time2;
7061 unsigned char buffer[10000],JAR[500],Vendor[500],Name[500],Version[500],FileID[400]; 7061 unsigned char buffer[10000],JAR[500],Vendor[500],Name[500],Version[500],FileID[400];
7062 bool Start = true, Found = false, wasclr; 7062 bool Start = true, Found = false, wasclr;
7063 bool ModEmpty = false; 7063 bool ModEmpty = false;
7064 int i = 0, Pos, Size, Size2, nextlong; 7064 int i = 0, Pos, Size, Size2, nextlong;
7065 7065
7066 while (Folder[i].level[0] != 0) { 7066 while (Folder[i].level[0] != 0) {
7067 if (mystrncasecmp(argv[2],Folder[i].parameter,0)) { 7067 if (mystrncasecmp(argv[2],Folder[i].parameter,0)) {
7068 Found = true; 7068 Found = true;
7069 break; 7069 break;
7070 } 7070 }
7071 i++; 7071 i++;
7072 } 7072 }
7073 if (!Found) { 7073 if (!Found) {
7074 printmsg("What folder type (\"%s\") ?\n",argv[2]); 7074 printmsg("What folder type (\"%s\") ?\n",argv[2]);
7075 exit(-1); 7075 exit(-1);
7076 } 7076 }
7077 7077
7078 GSM_Init(true); 7078 GSM_Init(true);
7079 7079
7080 if (s.ConnectionType == GCT_IRDAOBEX || s.ConnectionType == GCT_BLUEOBEX) { 7080 if (s.ConnectionType == GCT_IRDAOBEX || s.ConnectionType == GCT_BLUEOBEX) {
7081 Found = false; 7081 Found = false;
7082 i = 0; 7082 i = 0;
7083 while (Folder[i].level[0] != 0) { 7083 while (Folder[i].level[0] != 0) {
7084 if (!strcmp("obex",Folder[i].model) && 7084 if (!strcmp("obex",Folder[i].model) &&
7085 mystrncasecmp(argv[2],Folder[i].parameter,0)) { 7085 mystrncasecmp(argv[2],Folder[i].parameter,0)) {
7086 strcpy(Files.ID_FullName,Folder[i].level); 7086 strcpy(Files.ID_FullName,Folder[i].level);
7087 Found = true; 7087 Found = true;
7088 break; 7088 break;
7089 } 7089 }
7090 i++; 7090 i++;
7091 } 7091 }
7092 } else { 7092 } else {
7093 printmsgerr("Searching for phone folder: "); 7093 printmsgerr("Searching for phone folder: ");
7094 while (1) { 7094 while (1) {
7095 error = Phone->GetNextFileFolder(&s,&Files,Start); 7095 error = Phone->GetNextFileFolder(&s,&Files,Start);
7096 if (error == ERR_EMPTY) break; 7096 if (error == ERR_EMPTY) break;
7097 Print_Error(error); 7097 Print_Error(error);
7098 7098
7099 if (Files.Folder) { 7099 if (Files.Folder) {
7100 dbgprintf("folder %s level %i\n",DecodeUnicodeConsole(Files.Name),Files.Level); 7100 dbgprintf("folder %s level %i\n",DecodeUnicodeConsole(Files.Name),Files.Level);
7101 Found = false; 7101 Found = false;
7102 i = 0; 7102 i = 0;
7103 while (Folder[i].level[0] != 0) { 7103 while (Folder[i].level[0] != 0) {
7104 EncodeUnicode(buffer,Folder[i].folder,strlen(Folder[i].folder)); 7104 EncodeUnicode(buffer,Folder[i].folder,strlen(Folder[i].folder));
7105 dbgprintf("comparing \"%s\" \"%s\" \"%s\"\n",s.Phone.Data.ModelInfo->model,Files.ID_FullName,Folder[i].level); 7105 dbgprintf("comparing \"%s\" \"%s\" \"%s\"\n",s.Phone.Data.ModelInfo->model,Files.ID_FullName,Folder[i].level);
7106 if (mystrncasecmp(argv[2],Folder[i].parameter,0) && 7106 if (mystrncasecmp(argv[2],Folder[i].parameter,0) &&
7107 mywstrncasecmp(Files.Name,buffer,0) && 7107 mywstrncasecmp(Files.Name,buffer,0) &&
7108 Files.Level == atoi(Folder[i].level)) { 7108 Files.Level == atoi(Folder[i].level)) {
7109 Found = true; 7109 Found = true;
7110 break; 7110 break;
7111 } 7111 }
7112 if (!strcmp(s.Phone.Data.ModelInfo->model,Folder[i].model) && 7112 if (!strcmp(s.Phone.Data.ModelInfo->model,Folder[i].model) &&
7113 mystrncasecmp(argv[2],Folder[i].parameter,0) && 7113 mystrncasecmp(argv[2],Folder[i].parameter,0) &&
7114 !strcmp(Files.ID_FullName,Folder[i].level)) { 7114 !strcmp(Files.ID_FullName,Folder[i].level)) {
7115 Found = true; 7115 Found = true;
7116 break; 7116 break;
7117 } 7117 }
7118 i++; 7118 i++;
7119 } 7119 }
7120 if (Found) break; 7120 if (Found) break;
7121 } 7121 }
7122 printmsgerr("*"); 7122 printmsgerr("*");
7123 7123
7124 Start = false; 7124 Start = false;
7125 } 7125 }
7126 printmsgerr("\n"); 7126 printmsgerr("\n");
7127 } 7127 }
7128 if (!Found) { 7128 if (!Found) {
7129 printmsg("Folder not found. Probably function not supported !\n"); 7129 printmsg("Folder not found. Probably function not supported !\n");
7130 GSM_Terminate(); 7130 GSM_Terminate();
7131 exit(-1); 7131 exit(-1);
7132 } 7132 }
7133 File.Buffer = NULL; 7133 File.Buffer = NULL;
7134 File.Protected = false; 7134 File.Protected = false;
7135 File.ReadOnly = false; 7135 File.ReadOnly = false;
7136 File.Hidden= false; 7136 File.Hidden= false;
7137 File.System= false; 7137 File.System= false;
7138 7138
7139 if (mystrncasecmp(argv[2],"Application",0) || mystrncasecmp(argv[2],"Game",0)) { 7139 if (mystrncasecmp(argv[2],"Application",0) || mystrncasecmp(argv[2],"Game",0)) {
7140 sprintf(buffer,"%s.jad",argv[3]); 7140 sprintf(buffer,"%s.jad",argv[3]);
7141 file = fopen(buffer,"rb"); 7141 file = fopen(buffer,"rb");
7142 if (file == NULL) Print_Error(ERR_CANTOPENFILE); 7142 if (file == NULL) Print_Error(ERR_CANTOPENFILE);
7143 fclose(file); 7143 fclose(file);
7144 sprintf(buffer,"%s.jar",argv[3]); 7144 sprintf(buffer,"%s.jar",argv[3]);
7145 file = fopen(buffer,"rb"); 7145 file = fopen(buffer,"rb");
7146 if (file == NULL) Print_Error(ERR_CANTOPENFILE); 7146 if (file == NULL) Print_Error(ERR_CANTOPENFILE);
7147 fclose(file); 7147 fclose(file);
7148 7148
7149 /* reading jar file */ 7149 /* reading jar file */
7150 sprintf(buffer,"%s.jar",argv[3]); 7150 sprintf(buffer,"%s.jar",argv[3]);
7151 error = GSM_ReadFile(buffer, &File); 7151 error = GSM_ReadFile(buffer, &File);
7152 Print_Error(error); 7152 Print_Error(error);
7153 Size2 = File.Used; 7153 Size2 = File.Used;
7154 7154
7155 /* reading jad file */ 7155 /* reading jad file */
7156 sprintf(buffer,"%s.jad",argv[3]); 7156 sprintf(buffer,"%s.jad",argv[3]);
7157 error = GSM_ReadFile(buffer, &File); 7157 error = GSM_ReadFile(buffer, &File);
7158 Print_Error(error); 7158 Print_Error(error);
7159 7159
7160 /* Getting values from JAD file */ 7160 /* Getting values from JAD file */
7161 error = GSM_JADFindData(File, Vendor, Name, JAR, Version, &Size); 7161 error = GSM_JADFindData(File, Vendor, Name, JAR, Version, &Size);
7162 if (error == ERR_FILENOTSUPPORTED) { 7162 if (error == ERR_FILENOTSUPPORTED) {
7163 if (Vendor[0] == 0x00) { 7163 if (Vendor[0] == 0x00) {
7164 printmsgerr("No vendor info in JAD file\n"); 7164 printmsgerr("No vendor info in JAD file\n");
7165 GSM_Terminate(); 7165 GSM_Terminate();
7166 return; 7166 return;
7167 } 7167 }
7168 if (Name[0] == 0x00) { 7168 if (Name[0] == 0x00) {
7169 printmsgerr("No name info in JAD file\n"); 7169 printmsgerr("No name info in JAD file\n");
7170 GSM_Terminate(); 7170 GSM_Terminate();
7171 return; 7171 return;
7172 } 7172 }
7173 if (JAR[0] == 0x00) { 7173 if (JAR[0] == 0x00) {
7174 printmsgerr("No JAR URL info in JAD file\n"); 7174 printmsgerr("No JAR URL info in JAD file\n");
7175 GSM_Terminate(); 7175 GSM_Terminate();
7176 return; 7176 return;
7177 } 7177 }
7178 if (Size == -1) { 7178 if (Size == -1) {
7179 printmsgerr("No JAR size info in JAD file\n"); 7179 printmsgerr("No JAR size info in JAD file\n");
7180 GSM_Terminate(); 7180 GSM_Terminate();
7181 return; 7181 return;
7182 } 7182 }
7183 } 7183 }
7184 if (Size != Size2) { 7184 if (Size != Size2) {
7185 printmsgerr("Declared JAR file size is different than real\n"); 7185 printmsgerr("Declared JAR file size is different than real\n");
7186 GSM_Terminate(); 7186 GSM_Terminate();
7187 return; 7187 return;
7188 } 7188 }
7189 printmsgerr("Adding \"%s\"",Name); 7189 printmsgerr("Adding \"%s\"",Name);
7190 if (Version[0] != 0x00) printmsgerr(" version %s",Version); 7190 if (Version[0] != 0x00) printmsgerr(" version %s",Version);
7191 printmsgerr(" created by %s\n",Vendor); 7191 printmsgerr(" created by %s\n",Vendor);
7192 7192
7193 /* Bostjan Muller 3200 RH-30 3.08 */ 7193 /* Bostjan Muller 3200 RH-30 3.08 */
7194 if (strstr(JAR,"http://") != NULL) { 7194 if (strstr(JAR,"http://") != NULL) {
7195 i = strlen(JAR)-1; 7195 i = strlen(JAR)-1;
7196 while (JAR[i] != '/') i--; 7196 while (JAR[i] != '/') i--;
7197 strcpy(buffer,JAR+i+1); 7197 strcpy(buffer,JAR+i+1);
7198 strcpy(JAR,buffer); 7198 strcpy(JAR,buffer);
7199 dbgprintf("New file name is \"%s\"\n",JAR); 7199 dbgprintf("New file name is \"%s\"\n",JAR);
7200 } 7200 }
7201 7201
7202 /* Changing all #13 or #10 to #13#10 in JAD */ 7202 /* Changing all #13 or #10 to #13#10 in JAD */
7203 Pos = 0; 7203 Pos = 0;
7204 wasclr = false; 7204 wasclr = false;
7205 for (i=0;i<File.Used;i++) { 7205 for (i=0;i<File.Used;i++) {
7206 switch (File.Buffer[i]) { 7206 switch (File.Buffer[i]) {
7207 case 0x0D: 7207 case 0x0D:
7208 case 0x0A: 7208 case 0x0A:
7209 if (!wasclr) { 7209 if (!wasclr) {
7210 buffer[Pos++] = 0x0D; 7210 buffer[Pos++] = 0x0D;
7211 buffer[Pos++] = 0x0A; 7211 buffer[Pos++] = 0x0A;
7212 wasclr = true; 7212 wasclr = true;
7213 } else wasclr = false; 7213 } else wasclr = false;
7214 break; 7214 break;
7215 default: 7215 default:
7216 buffer[Pos++] = File.Buffer[i]; 7216 buffer[Pos++] = File.Buffer[i];
7217 wasclr = false; 7217 wasclr = false;
7218 } 7218 }
7219 } 7219 }
7220 File.Buffer = realloc(File.Buffer, Pos); 7220 File.Buffer = realloc(File.Buffer, Pos);
7221 File.Used = Pos; 7221 File.Used = Pos;
7222 memcpy(File.Buffer,buffer,Pos); 7222 memcpy(File.Buffer,buffer,Pos);
7223 7223
7224 /* adding folder */ 7224 /* adding folder */
7225 strcpy(buffer,Vendor); 7225 strcpy(buffer,Vendor);
7226 strcat(buffer,Name); 7226 strcat(buffer,Name);
7227 EncodeUnicode(File.Name,buffer,strlen(buffer)); 7227 EncodeUnicode(File.Name,buffer,strlen(buffer));
7228 strcpy(File.ID_FullName,Files.ID_FullName); 7228 strcpy(File.ID_FullName,Files.ID_FullName);
7229 error = Phone->AddFolder(&s,&File); 7229 error = Phone->AddFolder(&s,&File);
7230 Print_Error(error); 7230 Print_Error(error);
7231 strcpy(FileID,File.ID_FullName); 7231 strcpy(FileID,File.ID_FullName);
7232 7232
7233 /* adding jad file */ 7233 /* adding jad file */
7234 strcpy(buffer,JAR); 7234 strcpy(buffer,JAR);
7235 buffer[strlen(buffer) - 1] = 'd'; 7235 buffer[strlen(buffer) - 1] = 'd';
7236 EncodeUnicode(File.Name,buffer,strlen(buffer)); 7236 EncodeUnicode(File.Name,buffer,strlen(buffer));
7237 File.Type = GSM_File_Other; 7237 File.Type = GSM_File_Other;
7238 File.ModifiedEmpty = true; 7238 File.ModifiedEmpty = true;
7239 error = ERR_NONE; 7239 error = ERR_NONE;
7240 Pos = 0; 7240 Pos = 0;
7241 while (error == ERR_NONE) { 7241 while (error == ERR_NONE) {
7242 error = Phone->AddFilePart(&s,&File,&Pos); 7242 error = Phone->AddFilePart(&s,&File,&Pos);
7243 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); 7243 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
7244 printmsgerr("%cWriting JAD file: %i percent",13,Pos*100/File.Used); 7244 printmsgerr("%cWriting JAD file: %i percent",13,Pos*100/File.Used);
7245 } 7245 }
7246 printmsgerr("\n"); 7246 printmsgerr("\n");
7247 if (error == ERR_WRONGCRC) { 7247 if (error == ERR_WRONGCRC) {
7248 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); 7248 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
7249 } 7249 }
7250 7250
7251 if (argc > 4) { 7251 if (argc > 4) {
7252 if (mystrncasecmp(argv[4],"-readonly",0)) File.ReadOnly = true; 7252 if (mystrncasecmp(argv[4],"-readonly",0)) File.ReadOnly = true;
7253 } 7253 }
7254 7254
7255 /* reading jar file */ 7255 /* reading jar file */
7256 sprintf(buffer,"%s.jar",argv[3]); 7256 sprintf(buffer,"%s.jar",argv[3]);
7257 error = GSM_ReadFile(buffer, &File); 7257 error = GSM_ReadFile(buffer, &File);
7258 Print_Error(error); 7258 Print_Error(error);
7259 7259
7260 /* adding jar file */ 7260 /* adding jar file */
7261 strcpy(File.ID_FullName,FileID); 7261 strcpy(File.ID_FullName,FileID);
7262 strcpy(buffer,JAR); 7262 strcpy(buffer,JAR);
7263 EncodeUnicode(File.Name,buffer,strlen(buffer)); 7263 EncodeUnicode(File.Name,buffer,strlen(buffer));
7264 File.Type = GSM_File_Java_JAR; 7264 File.Type = GSM_File_Java_JAR;
7265 File.ModifiedEmpty = true; 7265 File.ModifiedEmpty = true;
7266 error = ERR_NONE; 7266 error = ERR_NONE;
7267 Pos = 0; 7267 Pos = 0;
7268 while (error == ERR_NONE) { 7268 while (error == ERR_NONE) {
7269 error = Phone->AddFilePart(&s,&File,&Pos); 7269 error = Phone->AddFilePart(&s,&File,&Pos);
7270 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); 7270 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
7271 printmsgerr("%cWriting JAR file: %i percent",13,Pos*100/File.Used); 7271 printmsgerr("%cWriting JAR file: %i percent",13,Pos*100/File.Used);
7272 } 7272 }
7273 printmsgerr("\n"); 7273 printmsgerr("\n");
7274 if (error == ERR_WRONGCRC) { 7274 if (error == ERR_WRONGCRC) {
7275 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); 7275 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
7276 } 7276 }
7277 7277
7278 free(File.Buffer); 7278 free(File.Buffer);
7279 GSM_Terminate(); 7279 GSM_Terminate();
7280 return; 7280 return;
7281 } 7281 }
7282 7282
7283 if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) { 7283 if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) {
7284 strcpy(buffer,argv[3]); 7284 strcpy(buffer,argv[3]);
7285 if (argc > 4) { 7285 if (argc > 4) {
7286 nextlong = 0; 7286 nextlong = 0;
7287 for (i=4;i<argc;i++) { 7287 for (i=4;i<argc;i++) {
7288 switch(nextlong) { 7288 switch(nextlong) {
7289 case 0: 7289 case 0:
7290 if (mystrncasecmp(argv[i],"-name",0)) { 7290 if (mystrncasecmp(argv[i],"-name",0)) {
7291 nextlong = 1; 7291 nextlong = 1;
7292 continue; 7292 continue;
7293 } 7293 }
7294 if (mystrncasecmp(argv[i],"-protected",0)) { 7294 if (mystrncasecmp(argv[i],"-protected",0)) {
7295 File.Protected = true; 7295 File.Protected = true;
7296 continue; 7296 continue;
7297 } 7297 }
7298 if (mystrncasecmp(argv[i],"-readonly",0)) { 7298 if (mystrncasecmp(argv[i],"-readonly",0)) {
7299 File.ReadOnly = true; 7299 File.ReadOnly = true;
7300 continue; 7300 continue;
7301 } 7301 }
7302 if (mystrncasecmp(argv[i],"-hidden",0)) { 7302 if (mystrncasecmp(argv[i],"-hidden",0)) {
7303 File.Hidden = true; 7303 File.Hidden = true;
7304 continue; 7304 continue;
7305 } 7305 }
7306 if (mystrncasecmp(argv[i],"-system",0)) { 7306 if (mystrncasecmp(argv[i],"-system",0)) {
7307 File.System = true; 7307 File.System = true;
7308 continue; 7308 continue;
7309 } 7309 }
7310 if (mystrncasecmp(argv[i],"-newtime",0)) { 7310 if (mystrncasecmp(argv[i],"-newtime",0)) {
7311 ModEmpty = true; 7311 ModEmpty = true;
7312 continue; 7312 continue;
7313 } 7313 }
7314 printmsg("Parameter \"%s\" unknown\n",argv[i]); 7314 printmsg("Parameter \"%s\" unknown\n",argv[i]);
7315 exit(-1); 7315 exit(-1);
7316 case 1: 7316 case 1:
7317 strcpy(buffer,argv[i]); 7317 strcpy(buffer,argv[i]);
7318 nextlong = 0; 7318 nextlong = 0;
7319 break; 7319 break;
7320 } 7320 }
7321 } 7321 }
7322 if (nextlong!=0) { 7322 if (nextlong!=0) {
7323 printmsg("Parameter missed...\n"); 7323 printmsg("Parameter missed...\n");
7324 exit(-1); 7324 exit(-1);
7325 } 7325 }
7326 } 7326 }
7327 } else { /* MMS things */ 7327 } else { /* MMS things */
7328 DT2.Year = 2001; 7328 DT2.Year = 2001;
7329 DT2.Month = 12; 7329 DT2.Month = 12;
7330 DT2.Day = 31; 7330 DT2.Day = 31;
7331 DT2.Hour = 14; 7331 DT2.Hour = 14;
7332 DT2.Minute = 00; 7332 DT2.Minute = 00;
7333 DT2.Second = 00; 7333 DT2.Second = 00;
7334 t_time2 = Fill_Time_T(DT2,8); 7334 t_time2 = Fill_Time_T(DT2,8);
7335 7335
7336 GSM_GetCurrentDateTime(&DT); 7336 GSM_GetCurrentDateTime(&DT);
7337 t_time1 = Fill_Time_T(DT,8); 7337 t_time1 = Fill_Time_T(DT,8);
7338 7338
7339 sprintf(buffer,"%07X %07X ",(int)(t_time1-t_time2-40),(int)(t_time1-t_time2-40)); 7339 sprintf(buffer,"%07X %07X ",(int)(t_time1-t_time2-40),(int)(t_time1-t_time2-40));
7340#ifdef DEVELOP 7340#ifdef DEVELOP
7341 sprintf(buffer,"2A947BD 2A947DB "); 7341 sprintf(buffer,"2A947BD 2A947DB ");
7342#endif 7342#endif
7343 /* 40 = inbox "multimedia message received" message */ 7343 /* 40 = inbox "multimedia message received" message */
7344 /* 30 = outbox sending failed */ 7344 /* 30 = outbox sending failed */
7345 if (mystrncasecmp(argv[2],"MMSUnreadInbox",0)) strcat(buffer,"43 "); 7345 if (mystrncasecmp(argv[2],"MMSUnreadInbox",0)) strcat(buffer,"43 ");
7346 else if (mystrncasecmp(argv[2],"MMSReadInbox",0)) strcat(buffer,"50 "); 7346 else if (mystrncasecmp(argv[2],"MMSReadInbox",0)) strcat(buffer,"50 ");
7347 else if (mystrncasecmp(argv[2],"MMSOutbox",0)) strcat(buffer,"10 "); 7347 else if (mystrncasecmp(argv[2],"MMSOutbox",0)) strcat(buffer,"10 ");
7348 else if (mystrncasecmp(argv[2],"MMSSent",0)) strcat(buffer,"20 "); 7348 else if (mystrncasecmp(argv[2],"MMSSent",0)) strcat(buffer,"20 ");
7349 else if (mystrncasecmp(argv[2],"MMSDrafts",0)) strcat(buffer,"61 "); 7349 else if (mystrncasecmp(argv[2],"MMSDrafts",0)) strcat(buffer,"61 ");
7350 if (argc > 4) { 7350 if (argc > 4) {
7351 if (!mystrncasecmp(argv[2],"MMSOutbox",0) && 7351 if (!mystrncasecmp(argv[2],"MMSOutbox",0) &&
7352 !mystrncasecmp(argv[2],"MMSSent",0)) { 7352 !mystrncasecmp(argv[2],"MMSSent",0)) {
7353 sprintf(Name,"%s",argv[4]); 7353 sprintf(Name,"%s",argv[4]);
7354 strcat(buffer,Name); 7354 strcat(buffer,Name);
7355 } 7355 }
7356 if (argc > 5) { 7356 if (argc > 5) {
7357 sprintf(Name,"%zd%s/TYPE=PLMN",strlen(argv[5])+10,argv[5]); 7357 sprintf(Name,"%zd%s/TYPE=PLMN",strlen(argv[5])+10,argv[5]);
7358 strcat(buffer,Name); 7358 strcat(buffer,Name);
7359 } 7359 }
7360 } 7360 }
7361 ModEmpty = true; 7361 ModEmpty = true;
7362 } 7362 }
7363 7363
7364 error = GSM_ReadFile(argv[3], &File); 7364 error = GSM_ReadFile(argv[3], &File);
7365 Print_Error(error); 7365 Print_Error(error);
7366 if (ModEmpty) File.ModifiedEmpty = true; 7366 if (ModEmpty) File.ModifiedEmpty = true;
7367 7367
7368 strcpy(File.ID_FullName,Files.ID_FullName); 7368 strcpy(File.ID_FullName,Files.ID_FullName);
7369 EncodeUnicode(File.Name,buffer,strlen(buffer)); 7369 EncodeUnicode(File.Name,buffer,strlen(buffer));
7370 GSM_IdentifyFileFormat(&File); 7370 GSM_IdentifyFileFormat(&File);
7371#ifdef DEVELOP 7371#ifdef DEVELOP
7372 if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) { 7372 if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) {
7373 } else { /* MMS things */ 7373 } else { /* MMS things */
7374 File.Type = GSM_File_MMS; 7374 File.Type = GSM_File_MMS;
7375 } 7375 }
7376#endif 7376#endif
7377 7377
7378 dbgprintf("Adding file to filesystem now\n"); 7378 dbgprintf("Adding file to filesystem now\n");
7379 error = ERR_NONE; 7379 error = ERR_NONE;
7380 Pos= 0; 7380 Pos= 0;
7381 while (error == ERR_NONE) { 7381 while (error == ERR_NONE) {
7382 error = Phone->AddFilePart(&s,&File,&Pos); 7382 error = Phone->AddFilePart(&s,&File,&Pos);
7383 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); 7383 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
7384 if (File.Used != 0) printmsgerr("%cWriting file: %i percent",13,Pos*100/File.Used); 7384 if (File.Used != 0) printmsgerr("%cWriting file: %i percent",13,Pos*100/File.Used);
7385 } 7385 }
7386 printmsgerr("\n"); 7386 printmsgerr("\n");
7387 if (error == ERR_WRONGCRC) { 7387 if (error == ERR_WRONGCRC) {
7388 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); 7388 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
7389 } 7389 }
7390 7390
7391 free(File.Buffer); 7391 free(File.Buffer);
7392 GSM_Terminate(); 7392 GSM_Terminate();
7393} 7393}
7394 7394
7395static void DeleteFiles(int argc, char *argv[]) 7395static void DeleteFiles(int argc, char *argv[])
7396{ 7396{
7397 int i; 7397 int i;
7398 7398
7399 GSM_Init(true); 7399 GSM_Init(true);
7400 7400
7401 for (i=2;i<argc;i++) { 7401 for (i=2;i<argc;i++) {
7402 error = Phone->DeleteFile(&s,argv[i]); 7402 error = Phone->DeleteFile(&s,argv[i]);
7403 Print_Error(error); 7403 Print_Error(error);
7404 } 7404 }
7405 7405
7406 GSM_Terminate(); 7406 GSM_Terminate();
7407} 7407}
7408 7408
7409static void SaveMMSFile(int argc, char *argv[]) 7409static void SaveMMSFile(int argc, char *argv[])
7410{ 7410{
7411 FILE *file; 7411 FILE *file;
7412 unsigned char Buffer[50000],Buffer2[20][2010]; 7412 unsigned char Buffer[50000],Buffer2[20][2010];
7413 int i,nextlong = 0,len = 0; 7413 int i,nextlong = 0,len = 0;
7414 GSM_EncodeMultiPartMMSInfo Info; 7414 GSM_EncodeMultiPartMMSInfo Info;
7415 7415
7416 GSM_ClearMultiPartMMSInfo(&Info); 7416 GSM_ClearMultiPartMMSInfo(&Info);
7417 7417
7418 for (i=3;i<argc;i++) { 7418 for (i=3;i<argc;i++) {
7419 switch (nextlong) { 7419 switch (nextlong) {
7420 case 0: 7420 case 0:
7421 if (mystrncasecmp(argv[i],"-subject",0)) { 7421 if (mystrncasecmp(argv[i],"-subject",0)) {
7422 nextlong=1; 7422 nextlong=1;
7423 continue; 7423 continue;
7424 } 7424 }
7425 if (mystrncasecmp(argv[i],"-text",0)) { 7425 if (mystrncasecmp(argv[i],"-text",0)) {
7426 nextlong=2; 7426 nextlong=2;
7427 continue; 7427 continue;
7428 } 7428 }
7429 if (mystrncasecmp(argv[i],"-from",0)) { 7429 if (mystrncasecmp(argv[i],"-from",0)) {
7430 nextlong=3; 7430 nextlong=3;
7431 continue; 7431 continue;
7432 } 7432 }
7433 if (mystrncasecmp(argv[i],"-to",0)) { 7433 if (mystrncasecmp(argv[i],"-to",0)) {
7434 nextlong=4; 7434 nextlong=4;
7435 continue; 7435 continue;
7436 } 7436 }
7437 printmsg("Unknown parameter (\"%s\")\n",argv[i]); 7437 printmsg("Unknown parameter (\"%s\")\n",argv[i]);
7438 exit(-1); 7438 exit(-1);
7439 break; 7439 break;
7440 case 1: /* Subject */ 7440 case 1: /* Subject */
7441 EncodeUnicode(Info.Subject,argv[i],strlen(argv[i])); 7441 EncodeUnicode(Info.Subject,argv[i],strlen(argv[i]));
7442 nextlong = 0; 7442 nextlong = 0;
7443 break; 7443 break;
7444 case 2: /* Text */ 7444 case 2: /* Text */
7445 EncodeUnicode(Buffer2[Info.EntriesNum],argv[i],strlen(argv[i])); 7445 EncodeUnicode(Buffer2[Info.EntriesNum],argv[i],strlen(argv[i]));
7446 Info.Entries[Info.EntriesNum].ID = MMS_Text; 7446 Info.Entries[Info.EntriesNum].ID = MMS_Text;
7447 Info.Entries[Info.EntriesNum].Buffer = Buffer2[Info.EntriesNum]; 7447 Info.Entries[Info.EntriesNum].Buffer = Buffer2[Info.EntriesNum];
7448 Info.EntriesNum++; 7448 Info.EntriesNum++;
7449 nextlong = 0; 7449 nextlong = 0;
7450 break; 7450 break;
7451 case 3: /* From */ 7451 case 3: /* From */
7452 EncodeUnicode(Info.Source,argv[i],strlen(argv[i])); 7452 EncodeUnicode(Info.Source,argv[i],strlen(argv[i]));
7453 nextlong = 0; 7453 nextlong = 0;
7454 break; 7454 break;
7455 case 4: /* To */ 7455 case 4: /* To */
7456 EncodeUnicode(Info.Destination,argv[i],strlen(argv[i])); 7456 EncodeUnicode(Info.Destination,argv[i],strlen(argv[i]));
7457 nextlong = 0; 7457 nextlong = 0;
7458 break; 7458 break;
7459 } 7459 }
7460 } 7460 }
7461 if (nextlong!=0) { 7461 if (nextlong!=0) {
7462 printmsg("Parameter missed...\n"); 7462 printmsg("Parameter missed...\n");
7463 exit(-1); 7463 exit(-1);
7464 } 7464 }
7465 7465
7466 GSM_EncodeMMSFile(&Info,Buffer,&len); 7466 GSM_EncodeMMSFile(&Info,Buffer,&len);
7467 7467
7468 file = fopen(argv[2],"wb"); 7468 file = fopen(argv[2],"wb");
7469 if (file == NULL) Print_Error(ERR_CANTOPENFILE); 7469 if (file == NULL) Print_Error(ERR_CANTOPENFILE);
7470 fwrite(Buffer,1,len,file); 7470 fwrite(Buffer,1,len,file);
7471 fclose(file); 7471 fclose(file);
7472} 7472}
7473 7473
7474static void CallDivert(int argc, char *argv[]) 7474static void CallDivert(int argc, char *argv[])
7475{ 7475{
7476 GSM_MultiCallDivert cd; 7476 GSM_MultiCallDivert cd;
7477 7477
7478 if (mystrncasecmp("get",argv[2],0)) {} 7478 if (mystrncasecmp("get",argv[2],0)) {}
7479 else if (mystrncasecmp("set",argv[2],0)) {} 7479 else if (mystrncasecmp("set",argv[2],0)) {}
7480 else { 7480 else {
7481 printmsg("Unknown divert action (\"%s\")\n",argv[2]); 7481 printmsg("Unknown divert action (\"%s\")\n",argv[2]);
7482 exit(-1); 7482 exit(-1);
7483 } 7483 }
7484 7484
7485 if (mystrncasecmp("all" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_AllTypes ;} 7485 if (mystrncasecmp("all" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_AllTypes ;}
7486 else if (mystrncasecmp("busy" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_Busy ;} 7486 else if (mystrncasecmp("busy" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_Busy ;}
7487 else if (mystrncasecmp("noans" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_NoAnswer ;} 7487 else if (mystrncasecmp("noans" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_NoAnswer ;}
7488 else if (mystrncasecmp("outofreach", argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_OutOfReach;} 7488 else if (mystrncasecmp("outofreach", argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_OutOfReach;}
7489 else { 7489 else {
7490 printmsg("Unknown divert type (\"%s\")\n",argv[3]); 7490 printmsg("Unknown divert type (\"%s\")\n",argv[3]);
7491 exit(-1); 7491 exit(-1);
7492 } 7492 }
7493 7493
7494 if (mystrncasecmp("all" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_AllCalls ;} 7494 if (mystrncasecmp("all" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_AllCalls ;}
7495 else if (mystrncasecmp("voice", argv[4],0)) {cd.Request.CallType = GSM_DIVERT_VoiceCalls;} 7495 else if (mystrncasecmp("voice", argv[4],0)) {cd.Request.CallType = GSM_DIVERT_VoiceCalls;}
7496 else if (mystrncasecmp("fax" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_FaxCalls ;} 7496 else if (mystrncasecmp("fax" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_FaxCalls ;}
7497 else if (mystrncasecmp("data" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_DataCalls ;} 7497 else if (mystrncasecmp("data" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_DataCalls ;}
7498 else { 7498 else {
7499 printmsg("Unknown call type (\"%s\")\n",argv[4]); 7499 printmsg("Unknown call type (\"%s\")\n",argv[4]);
7500 exit(-1); 7500 exit(-1);
7501 } 7501 }
7502 7502
7503 GSM_Init(true); 7503 GSM_Init(true);
7504 7504
7505 if (mystrncasecmp("get", argv[2],0)) { 7505 if (mystrncasecmp("get", argv[2],0)) {
7506 error = Phone->GetCallDivert(&s,&cd); 7506 error = Phone->GetCallDivert(&s,&cd);
7507 Print_Error(error); 7507 Print_Error(error);
7508 printmsg("Query:\n Divert type: "); 7508 printmsg("Query:\n Divert type: ");
7509 } else { 7509 } else {
7510 cd.Request.Number[0] = 0; 7510 cd.Request.Number[0] = 0;
7511 cd.Request.Number[1] = 0; 7511 cd.Request.Number[1] = 0;
7512 if (argc > 5) EncodeUnicode(cd.Request.Number,argv[5],strlen(argv[5])); 7512 if (argc > 5) EncodeUnicode(cd.Request.Number,argv[5],strlen(argv[5]));
7513 7513
7514 cd.Request.Timeout = 0; 7514 cd.Request.Timeout = 0;
7515 if (argc > 6) cd.Request.Timeout = atoi(argv[6]); 7515 if (argc > 6) cd.Request.Timeout = atoi(argv[6]);
7516 7516
7517 error = Phone->SetCallDivert(&s,&cd); 7517 error = Phone->SetCallDivert(&s,&cd);
7518 Print_Error(error); 7518 Print_Error(error);
7519 printmsg("Changed:\n Divert type: "); 7519 printmsg("Changed:\n Divert type: ");
7520 } 7520 }
7521 7521
7522 switch (cd.Request.DivertType) { 7522 switch (cd.Request.DivertType) {
7523 case GSM_DIVERT_Busy : printmsg("when busy"); break; 7523 case GSM_DIVERT_Busy : printmsg("when busy"); break;
7524 case GSM_DIVERT_NoAnswer : printmsg("when not answered"); break; 7524 case GSM_DIVERT_NoAnswer : printmsg("when not answered"); break;
7525 case GSM_DIVERT_OutOfReach: printmsg("when phone off or no coverage");break; 7525 case GSM_DIVERT_OutOfReach: printmsg("when phone off or no coverage");break;
7526 case GSM_DIVERT_AllTypes : printmsg("all types of diverts"); break; 7526 case GSM_DIVERT_AllTypes : printmsg("all types of diverts"); break;
7527 default : printmsg("unknown %i",cd.Request.DivertType); break; 7527 default : printmsg("unknown %i",cd.Request.DivertType); break;
7528 } 7528 }
7529 printmsg("\n Calls type : "); 7529 printmsg("\n Calls type : ");
7530 switch (cd.Request.CallType) { 7530 switch (cd.Request.CallType) {
7531 case GSM_DIVERT_VoiceCalls: printmsg("voice"); break; 7531 case GSM_DIVERT_VoiceCalls: printmsg("voice"); break;
7532 case GSM_DIVERT_FaxCalls : printmsg("fax"); break; 7532 case GSM_DIVERT_FaxCalls : printmsg("fax"); break;
7533 case GSM_DIVERT_DataCalls : printmsg("data"); break; 7533 case GSM_DIVERT_DataCalls : printmsg("data"); break;
7534 case GSM_DIVERT_AllCalls : printmsg("data & fax & voice"); break; 7534 case GSM_DIVERT_AllCalls : printmsg("data & fax & voice"); break;
7535 default : printmsg("unknown %i",cd.Request.CallType); break; 7535 default : printmsg("unknown %i",cd.Request.CallType); break;
7536 } 7536 }
7537 printmsg("\nResponse:"); 7537 printmsg("\nResponse:");
7538 7538
7539 for (i=0;i<cd.Response.EntriesNum;i++) { 7539 for (i=0;i<cd.Response.EntriesNum;i++) {
7540 printmsg("\n Calls type : "); 7540 printmsg("\n Calls type : ");
7541 switch (cd.Response.Entries[i].CallType) { 7541 switch (cd.Response.Entries[i].CallType) {
7542 case GSM_DIVERT_VoiceCalls: printmsg("voice"); break; 7542 case GSM_DIVERT_VoiceCalls: printmsg("voice"); break;
7543 case GSM_DIVERT_FaxCalls : printmsg("fax"); break; 7543 case GSM_DIVERT_FaxCalls : printmsg("fax"); break;
7544 case GSM_DIVERT_DataCalls : printmsg("data"); break; 7544 case GSM_DIVERT_DataCalls : printmsg("data"); break;
7545 default : printmsg("unknown %i",cd.Response.Entries[i].CallType);break; 7545 default : printmsg("unknown %i",cd.Response.Entries[i].CallType);break;
7546 } 7546 }
7547 printf("\n"); 7547 printf("\n");
7548 printmsg(" Timeout : %i seconds\n",cd.Response.Entries[i].Timeout); 7548 printmsg(" Timeout : %i seconds\n",cd.Response.Entries[i].Timeout);
7549 printmsg(" Number : %s\n",DecodeUnicodeString(cd.Response.Entries[i].Number)); 7549 printmsg(" Number : %s\n",DecodeUnicodeString(cd.Response.Entries[i].Number));
7550 } 7550 }
7551 printf("\n"); 7551 printf("\n");
7552 7552
7553 GSM_Terminate(); 7553 GSM_Terminate();
7554} 7554}
7555 7555
7556 7556
7557//#if 0 7557//#if 0
7558static void CancelAllDiverts(int argc, char *argv[]) 7558static void CancelAllDiverts(int argc, char *argv[])
7559{ 7559{
7560 GSM_Init(true); 7560 GSM_Init(true);
7561 7561
7562 error = Phone->CancelAllDiverts(&s); 7562 error = Phone->CancelAllDiverts(&s);
7563 Print_Error(error); 7563 Print_Error(error);
7564 7564
7565 GSM_Terminate(); 7565 GSM_Terminate();
7566} 7566}
7567 7567
7568 7568
7569 7569
7570void SearchPhoneThread(OneDeviceInfo *Info) 7570void SearchPhoneThread(OneDeviceInfo *Info)
7571{ 7571{
7572 int j; 7572 int j;
7573 GSM_Error error; 7573 GSM_Error error;
7574 fprintf(stderr,"*********************************** \n"); 7574 fprintf(stderr,"*********************************** \n");
7575 fprintf(stderr,"*********************************** \n"); 7575 fprintf(stderr,"*********************************** \n");
7576 fprintf(stderr,"*********************************** \n"); 7576 fprintf(stderr,"*********************************** \n");
7577 fprintf(stderr,"*********************************** \n"); 7577 fprintf(stderr,"*********************************** \n");
7578 fprintf(stderr,"*********************************** \n"); 7578 fprintf(stderr,"*********************************** \n");
7579#if 0 7579#if 0
7580 j = 0; 7580 j = 0;
7581 while(strlen(Info->Connections[j].Connection) != 0) { 7581 while(strlen(Info->Connections[j].Connection) != 0) {
7582 memcpy(&Info->s.di,&s.di,sizeof(Debug_Info)); 7582 memcpy(&Info->s.di,&s.di,sizeof(Debug_Info));
7583 Info->s.msg = s.msg; 7583 Info->s.msg = s.msg;
7584 Info->s.ConfigNum = 1; 7584 Info->s.ConfigNum = 1;
7585 Info->s.opened = false; 7585 Info->s.opened = false;
7586 Info->s.Config[0].UseGlobalDebugFile = s.Config[0].UseGlobalDebugFile; 7586 Info->s.Config[0].UseGlobalDebugFile = s.Config[0].UseGlobalDebugFile;
7587 Info->s.Config[0].Localize = s.Config[0].Localize; 7587 Info->s.Config[0].Localize = s.Config[0].Localize;
7588 Info->s.Config[0].Device = Info->Device; 7588 Info->s.Config[0].Device = Info->Device;
7589 Info->s.Config[0].Connection = Info->Connections[j].Connection; 7589 Info->s.Config[0].Connection = Info->Connections[j].Connection;
7590 Info->s.Config[0].SyncTime = "no"; 7590 Info->s.Config[0].SyncTime = "no";
7591 Info->s.Config[0].DebugFile = s.Config[0].DebugFile; 7591 Info->s.Config[0].DebugFile = s.Config[0].DebugFile;
7592 Info->s.Config[0].Model[0] = 0; 7592 Info->s.Config[0].Model[0] = 0;
7593 strcpy(Info->s.Config[0].DebugLevel,s.Config[0].DebugLevel); 7593 strcpy(Info->s.Config[0].DebugLevel,s.Config[0].DebugLevel);
7594 Info->s.Config[0].LockDevice = "no"; 7594 Info->s.Config[0].LockDevice = "no";
7595 Info->s.Config[0].StartInfo = "no"; 7595 Info->s.Config[0].StartInfo = "no";
7596 7596
7597 error = GSM_InitConnection(&Info->s,1); 7597 error = GSM_InitConnection(&Info->s,1);
7598 if (SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device); 7598 if (SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device);
7599 if (error == ERR_NONE) { 7599 if (error == ERR_NONE) {
7600 error=Info->s.Phone.Functions->GetManufacturer(&Info->s); 7600 error=Info->s.Phone.Functions->GetManufacturer(&Info->s);
7601 if (error == ERR_NONE) { 7601 if (error == ERR_NONE) {
7602 error=Info->s.Phone.Functions->GetModel(&Info->s); 7602 error=Info->s.Phone.Functions->GetModel(&Info->s);
7603 if (error == ERR_NONE) { 7603 if (error == ERR_NONE) {
7604 if (!SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device); 7604 if (!SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device);
7605 printmsg(" Manufacturer : %s\n", 7605 printmsg(" Manufacturer : %s\n",
7606 Info->s.Phone.Data.Manufacturer); 7606 Info->s.Phone.Data.Manufacturer);
7607 printmsg(" Model : %s (%s)\n", 7607 printmsg(" Model : %s (%s)\n",
7608 Info->s.Phone.Data.ModelInfo->model, 7608 Info->s.Phone.Data.ModelInfo->model,
7609 Info->s.Phone.Data.Model); 7609 Info->s.Phone.Data.Model);
7610 } else { 7610 } else {
7611 if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg)); 7611 if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg));
7612 } 7612 }
7613 } else { 7613 } else {
7614 if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg)); 7614 if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg));
7615 } 7615 }
7616 } else { 7616 } else {
7617 if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg)); 7617 if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg));
7618 } 7618 }
7619 if (error != ERR_DEVICEOPENERROR) { 7619 if (error != ERR_DEVICEOPENERROR) {
7620 GSM_TerminateConnection(&Info->s); 7620 GSM_TerminateConnection(&Info->s);
7621 dbgprintf("Closing done\n"); 7621 dbgprintf("Closing done\n");
7622 } 7622 }
7623 if (error == ERR_DEVICEOPENERROR || error == ERR_NONE) break; 7623 if (error == ERR_DEVICEOPENERROR || error == ERR_NONE) break;
7624 j++; 7624 j++;
7625 } 7625 }
7626 num--; 7626 num--;
7627#endif 7627#endif
7628} 7628}
7629 7629
7630//#undef HAVE_PTHREAD 7630//#undef HAVE_PTHREAD
7631//#if 0 7631//#if 0
7632#if defined(WIN32) || defined(HAVE_PTHREAD) 7632#if defined(WIN32) || defined(HAVE_PTHREAD)
7633#ifdef HAVE_PTHREAD 7633#ifdef HAVE_PTHREAD
7634 pthread_t Thread[100]; 7634 pthread_t Thread[100];
7635#endif 7635#endif
7636 7636
7637void MakeSearchThread(int i) 7637void MakeSearchThread(int i)
7638{ 7638{
7639 num++; 7639 num++;
7640#ifdef HAVE_PTHREAD 7640#ifdef HAVE_PTHREAD
7641 if (pthread_create(&Thread[i],NULL,(void *)SearchPhoneThread,&SearchDevices[i])!=0) { 7641 if (pthread_create(&Thread[i],NULL,(void *)SearchPhoneThread,&SearchDevices[i])!=0) {
7642 dbgprintf("Error creating thread\n"); 7642 dbgprintf("Error creating thread\n");
7643 } 7643 }
7644#else 7644#else
7645 if (CreateThread((LPSECURITY_ATTRIBUTES)NULL,0, 7645 if (CreateThread((LPSECURITY_ATTRIBUTES)NULL,0,
7646 (LPTHREAD_START_ROUTINE)SearchPhoneThread,&SearchDevices[i], 7646 (LPTHREAD_START_ROUTINE)SearchPhoneThread,&SearchDevices[i],
7647 0,NULL)==NULL) { 7647 0,NULL)==NULL) {
7648 dbgprintf("Error creating thread\n"); 7648 dbgprintf("Error creating thread\n");
7649 } 7649 }
7650#endif 7650#endif
7651} 7651}
7652 7652
7653static void SearchPhone(int argc, char *argv[]) 7653static void SearchPhone(int argc, char *argv[])
7654{ 7654{
7655 int i,dev = 0, dev2 = 0; 7655 int i,dev = 0, dev2 = 0;
7656 7656
7657 SearchOutput = false; 7657 SearchOutput = false;
7658 if (argc == 3 && mystrncasecmp(argv[2], "-debug",0)) SearchOutput = true; 7658 if (argc == 3 && mystrncasecmp(argv[2], "-debug",0)) SearchOutput = true;
7659 7659
7660 num = 0; 7660 num = 0;
7661#ifdef WIN32 7661#ifdef WIN32
7662# ifdef GSM_ENABLE_IRDADEVICE 7662# ifdef GSM_ENABLE_IRDADEVICE
7663 sprintf(SearchDevices[dev].Device,""); 7663 sprintf(SearchDevices[dev].Device,"");
7664 sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet"); 7664 sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet");
7665 SearchDevices[dev].Connections[1].Connection[0] = 0; 7665 SearchDevices[dev].Connections[1].Connection[0] = 0;
7666 dev++; 7666 dev++;
7667# endif 7667# endif
7668# ifdef GSM_ENABLE_SERIALDEVICE 7668# ifdef GSM_ENABLE_SERIALDEVICE
7669 dev2 = dev; 7669 dev2 = dev;
7670 for(i=0;i<10;i++) { 7670 for(i=0;i<10;i++) {
7671 sprintf(SearchDevices[dev2].Device,"com%i:",i+1); 7671 sprintf(SearchDevices[dev2].Device,"com%i:",i+1);
7672 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); 7672 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
7673 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); 7673 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
7674 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); 7674 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
7675 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); 7675 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
7676 SearchDevices[dev2].Connections[4].Connection[0] = 0; 7676 SearchDevices[dev2].Connections[4].Connection[0] = 0;
7677 dev2++; 7677 dev2++;
7678 } 7678 }
7679# endif 7679# endif
7680#endif 7680#endif
7681#ifdef __linux__ 7681#ifdef __linux__
7682# ifdef GSM_ENABLE_IRDADEVICE 7682# ifdef GSM_ENABLE_IRDADEVICE
7683 for(i=0;i<6;i++) { 7683 for(i=0;i<6;i++) {
7684 sprintf(SearchDevices[dev].Device,"/dev/ircomm%i",i); 7684 sprintf(SearchDevices[dev].Device,"/dev/ircomm%i",i);
7685 sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet"); 7685 sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet");
7686 sprintf(SearchDevices[dev].Connections[1].Connection,"at19200"); 7686 sprintf(SearchDevices[dev].Connections[1].Connection,"at19200");
7687 SearchDevices[dev].Connections[2].Connection[0] = 0; 7687 SearchDevices[dev].Connections[2].Connection[0] = 0;
7688 dev++; 7688 dev++;
7689 } 7689 }
7690# endif 7690# endif
7691# ifdef GSM_ENABLE_SERIALDEVICE 7691# ifdef GSM_ENABLE_SERIALDEVICE
7692 dev2 = dev; 7692 dev2 = dev;
7693 for(i=0;i<10;i++) { 7693 for(i=0;i<10;i++) {
7694 sprintf(SearchDevices[dev2].Device,"/dev/ttyS%i",i); 7694 sprintf(SearchDevices[dev2].Device,"/dev/ttyS%i",i);
7695 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); 7695 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
7696 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); 7696 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
7697 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); 7697 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
7698 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); 7698 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
7699 SearchDevices[dev2].Connections[4].Connection[0] = 0; 7699 SearchDevices[dev2].Connections[4].Connection[0] = 0;
7700 dev2++; 7700 dev2++;
7701 } 7701 }
7702 for(i=0;i<8;i++) { 7702 for(i=0;i<8;i++) {
7703 sprintf(SearchDevices[dev2].Device,"/dev/ttyD00%i",i); 7703 sprintf(SearchDevices[dev2].Device,"/dev/ttyD00%i",i);
7704 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); 7704 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
7705 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); 7705 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
7706 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); 7706 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
7707 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); 7707 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
7708 SearchDevices[dev2].Connections[4].Connection[0] = 0; 7708 SearchDevices[dev2].Connections[4].Connection[0] = 0;
7709 dev2++; 7709 dev2++;
7710 } 7710 }
7711 for(i=0;i<4;i++) { 7711 for(i=0;i<4;i++) {
7712 sprintf(SearchDevices[dev2].Device,"/dev/usb/tts/%i",i); 7712 sprintf(SearchDevices[dev2].Device,"/dev/usb/tts/%i",i);
7713 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); 7713 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
7714 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); 7714 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
7715 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); 7715 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
7716 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); 7716 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
7717 SearchDevices[dev2].Connections[4].Connection[0] = 0; 7717 SearchDevices[dev2].Connections[4].Connection[0] = 0;
7718 dev2++; 7718 dev2++;
7719 } 7719 }
7720# endif 7720# endif
7721#endif 7721#endif
7722 for(i=0;i<dev;i++) MakeSearchThread(i); 7722 for(i=0;i<dev;i++) MakeSearchThread(i);
7723 while (num != 0) my_sleep(5); 7723 while (num != 0) my_sleep(5);
7724 for(i=dev;i<dev2;i++) MakeSearchThread(i); 7724 for(i=dev;i<dev2;i++) MakeSearchThread(i);
7725 while (num != 0) my_sleep(5); 7725 while (num != 0) my_sleep(5);
7726} 7726}
7727#endif /*Support for threads */ 7727#endif /*Support for threads */
7728// #if 0 7728// #if 0
7729static void NokiaGetADC(int argc, char *argv[]) 7729static void NokiaGetADC(int argc, char *argv[])
7730{ 7730{
7731 GSM_Init(true); 7731 GSM_Init(true);
7732 7732
7733#ifdef GSM_ENABLE_NOKIA_DCT3 7733#ifdef GSM_ENABLE_NOKIA_DCT3
7734 DCT3GetADC(argc,argv); 7734 DCT3GetADC(argc,argv);
7735#endif 7735#endif
7736#ifdef GSM_ENABLE_NOKIA_DCT4 7736#ifdef GSM_ENABLE_NOKIA_DCT4
7737 DCT4GetADC(argc, argv); 7737 DCT4GetADC(argc, argv);
7738#endif 7738#endif
7739 7739
7740 GSM_Terminate(); 7740 GSM_Terminate();
7741} 7741}
7742 7742
7743static void NokiaDisplayTest(int argc, char *argv[]) 7743static void NokiaDisplayTest(int argc, char *argv[])
7744{ 7744{
7745 GSM_Init(true); 7745 GSM_Init(true);
7746 7746
7747#ifdef GSM_ENABLE_NOKIA_DCT3 7747#ifdef GSM_ENABLE_NOKIA_DCT3
7748 DCT3DisplayTest(argc,argv); 7748 DCT3DisplayTest(argc,argv);
7749#endif 7749#endif
7750#ifdef GSM_ENABLE_NOKIA_DCT4 7750#ifdef GSM_ENABLE_NOKIA_DCT4
7751 DCT4DisplayTest(argc, argv); 7751 DCT4DisplayTest(argc, argv);
7752#endif 7752#endif
7753 7753
7754 GSM_Terminate(); 7754 GSM_Terminate();
7755} 7755}
7756 7756
7757static void NokiaGetT9(int argc, char *argv[]) 7757static void NokiaGetT9(int argc, char *argv[])
7758{ 7758{
7759 GSM_Init(true); 7759 GSM_Init(true);
7760 7760
7761#ifdef GSM_ENABLE_NOKIA_DCT3 7761#ifdef GSM_ENABLE_NOKIA_DCT3
7762 DCT3GetT9(argc,argv); 7762 DCT3GetT9(argc,argv);
7763#endif 7763#endif
7764#ifdef GSM_ENABLE_NOKIA_DCT4 7764#ifdef GSM_ENABLE_NOKIA_DCT4
7765 DCT4GetT9(argc, argv); 7765 DCT4GetT9(argc, argv);
7766#endif 7766#endif
7767 7767
7768 GSM_Terminate(); 7768 GSM_Terminate();
7769} 7769}
7770 7770
7771static void NokiaVibraTest(int argc, char *argv[]) 7771static void NokiaVibraTest(int argc, char *argv[])
7772{ 7772{
7773 GSM_Init(true); 7773 GSM_Init(true);
7774 7774
7775#ifdef GSM_ENABLE_NOKIA_DCT3 7775#ifdef GSM_ENABLE_NOKIA_DCT3
7776 DCT3VibraTest(argc,argv); 7776 DCT3VibraTest(argc,argv);
7777#endif 7777#endif
7778#ifdef GSM_ENABLE_NOKIA_DCT4 7778#ifdef GSM_ENABLE_NOKIA_DCT4
7779 DCT4VibraTest(argc, argv); 7779 DCT4VibraTest(argc, argv);
7780#endif 7780#endif
7781 7781
7782 GSM_Terminate(); 7782 GSM_Terminate();
7783} 7783}
7784 7784
7785static GSM_Parameters Parameters[] = { 7785static GSM_Parameters Parameters[] = {
7786 {"--identify", 0, 0, Identify, {H_Info,0}, ""}, 7786 {"--identify", 0, 0, Identify, {H_Info,0}, ""},
7787 {"--version", 0, 0, Version, {H_Other,0}, ""}, 7787 {"--version", 0, 0, Version, {H_Other,0}, ""},
7788 {"--getdisplaystatus", 0, 0, GetDisplayStatus, {H_Info,0}, ""}, 7788 {"--getdisplaystatus", 0, 0, GetDisplayStatus, {H_Info,0}, ""},
7789 {"--monitor", 0, 1, Monitor, {H_Info,H_Network,H_Call,0},"[times]"}, 7789 {"--monitor", 0, 1, Monitor, {H_Info,H_Network,H_Call,0},"[times]"},
7790 {"--setautonetworklogin", 0, 0, SetAutoNetworkLogin, {H_Network,0}, ""}, 7790 {"--setautonetworklogin", 0, 0, SetAutoNetworkLogin, {H_Network,0}, ""},
7791 {"--listnetworks", 0, 0, ListNetworks, {H_Network,0}, ""}, 7791 {"--listnetworks", 0, 0, ListNetworks, {H_Network,0}, ""},
7792 {"--getgprspoint", 1, 2, GetGPRSPoint, {H_Nokia,H_Network,0}, "start [stop]"}, 7792 {"--getgprspoint", 1, 2, GetGPRSPoint, {H_Nokia,H_Network,0}, "start [stop]"},
7793 {"--addfolder", 2, 2, AddFolder, {H_Filesystem,0}, "parentfolderID name"}, 7793 {"--addfolder", 2, 2, AddFolder, {H_Filesystem,0}, "parentfolderID name"},
7794 {"--getfilesystem", 0, 1, GetFileSystem, {H_Filesystem,0}, "[-flatall|-flat]"}, 7794 {"--getfilesystem", 0, 1, GetFileSystem, {H_Filesystem,0}, "[-flatall|-flat]"},
7795 {"--getfilesystemstatus", 0, 0, GetFileSystemStatus, {H_Filesystem,0}, ""}, 7795 {"--getfilesystemstatus", 0, 0, GetFileSystemStatus, {H_Filesystem,0}, ""},
7796 {"--getfiles", 1,40, GetFiles, {H_Filesystem,0}, "ID1, ID2, ..."}, 7796 {"--getfiles", 1,40, GetFiles, {H_Filesystem,0}, "ID1, ID2, ..."},
7797 {"--getfilefolder", 1,40, GetFileFolder, {H_Filesystem,0}, "ID1, ID2, ..."}, 7797 {"--getfilefolder", 1,40, GetFileFolder, {H_Filesystem,0}, "ID1, ID2, ..."},
7798 {"--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]"}, 7798 {"--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]"},
7799 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"MMSUnreadInbox|MMSReadInbox|MMSOutbox|MMSDrafts|MMSSent file sender title"}, 7799 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"MMSUnreadInbox|MMSReadInbox|MMSOutbox|MMSDrafts|MMSSent file sender title"},
7800 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Application|Game file [-readonly]"}, 7800 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Application|Game file [-readonly]"},
7801 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Gallery|Tones file [-name name][-protected][-readonly][-system][-hidden][-newtime]"}, 7801 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Gallery|Tones file [-name name][-protected][-readonly][-system][-hidden][-newtime]"},
7802 {"--deletefiles", 1,20, DeleteFiles, {H_Filesystem,0}, "fileID"}, 7802 {"--deletefiles", 1,20, DeleteFiles, {H_Filesystem,0}, "fileID"},
7803 {"--playringtone", 1, 1, PlayRingtone, {H_Ringtone,0}, "file"}, 7803 {"--playringtone", 1, 1, PlayRingtone, {H_Ringtone,0}, "file"},
7804 {"--playsavedringtone", 1, 1, DCT4PlaySavedRingtone, {H_Ringtone,0}, ""}, 7804 {"--playsavedringtone", 1, 1, DCT4PlaySavedRingtone, {H_Ringtone,0}, ""},
7805 {"--getdatetime", 0, 0, GetDateTime, {H_DateTime,0}, ""}, 7805 {"--getdatetime", 0, 0, GetDateTime, {H_DateTime,0}, ""},
7806 {"--setdatetime", 0, 0, SetDateTime, {H_DateTime,0}, ""}, 7806 {"--setdatetime", 0, 0, SetDateTime, {H_DateTime,0}, ""},
7807 {"--getalarm", 0, 0, GetAlarm, {H_DateTime,0}, ""}, 7807 {"--getalarm", 0, 0, GetAlarm, {H_DateTime,0}, ""},
7808 {"--setalarm", 2, 2, SetAlarm, {H_DateTime,0}, "hour minute"}, 7808 {"--setalarm", 2, 2, SetAlarm, {H_DateTime,0}, "hour minute"},
7809 {"--resetphonesettings", 1, 1, ResetPhoneSettings, {H_Settings,0}, "PHONE|DEV|UIF|ALL|FACTORY"}, 7809 {"--resetphonesettings", 1, 1, ResetPhoneSettings, {H_Settings,0}, "PHONE|DEV|UIF|ALL|FACTORY"},
7810 {"--getmemory", 2, 3, GetMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD start [stop]"}, 7810 {"--getmemory", 2, 3, GetMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD start [stop]"},
7811 {"--getallmemory", 1, 1, GetAllMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD"}, 7811 {"--getallmemory", 1, 1, GetAllMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD"},
7812 {"--searchmemory", 1, 1, SearchMemory, {H_Memory,0}, "text"}, 7812 {"--searchmemory", 1, 1, SearchMemory, {H_Memory,0}, "text"},
7813 {"--listmemorycategory", 1, 1, ListMemoryCategory, {H_Memory, H_Category,0},"text|number"}, 7813 {"--listmemorycategory", 1, 1, ListMemoryCategory, {H_Memory, H_Category,0},"text|number"},
7814 {"--getfmstation", 1, 2, GetFMStation, {H_FM,0}, "start [stop]"}, 7814 {"--getfmstation", 1, 2, GetFMStation, {H_FM,0}, "start [stop]"},
7815 {"--getsmsc", 1, 2, GetSMSC, {H_SMS,0}, "start [stop]"}, 7815 {"--getsmsc", 1, 2, GetSMSC, {H_SMS,0}, "start [stop]"},
7816 {"--getsms", 2, 3, GetSMS, {H_SMS,0}, "folder start [stop]"}, 7816 {"--getsms", 2, 3, GetSMS, {H_SMS,0}, "folder start [stop]"},
7817 {"--deletesms", 2, 3, DeleteSMS, {H_SMS,0}, "folder start [stop]"}, 7817 {"--deletesms", 2, 3, DeleteSMS, {H_SMS,0}, "folder start [stop]"},
7818 {"--deleteallsms", 1, 1, DeleteAllSMS, {H_SMS,0}, "folder"}, 7818 {"--deleteallsms", 1, 1, DeleteAllSMS, {H_SMS,0}, "folder"},
7819 {"--getsmsfolders", 0, 0, GetSMSFolders, {H_SMS,0}, ""}, 7819 {"--getsmsfolders", 0, 0, GetSMSFolders, {H_SMS,0}, ""},
7820 {"--getallsms", 0, 0, GetAllSMS, {H_SMS,0}, ""}, 7820 {"--getallsms", 0, 0, GetAllSMS, {H_SMS,0}, ""},
7821 {"--geteachsms", 0, 0, GetEachSMS, {H_SMS,0}, ""}, 7821 {"--geteachsms", 0, 0, GetEachSMS, {H_SMS,0}, ""},
7822 7822
7823 #define SMS_TEXT_OPTIONS"[-inputunicode][-16bit][-flash][-len len][-autolen len][-unicode][-enablevoice][-disablevoice][-enablefax][-disablefax][-enableemail][-disableemail][-voidsms][-replacemessages ID][-replacefile file]" 7823 #define SMS_TEXT_OPTIONS"[-inputunicode][-16bit][-flash][-len len][-autolen len][-unicode][-enablevoice][-disablevoice][-enablefax][-disablefax][-enableemail][-disableemail][-voidsms][-replacemessages ID][-replacefile file]"
7824 #define SMS_PICTURE_OPTIONS"[-text text][-unicode][-alcatelbmmi]" 7824 #define SMS_PICTURE_OPTIONS"[-text text][-unicode][-alcatelbmmi]"
7825 #define SMS_PROFILE_OPTIONS"[-name name][-bitmap bitmap][-ringtone ringtone]" 7825 #define SMS_PROFILE_OPTIONS"[-name name][-bitmap bitmap][-ringtone ringtone]"
7826 #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]" 7826 #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]"
7827 #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 ...]" 7827 #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 ...]"
7828 #define SMS_ANIMATION_OPTIONS"" 7828 #define SMS_ANIMATION_OPTIONS""
7829 #define SMS_OPERATOR_OPTIONS"[-netcode netcode][-biglogo]" 7829 #define SMS_OPERATOR_OPTIONS"[-netcode netcode][-biglogo]"
7830 #define SMS_SAVE_OPTIONS"[-folder id][-unread][-read][-unsent][-sent][-sender number]" 7830 #define SMS_SAVE_OPTIONS"[-folder id][-unread][-read][-unsent][-sent][-sender number]"
7831 #define SMS_SEND_OPTIONS"[-report][-validity HOUR|6HOURS|DAY|3DAYS|WEEK|MAX][-save [-folder number]]" 7831 #define SMS_SEND_OPTIONS"[-report][-validity HOUR|6HOURS|DAY|3DAYS|WEEK|MAX][-save [-folder number]]"
7832 #define SMS_COMMON_OPTIONS"[-smscset number][-smscnumber number][-reply][-maxsms num]" 7832 #define SMS_COMMON_OPTIONS"[-smscset number][-smscnumber number][-reply][-maxsms num]"
7833 7833
7834 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS}, 7834 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS},
7835 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 7835 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
7836 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS}, 7836 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS},
7837 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 7837 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
7838 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS}, 7838 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS},
7839 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION frames file1 file2... " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS}, 7839 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION frames file1 file2... " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS},
7840 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR URL Title Sender " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 7840 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR URL Title Sender " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
7841#ifdef GSM_ENABLE_BACKUP 7841#ifdef GSM_ENABLE_BACKUP
7842 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 7842 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
7843 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS file location DATA|GPRS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 7843 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS file location DATA|GPRS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
7844 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 7844 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
7845 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 7845 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
7846 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 7846 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
7847 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 file SM|ME location [-nokia]" SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 7847 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 file SM|ME location [-nokia]" SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
7848#endif 7848#endif
7849 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PROFILE_OPTIONS}, 7849 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PROFILE_OPTIONS},
7850 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS}, 7850 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS},
7851 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS}, 7851 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS},
7852 7852
7853 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS}, 7853 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS},
7854 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 7854 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
7855 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS}, 7855 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS},
7856 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 7856 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
7857 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS}, 7857 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS},
7858 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION destination frames file1 file2... " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS}, 7858 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION destination frames file1 file2... " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS},
7859 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR destination URL Title Sender " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 7859 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR destination URL Title Sender " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
7860#ifdef GSM_ENABLE_BACKUP 7860#ifdef GSM_ENABLE_BACKUP
7861 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 7861 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
7862 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS destination file location DATA|GPRS " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 7862 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS destination file location DATA|GPRS " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
7863 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 7863 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
7864 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 7864 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
7865 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 7865 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
7866 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 destination file SM|ME location [-nokia]" SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 7866 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 destination file SM|ME location [-nokia]" SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
7867#endif 7867#endif
7868 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS ""SMS_PROFILE_OPTIONS}, 7868 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS ""SMS_PROFILE_OPTIONS},
7869 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS}, 7869 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS},
7870 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS}, 7870 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS},
7871 7871
7872 {"--displaysms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "... (options like in sendsms)"}, 7872 {"--displaysms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "... (options like in sendsms)"},
7873 7873
7874 {"--addsmsfolder", 1, 1, AddSMSFolder, {H_SMS,0}, "name"}, 7874 {"--addsmsfolder", 1, 1, AddSMSFolder, {H_SMS,0}, "name"},
7875#ifdef HAVE_MYSQL_MYSQL_H 7875#ifdef HAVE_MYSQL_MYSQL_H
7876 {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "MYSQL configfile"}, 7876 {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "MYSQL configfile"},
7877#endif 7877#endif
7878 {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "FILES configfile"}, 7878 {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "FILES configfile"},
7879 {"--sendsmsdsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Other,0}, "TEXT|WAPSETTINGS|... destination FILES|MYSQL configfile ... (options like in sendsms)"}, 7879 {"--sendsmsdsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Other,0}, "TEXT|WAPSETTINGS|... destination FILES|MYSQL configfile ... (options like in sendsms)"},
7880 {"--getringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"}, 7880 {"--getringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"},
7881 {"--getphoneringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"}, 7881 {"--getphoneringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"},
7882 {"--getringtoneslist", 0, 0, GetRingtonesList, {H_Ringtone,0}, ""}, 7882 {"--getringtoneslist", 0, 0, GetRingtonesList, {H_Ringtone,0}, ""},
7883 {"--setringtone", 1, 6, SetRingtone, {H_Ringtone,0}, "file [-location location][-scale][-name name]"}, 7883 {"--setringtone", 1, 6, SetRingtone, {H_Ringtone,0}, "file [-location location][-scale][-name name]"},
7884 {"--nokiacomposer", 1, 1, NokiaComposer, {H_Ringtone,H_Nokia,0}, "file"}, 7884 {"--nokiacomposer", 1, 1, NokiaComposer, {H_Ringtone,H_Nokia,0}, "file"},
7885 {"--copyringtone", 2, 3, CopyRingtone, {H_Ringtone,0}, "source destination [RTTL|BINARY]"}, 7885 {"--copyringtone", 2, 3, CopyRingtone, {H_Ringtone,0}, "source destination [RTTL|BINARY]"},
7886 {"--getussd", 1, 1, GetUSSD, {H_Call,0}, "code"}, 7886 {"--getussd", 1, 1, GetUSSD, {H_Call,0}, "code"},
7887 {"--dialvoice", 1, 2, DialVoice, {H_Call,0}, "number [show|hide]"}, 7887 {"--dialvoice", 1, 2, DialVoice, {H_Call,0}, "number [show|hide]"},
7888 {"--getspeeddial", 1, 2, GetSpeedDial, {H_Call,H_Memory,0}, "start [stop]"}, 7888 {"--getspeeddial", 1, 2, GetSpeedDial, {H_Call,H_Memory,0}, "start [stop]"},
7889 {"--cancelcall", 0, 1, CancelCall, {H_Call,0}, "[ID]"}, 7889 {"--cancelcall", 0, 1, CancelCall, {H_Call,0}, "[ID]"},
7890 {"--answercall", 0, 1, AnswerCall, {H_Call,0}, "[ID]"}, 7890 {"--answercall", 0, 1, AnswerCall, {H_Call,0}, "[ID]"},
7891 {"--unholdcall", 1, 1, UnholdCall, {H_Call,0}, "ID"}, 7891 {"--unholdcall", 1, 1, UnholdCall, {H_Call,0}, "ID"},
7892 {"--holdcall", 1, 1, HoldCall, {H_Call,0}, "ID"}, 7892 {"--holdcall", 1, 1, HoldCall, {H_Call,0}, "ID"},
7893 {"--conferencecall", 1, 1, ConferenceCall, {H_Call,0}, "ID"}, 7893 {"--conferencecall", 1, 1, ConferenceCall, {H_Call,0}, "ID"},
7894 {"--splitcall", 1, 1, SplitCall, {H_Call,0}, "ID"}, 7894 {"--splitcall", 1, 1, SplitCall, {H_Call,0}, "ID"},
7895 {"--switchcall", 0, 1, SwitchCall, {H_Call,0}, "[ID]"}, 7895 {"--switchcall", 0, 1, SwitchCall, {H_Call,0}, "[ID]"},
7896 {"--transfercall", 0, 1, TransferCall, {H_Call,0}, "[ID]"}, 7896 {"--transfercall", 0, 1, TransferCall, {H_Call,0}, "[ID]"},
7897 {"--divert", 3, 5, CallDivert, {H_Call,0}, "get|set all|busy|noans|outofreach all|voice|fax|data [number timeout]"}, 7897 {"--divert", 3, 5, CallDivert, {H_Call,0}, "get|set all|busy|noans|outofreach all|voice|fax|data [number timeout]"},
7898 {"--canceldiverts", 0, 0, CancelAllDiverts, {H_Call,0}, ""}, 7898 {"--canceldiverts", 0, 0, CancelAllDiverts, {H_Call,0}, ""},
7899 {"--senddtmf", 1, 1, SendDTMF, {H_Call,0}, "sequence"}, 7899 {"--senddtmf", 1, 1, SendDTMF, {H_Call,0}, "sequence"},
7900 {"--getcalendarsettings", 0, 0, GetCalendarSettings, {H_Calendar,H_Settings,0},""}, 7900 {"--getcalendarsettings", 0, 0, GetCalendarSettings, {H_Calendar,H_Settings,0},""},
7901 {"--getalltodo", 0, 0, GetAllToDo, {H_ToDo,0}, ""}, 7901 {"--getalltodo", 0, 0, GetAllToDo, {H_ToDo,0}, ""},
7902 {"--listtodocategory", 1, 1, ListToDoCategory, {H_ToDo, H_Category,0}, "text|number"}, 7902 {"--listtodocategory", 1, 1, ListToDoCategory, {H_ToDo, H_Category,0}, "text|number"},
7903 {"--gettodo", 1, 2, GetToDo, {H_ToDo,0}, "start [stop]"}, 7903 {"--gettodo", 1, 2, GetToDo, {H_ToDo,0}, "start [stop]"},
7904 {"--deletetodo", 1, 2, DeleteToDo, {H_ToDo,0}, "start [stop]"}, 7904 {"--deletetodo", 1, 2, DeleteToDo, {H_ToDo,0}, "start [stop]"},
7905 {"--getnote", 1, 2, GetNote, {H_Note,0}, "start [stop]"}, 7905 {"--getnote", 1, 2, GetNote, {H_Note,0}, "start [stop]"},
7906 {"--deletecalendar", 1, 2, DeleteCalendar, {H_Calendar,0}, "start [stop]"}, 7906 {"--deletecalendar", 1, 2, DeleteCalendar, {H_Calendar,0}, "start [stop]"},
7907 {"--getallcalendar", 0, 0, GetAllCalendar, {H_Calendar,0}, ""}, 7907 {"--getallcalendar", 0, 0, GetAllCalendar, {H_Calendar,0}, ""},
7908 {"--getcalendar", 1, 2, GetCalendar, {H_Calendar,0}, "start [stop]"}, 7908 {"--getcalendar", 1, 2, GetCalendar, {H_Calendar,0}, "start [stop]"},
7909 {"--getcategory", 2, 3, GetCategory, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK start [stop]"}, 7909 {"--getcategory", 2, 3, GetCategory, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK start [stop]"},
7910 {"--getallcategory", 1, 1, GetAllCategories, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK"}, 7910 {"--getallcategory", 1, 1, GetAllCategories, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK"},
7911 {"--reset", 1, 1, Reset, {H_Other,0}, "SOFT|HARD"}, 7911 {"--reset", 1, 1, Reset, {H_Other,0}, "SOFT|HARD"},
7912 {"--getprofile", 1, 2, GetProfile, {H_Settings,0}, "start [stop]"}, 7912 {"--getprofile", 1, 2, GetProfile, {H_Settings,0}, "start [stop]"},
7913 {"--getsecuritystatus", 0, 0, GetSecurityStatus, {H_Info,0}, ""}, 7913 {"--getsecuritystatus", 0, 0, GetSecurityStatus, {H_Info,0}, ""},
7914 {"--entersecuritycode", 2, 2, EnterSecurityCode, {H_Other,0}, "PIN|PUK|PIN2|PUK2 code"}, 7914 {"--entersecuritycode", 2, 2, EnterSecurityCode, {H_Other,0}, "PIN|PUK|PIN2|PUK2 code"},
7915 {"--deletewapbookmark", 1, 2, DeleteWAPBookmark, {H_WAP,0}, "start [stop]"}, 7915 {"--deletewapbookmark", 1, 2, DeleteWAPBookmark, {H_WAP,0}, "start [stop]"},
7916 {"--getwapbookmark", 1, 2, GetWAPBookmark, {H_WAP,0}, "start [stop]"}, 7916 {"--getwapbookmark", 1, 2, GetWAPBookmark, {H_WAP,0}, "start [stop]"},
7917 {"--getwapsettings", 1, 2, GetWAPMMSSettings, {H_WAP,0}, "start [stop]"}, 7917 {"--getwapsettings", 1, 2, GetWAPMMSSettings, {H_WAP,0}, "start [stop]"},
7918 {"--getmmssettings", 1, 2, GetWAPMMSSettings, {H_MMS,0}, "start [stop]"}, 7918 {"--getmmssettings", 1, 2, GetWAPMMSSettings, {H_MMS,0}, "start [stop]"},
7919 {"--getsyncmlsettings", 1, 2, GetSyncMLSettings, {H_WAP,0}, "start [stop]"}, 7919 {"--getsyncmlsettings", 1, 2, GetSyncMLSettings, {H_WAP,0}, "start [stop]"},
7920 {"--getchatsettings", 1, 2, GetChatSettings, {H_WAP,0}, "start [stop]"}, 7920 {"--getchatsettings", 1, 2, GetChatSettings, {H_WAP,0}, "start [stop]"},
7921 {"--savemmsfile", 3, 15,SaveMMSFile, {H_MMS,0}, "file [-subject text][-text text]"}, 7921 {"--savemmsfile", 3, 15,SaveMMSFile, {H_MMS,0}, "file [-subject text][-text text]"},
7922 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "STARTUP [file]"}, 7922 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "STARTUP [file]"},
7923 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "CALLER location [file]"}, 7923 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "CALLER location [file]"},
7924 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "OPERATOR [file]"}, 7924 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "OPERATOR [file]"},
7925 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "PICTURE location [file]"}, 7925 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "PICTURE location [file]"},
7926 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "TEXT"}, 7926 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "TEXT"},
7927 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "DEALER"}, 7927 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "DEALER"},
7928 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "STARTUP file|1|2|3"}, 7928 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "STARTUP file|1|2|3"},
7929 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOURSTARTUP [fileID]"}, 7929 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOURSTARTUP [fileID]"},
7930 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "WALLPAPER fileID"}, 7930 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "WALLPAPER fileID"},
7931 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "CALLER location [file]"}, 7931 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "CALLER location [file]"},
7932 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "OPERATOR [file [netcode]]"}, 7932 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "OPERATOR [file [netcode]]"},
7933 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOUROPERATOR [fileID [netcode]]"}, 7933 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOUROPERATOR [fileID [netcode]]"},
7934 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "PICTURE file location [text]"}, 7934 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "PICTURE file location [text]"},
7935 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "TEXT text"}, 7935 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "TEXT text"},
7936 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "DEALER text"}, 7936 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "DEALER text"},
7937 {"--copybitmap", 1, 3, CopyBitmap, {H_Logo,0}, "inputfile [outputfile [OPERATOR|PICTURE|STARTUP|CALLER]]"}, 7937 {"--copybitmap", 1, 3, CopyBitmap, {H_Logo,0}, "inputfile [outputfile [OPERATOR|PICTURE|STARTUP|CALLER]]"},
7938 {"--presskeysequence", 1, 1, PressKeySequence, {H_Other,0}, "mMnNpPuUdD+-123456789*0#gGrRwW"}, 7938 {"--presskeysequence", 1, 1, PressKeySequence, {H_Other,0}, "mMnNpPuUdD+-123456789*0#gGrRwW"},
7939#if defined(WIN32) || defined(HAVE_PTHREAD) 7939#if defined(WIN32) || defined(HAVE_PTHREAD)
7940 {"--searchphone", 0, 1, SearchPhone, {H_Other,0}, "[-debug]"}, 7940 {"--searchphone", 0, 1, SearchPhone, {H_Other,0}, "[-debug]"},
7941#endif 7941#endif
7942#ifdef GSM_ENABLE_BACKUP 7942#ifdef GSM_ENABLE_BACKUP
7943 {"--savefile", 4, 5, SaveFile, {H_Backup,H_Calendar,0},"CALENDAR target.vcs file location"}, 7943 {"--savefile", 4, 5, SaveFile, {H_Backup,H_Calendar,0},"CALENDAR target.vcs file location"},
7944 {"--savefile", 4, 5, SaveFile, {H_Backup,H_ToDo,0}, "TODO target.vcs file location"}, 7944 {"--savefile", 4, 5, SaveFile, {H_Backup,H_ToDo,0}, "TODO target.vcs file location"},
7945 {"--savefile", 4, 5, SaveFile, {H_Backup,H_Memory,0}, "VCARD10|VCARD21 target.vcf file SM|ME location"}, 7945 {"--savefile", 4, 5, SaveFile, {H_Backup,H_Memory,0}, "VCARD10|VCARD21 target.vcf file SM|ME location"},
7946 {"--savefile", 4, 5, SaveFile, {H_Backup,H_WAP,0}, "BOOKMARK target.url file location"}, 7946 {"--savefile", 4, 5, SaveFile, {H_Backup,H_WAP,0}, "BOOKMARK target.url file location"},
7947 {"--backup", 1, 2, Backup, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file [-yes]"}, 7947 {"--backup", 1, 2, Backup, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file [-yes]"},
7948 {"--backupsms", 1, 1, BackupSMS, {H_Backup,H_SMS,0}, "file"}, 7948 {"--backupsms", 1, 1, BackupSMS, {H_Backup,H_SMS,0}, "file"},
7949 {"--restore", 1, 1, Restore, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"}, 7949 {"--restore", 1, 1, Restore, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"},
7950 {"--addnew", 1, 1, AddNew, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"}, 7950 {"--addnew", 1, 1, AddNew, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"},
7951 {"--restoresms", 1, 1, RestoreSMS, {H_Backup,H_SMS,0}, "file"}, 7951 {"--restoresms", 1, 1, RestoreSMS, {H_Backup,H_SMS,0}, "file"},
7952 {"--addsms", 2, 2, AddSMS, {H_Backup,H_SMS,0}, "folder file"}, 7952 {"--addsms", 2, 2, AddSMS, {H_Backup,H_SMS,0}, "folder file"},
7953#endif 7953#endif
7954 {"--clearall", 0, 0, ClearAll, {H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0},""}, 7954 {"--clearall", 0, 0, ClearAll, {H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0},""},
7955 {"--networkinfo", 0, 0, NetworkInfo, {H_Network,0}, ""}, 7955 {"--networkinfo", 0, 0, NetworkInfo, {H_Network,0}, ""},
7956 #ifdef GSM_ENABLE_AT 7956 #ifdef GSM_ENABLE_AT
7957 {"--siemenssatnetmon", 0, 0, ATSIEMENSSATNetmon, {H_Siemens,H_Network,0},""}, 7957 {"--siemenssatnetmon", 0, 0, ATSIEMENSSATNetmon, {H_Siemens,H_Network,0},""},
7958 {"--siemensnetmonact", 1, 1, ATSIEMENSActivateNetmon, {H_Siemens,H_Network,0}, "netmon_type (1-full, 2-simple)"}, 7958 {"--siemensnetmonact", 1, 1, ATSIEMENSActivateNetmon, {H_Siemens,H_Network,0}, "netmon_type (1-full, 2-simple)"},
7959 {"--siemensnetmonitor", 1, 1, ATSIEMENSNetmonitor, {H_Siemens,H_Network,0},"test"}, 7959 {"--siemensnetmonitor", 1, 1, ATSIEMENSNetmonitor, {H_Siemens,H_Network,0},"test"},
7960 #endif 7960 #endif
7961#ifdef GSM_ENABLE_NOKIA6110 7961#ifdef GSM_ENABLE_NOKIA6110
7962 {"--nokiagetoperatorname", 0, 0, DCT3GetOperatorName, {H_Nokia,H_Network,0}, ""}, 7962 {"--nokiagetoperatorname", 0, 0, DCT3GetOperatorName, {H_Nokia,H_Network,0}, ""},
7963 {"--nokiasetoperatorname", 0, 2, DCT3SetOperatorName, {H_Nokia,H_Network,0}, "[networkcode name]"}, 7963 {"--nokiasetoperatorname", 0, 2, DCT3SetOperatorName, {H_Nokia,H_Network,0}, "[networkcode name]"},
7964 {"--nokiadisplayoutput", 0, 0, DCT3DisplayOutput, {H_Nokia,0}, ""}, 7964 {"--nokiadisplayoutput", 0, 0, DCT3DisplayOutput, {H_Nokia,0}, ""},
7965#endif 7965#endif
7966#ifdef GSM_ENABLE_NOKIA_DCT3 7966#ifdef GSM_ENABLE_NOKIA_DCT3
7967 {"--nokianetmonitor", 1, 1, DCT3netmonitor, {H_Nokia,H_Network,0}, "test"}, 7967 {"--nokianetmonitor", 1, 1, DCT3netmonitor, {H_Nokia,H_Network,0}, "test"},
7968 {"--nokianetmonitor36", 0, 0, DCT3ResetTest36, {H_Nokia,0}, ""}, 7968 {"--nokianetmonitor36", 0, 0, DCT3ResetTest36, {H_Nokia,0}, ""},
7969 {"--nokiadebug", 1, 2, DCT3SetDebug, {H_Nokia,H_Network,0}, "filename [[v11-22][,v33-44]...]"}, 7969 {"--nokiadebug", 1, 2, DCT3SetDebug, {H_Nokia,H_Network,0}, "filename [[v11-22][,v33-44]...]"},
7970#endif 7970#endif
7971#ifdef GSM_ENABLE_NOKIA_DCT4 7971#ifdef GSM_ENABLE_NOKIA_DCT4
7972 {"--nokiasetvibralevel", 1, 1, DCT4SetVibraLevel, {H_Nokia,H_Other,0}, "level"}, 7972 {"--nokiasetvibralevel", 1, 1, DCT4SetVibraLevel, {H_Nokia,H_Other,0}, "level"},
7973 {"--nokiagetvoicerecord", 1, 1, DCT4GetVoiceRecord, {H_Nokia,H_Other,0}, "location"}, 7973 {"--nokiagetvoicerecord", 1, 1, DCT4GetVoiceRecord, {H_Nokia,H_Other,0}, "location"},
7974 {"--nokiasetlights", 2, 2, DCT4SetLight, {H_Nokia,H_Tests,0}, "keypad|display|torch on|off"}, 7974 {"--nokiasetlights", 2, 2, DCT4SetLight, {H_Nokia,H_Tests,0}, "keypad|display|torch on|off"},
7975 {"--nokiatuneradio", 0, 0, DCT4TuneRadio, {H_Nokia,H_FM,0}, ""}, 7975 {"--nokiatuneradio", 0, 0, DCT4TuneRadio, {H_Nokia,H_FM,0}, ""},
7976 {"--nokiamakecamerashoot", 0, 0, DCT4MakeCameraShoot, {H_Nokia,H_Other,0}, ""}, 7976 {"--nokiamakecamerashoot", 0, 0, DCT4MakeCameraShoot, {H_Nokia,H_Other,0}, ""},
7977 {"--nokiagetscreendump", 0, 0, DCT4GetScreenDump, {H_Nokia,H_Other,0}, ""}, 7977 {"--nokiagetscreendump", 0, 0, DCT4GetScreenDump, {H_Nokia,H_Other,0}, ""},
7978#endif 7978#endif
7979#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) 7979#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
7980 {"--nokiavibratest", 0, 0, NokiaVibraTest, {H_Nokia,H_Tests,0}, ""}, 7980 {"--nokiavibratest", 0, 0, NokiaVibraTest, {H_Nokia,H_Tests,0}, ""},
7981 {"--nokiagett9", 0, 0, NokiaGetT9, {H_Nokia,H_SMS,0}, ""}, 7981 {"--nokiagett9", 0, 0, NokiaGetT9, {H_Nokia,H_SMS,0}, ""},
7982 {"--nokiadisplaytest", 1, 1, NokiaDisplayTest, {H_Nokia,H_Tests,0}, "number"}, 7982 {"--nokiadisplaytest", 1, 1, NokiaDisplayTest, {H_Nokia,H_Tests,0}, "number"},
7983 {"--nokiagetadc", 0, 0, NokiaGetADC, {H_Nokia,H_Tests,0}, ""}, 7983 {"--nokiagetadc", 0, 0, NokiaGetADC, {H_Nokia,H_Tests,0}, ""},
7984 {"--nokiasecuritycode", 0, 0, NokiaSecurityCode, {H_Nokia,H_Info,0}, ""}, 7984 {"--nokiasecuritycode", 0, 0, NokiaSecurityCode, {H_Nokia,H_Info,0}, ""},
7985 {"--nokiaselftests", 0, 0, NokiaSelfTests, {H_Nokia,H_Tests,0}, ""}, 7985 {"--nokiaselftests", 0, 0, NokiaSelfTests, {H_Nokia,H_Tests,0}, ""},
7986 {"--nokiasetphonemenus", 0, 0, NokiaSetPhoneMenus, {H_Nokia,H_Other,0}, ""}, 7986 {"--nokiasetphonemenus", 0, 0, NokiaSetPhoneMenus, {H_Nokia,H_Other,0}, ""},
7987#endif 7987#endif
7988#ifdef DEBUG 7988#ifdef DEBUG
7989 {"--decodesniff", 2, 3, decodesniff, {H_Decode,0}, "MBUS2|IRDA file [phonemodel]"}, 7989 {"--decodesniff", 2, 3, decodesniff, {H_Decode,0}, "MBUS2|IRDA file [phonemodel]"},
7990 {"--decodebinarydump", 1, 2, decodebinarydump, {H_Decode,0}, "file [phonemodel]"}, 7990 {"--decodebinarydump", 1, 2, decodebinarydump, {H_Decode,0}, "file [phonemodel]"},
7991 {"--makeconverttable", 1, 1, MakeConvertTable, {H_Decode,0}, "file"}, 7991 {"--makeconverttable", 1, 1, MakeConvertTable, {H_Decode,0}, "file"},
7992#endif 7992#endif
7993 {"", 0, 0, NULL } 7993 {"", 0, 0, NULL }
7994}; 7994};
7995 7995
7996static HelpCategoryDescriptions HelpDescriptions[] = { 7996static HelpCategoryDescriptions HelpDescriptions[] = {
7997 {H_Call, "call", "Calls",}, 7997 {H_Call, "call", "Calls",},
7998 {H_SMS, "sms", "SMS and EMS"}, 7998 {H_SMS, "sms", "SMS and EMS"},
7999 {H_Memory, "memory","Memory (phonebooks and calls)"}, 7999 {H_Memory, "memory","Memory (phonebooks and calls)"},
8000 {H_Filesystem, "filesystem","Filesystem"}, 8000 {H_Filesystem, "filesystem","Filesystem"},
8001 {H_Logo, "logo", "Logo and pictures"}, 8001 {H_Logo, "logo", "Logo and pictures"},
8002 {H_Ringtone, "ringtone","Ringtones"}, 8002 {H_Ringtone, "ringtone","Ringtones"},
8003 {H_Calendar, "calendar","Calendar notes"}, 8003 {H_Calendar, "calendar","Calendar notes"},
8004 {H_ToDo, "todo", "To do lists"}, 8004 {H_ToDo, "todo", "To do lists"},
8005 {H_Note, "note", "Notes"}, 8005 {H_Note, "note", "Notes"},
8006 {H_DateTime, "datetime","Date, time and alarms"}, 8006 {H_DateTime, "datetime","Date, time and alarms"},
8007 {H_Category, "category","Categories"}, 8007 {H_Category, "category","Categories"},
8008#ifdef GSM_ENABLE_BACKUP 8008#ifdef GSM_ENABLE_BACKUP
8009 {H_Backup, "backup","Backing up and restoring"}, 8009 {H_Backup, "backup","Backing up and restoring"},
8010#endif 8010#endif
8011#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) 8011#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
8012 {H_Nokia, "nokia","Nokia specific"}, 8012 {H_Nokia, "nokia","Nokia specific"},
8013#endif 8013#endif
8014#ifdef GSM_ENABLE_AT 8014#ifdef GSM_ENABLE_AT
8015 {H_Siemens, "siemens","Siemens specific"}, 8015 {H_Siemens, "siemens","Siemens specific"},
8016#endif 8016#endif
8017 {H_Network, "network","Network"}, 8017 {H_Network, "network","Network"},
8018 {H_WAP, "wap", "WAP settings and bookmarks"}, 8018 {H_WAP, "wap", "WAP settings and bookmarks"},
8019 {H_MMS, "mms", "MMS and MMS settings"}, 8019 {H_MMS, "mms", "MMS and MMS settings"},
8020 {H_Tests, "tests","Phone tests"}, 8020 {H_Tests, "tests","Phone tests"},
8021 {H_FM, "fm", "FM radio"}, 8021 {H_FM, "fm", "FM radio"},
8022 {H_Info, "info", "Phone information"}, 8022 {H_Info, "info", "Phone information"},
8023 {H_Settings, "settings","Phone settings"}, 8023 {H_Settings, "settings","Phone settings"},
8024#ifdef DEBUG 8024#ifdef DEBUG
8025 {H_Decode, "decode","Dumps decoding"}, 8025 {H_Decode, "decode","Dumps decoding"},
8026#endif 8026#endif
8027 {H_Other, "other","Functions that don't fit elsewhere"}, 8027 {H_Other, "other","Functions that don't fit elsewhere"},
8028 {0, NULL, NULL} 8028 {0, NULL, NULL}
8029}; 8029};
8030 8030
8031 8031
8032void HelpHeader(void) 8032void HelpHeader(void)
8033{ 8033{
8034 printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__); 8034 printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__);
8035} 8035}
8036 8036
8037static void HelpGeneral(void) 8037static void HelpGeneral(void)
8038{ 8038{
8039 inti=0; 8039 inti=0;
8040 8040
8041 HelpHeader(); 8041 HelpHeader();
8042 8042
8043 printmsg("Usage: gammu [confign] [nothing|text|textall|binary|errors] [options]\n\n"); 8043 printmsg("Usage: gammu [confign] [nothing|text|textall|binary|errors] [options]\n\n");
8044 printmsg("First parameter optionally specifies which config section to use (by default are probed all).\n"); 8044 printmsg("First parameter optionally specifies which config section to use (by default are probed all).\n");
8045 printmsg("Second parameter optionally controls debug level, next specify actions.\n\n"); 8045 printmsg("Second parameter optionally controls debug level, next specify actions.\n\n");
8046 8046
8047 /* We might want to put here some most used commands */ 8047 /* We might want to put here some most used commands */
8048 printmsg("For more details call help on specific topic (gammu --help topic), topics are:\n\n"); 8048 printmsg("For more details call help on specific topic (gammu --help topic), topics are:\n\n");
8049 8049
8050 while (HelpDescriptions[i].category != 0) { 8050 while (HelpDescriptions[i].category != 0) {
8051 printf("%11s - %s\n", HelpDescriptions[i].option, HelpDescriptions[i].description); 8051 printf("%11s - %s\n", HelpDescriptions[i].option, HelpDescriptions[i].description);
8052 i++; 8052 i++;
8053 } 8053 }
8054 printf("\n"); 8054 printf("\n");
8055} 8055}
8056 8056
8057static void HelpSplit(int cols, int len, unsigned char *buff) 8057static void HelpSplit(int cols, int len, unsigned char *buff)
8058{ 8058{
8059 int l, len2, pos, split; 8059 int l, len2, pos, split;
8060 bool in_opt,first=true; 8060 bool in_opt,first=true;
8061 char *remain, spaces[50], buffer[500]; 8061 char *remain, spaces[50], buffer[500];
8062 8062
8063 if (cols == 0) { 8063 if (cols == 0) {
8064 printf(" %s\n", buff); 8064 printf(" %s\n", buff);
8065 } else { 8065 } else {
8066 printf(" "); 8066 printf(" ");
8067 spaces[0] = 0; 8067 spaces[0] = 0;
8068 len2 = strlen(buff); 8068 len2 = strlen(buff);
8069 if (len + len2 < cols) { 8069 if (len + len2 < cols) {
8070 printf("%s\n", buff); 8070 printf("%s\n", buff);
8071 } else { 8071 } else {
8072 for(l = 0; l < len; l++) strcat(spaces, " "); 8072 for(l = 0; l < len; l++) strcat(spaces, " ");
8073 8073
8074 remain = buff; 8074 remain = buff;
8075 8075
8076 while (strlen(remain) > 0) { 8076 while (strlen(remain) > 0) {
8077 split= 0; 8077 split= 0;
8078 pos= 0; 8078 pos= 0;
8079 in_opt= false; 8079 in_opt= false;
8080 if (!first) printf(spaces); 8080 if (!first) printf(spaces);
8081 while (pos < cols - len && remain[pos] != 0) { 8081 while (pos < cols - len && remain[pos] != 0) {
8082 if (in_opt && remain[pos] == ']') { 8082 if (in_opt && remain[pos] == ']') {
8083 in_opt = false; 8083 in_opt = false;
8084 split = pos; 8084 split = pos;
8085 } else if (remain[pos] == '[') { 8085 } else if (remain[pos] == '[') {
8086 in_opt = true; 8086 in_opt = true;
8087 } else if (!in_opt && remain[pos] == ' ') { 8087 } else if (!in_opt && remain[pos] == ' ') {
8088 split = pos - 1; 8088 split = pos - 1;
8089 } 8089 }
8090 pos++; 8090 pos++;
8091 } 8091 }
8092 /* Can not be split */ 8092 /* Can not be split */
8093 if (split == 0) { 8093 if (split == 0) {
8094 printf("%s\n", remain); 8094 printf("%s\n", remain);
8095 remain += strlen(remain); 8095 remain += strlen(remain);
8096 } else { 8096 } else {
8097 first = false; 8097 first = false;
8098 split++; 8098 split++;
8099 strncpy(buffer, remain, split); 8099 strncpy(buffer, remain, split);
8100 buffer[split] = 0; 8100 buffer[split] = 0;
8101 printf("%s\n", buffer); 8101 printf("%s\n", buffer);
8102 remain += split; 8102 remain += split;
8103 if (remain[0] == ' ') remain++; 8103 if (remain[0] == ' ') remain++;
8104 } 8104 }
8105 } 8105 }
8106 } 8106 }
8107 } 8107 }
8108} 8108}
8109 8109
8110static void Help(int argc, char *argv[]) 8110static void Help(int argc, char *argv[])
8111{ 8111{
8112 int i = 0, j = 0, k, cols; 8112 int i = 0, j = 0, k, cols;
8113 bool disp; 8113 bool disp;
8114#ifdef TIOCGWINSZ 8114#ifdef TIOCGWINSZ
8115 struct winsize w; 8115 struct winsize w;
8116#endif 8116#endif
8117#if defined(WIN32) || defined(DJGPP) 8117#if defined(WIN32) || defined(DJGPP)
8118#else 8118#else
8119 char *columns; 8119 char *columns;
8120#endif 8120#endif
8121 8121
8122 /* Just --help */ 8122 /* Just --help */
8123 if (argc == 2) { 8123 if (argc == 2) {
8124 HelpGeneral(); 8124 HelpGeneral();
8125 return; 8125 return;
8126 } 8126 }
8127 8127
8128 if (!strcmp(argv[2],"all")) { 8128 if (!strcmp(argv[2],"all")) {
8129 HelpHeader(); 8129 HelpHeader();
8130 } else { 8130 } else {
8131 while (HelpDescriptions[i].category != 0) { 8131 while (HelpDescriptions[i].category != 0) {
8132 if (strcmp(argv[2], HelpDescriptions[i].option) == 0) break; 8132 if (strcmp(argv[2], HelpDescriptions[i].option) == 0) break;
8133 i++; 8133 i++;
8134 } 8134 }
8135 if (HelpDescriptions[i].category == 0) { 8135 if (HelpDescriptions[i].category == 0) {
8136 HelpGeneral(); 8136 HelpGeneral();
8137 printmsg("Unknown help topic specified!\n"); 8137 printmsg("Unknown help topic specified!\n");
8138 return; 8138 return;
8139 } 8139 }
8140 HelpHeader(); 8140 HelpHeader();
8141 printmsg("Gammu parameters, topic: %s\n\n", HelpDescriptions[i].description); 8141 printmsg("Gammu parameters, topic: %s\n\n", HelpDescriptions[i].description);
8142 } 8142 }
8143 8143
8144#if defined(WIN32) || defined(DJGPP) 8144#if defined(WIN32) || defined(DJGPP)
8145 cols = 80; 8145 cols = 80;
8146#else 8146#else
8147 cols = 0; 8147 cols = 0;
8148 /* If stdout is a tty, we will wrap to columns it has */ 8148 /* If stdout is a tty, we will wrap to columns it has */
8149 if (isatty(1)) { 8149 if (isatty(1)) {
8150#ifdef TIOCGWINSZ 8150#ifdef TIOCGWINSZ
8151 if (ioctl(2, TIOCGWINSZ, &w) == 0) { 8151 if (ioctl(2, TIOCGWINSZ, &w) == 0) {
8152 if (w.ws_col > 0) cols = w.ws_col; 8152 if (w.ws_col > 0) cols = w.ws_col;
8153 } 8153 }
8154#endif 8154#endif
8155 if (cols == 0) { 8155 if (cols == 0) {
8156 columns = getenv("COLUMNS"); 8156 columns = getenv("COLUMNS");
8157 if (columns != NULL) { 8157 if (columns != NULL) {
8158 cols = atoi(columns); 8158 cols = atoi(columns);
8159 if (cols <= 0) cols = 0; 8159 if (cols <= 0) cols = 0;
8160 } 8160 }
8161 } 8161 }
8162 8162
8163 if (cols == 0) { 8163 if (cols == 0) {
8164 /* Fallback */ 8164 /* Fallback */
8165 cols = 80; 8165 cols = 80;
8166 } 8166 }
8167 } 8167 }
8168#endif 8168#endif
8169 8169
8170 while (Parameters[j].Function != NULL) { 8170 while (Parameters[j].Function != NULL) {
8171 k = 0; 8171 k = 0;
8172 disp = false; 8172 disp = false;
8173 if (!strcmp(argv[2],"all")) { 8173 if (!strcmp(argv[2],"all")) {
8174 if (j==0) disp = true; 8174 if (j==0) disp = true;
8175 if (j!=0) { 8175 if (j!=0) {
8176 if (strcmp(Parameters[j].help,Parameters[j-1].help)) { 8176 if (strcmp(Parameters[j].help,Parameters[j-1].help)) {
8177 disp = true; 8177 disp = true;
8178 } else { 8178 } else {
8179 if (strcmp(Parameters[j].parameter,Parameters[j-1].parameter)) { 8179 if (strcmp(Parameters[j].parameter,Parameters[j-1].parameter)) {
8180 disp = true; 8180 disp = true;
8181 } 8181 }
8182 } 8182 }
8183 } 8183 }
8184 } else { 8184 } else {
8185 while (Parameters[j].help_cat[k] != 0) { 8185 while (Parameters[j].help_cat[k] != 0) {
8186 if (Parameters[j].help_cat[k] == HelpDescriptions[i].category) { 8186 if (Parameters[j].help_cat[k] == HelpDescriptions[i].category) {
8187 disp = true; 8187 disp = true;
8188 break; 8188 break;
8189 } 8189 }
8190 k++; 8190 k++;
8191 } 8191 }
8192 } 8192 }
8193 if (disp) { 8193 if (disp) {
8194 printf("%s", Parameters[j].parameter); 8194 printf("%s", Parameters[j].parameter);
8195 if (Parameters[j].help[0] == 0) { 8195 if (Parameters[j].help[0] == 0) {
8196 printf("\n"); 8196 printf("\n");
8197 } else { 8197 } else {
8198 HelpSplit(cols - 1, strlen(Parameters[j].parameter) + 1, Parameters[j].help); 8198 HelpSplit(cols - 1, strlen(Parameters[j].parameter) + 1, Parameters[j].help);
8199 } 8199 }
8200 } 8200 }
8201 j++; 8201 j++;
8202 } 8202 }
8203} 8203}
8204#if 0 8204#if 0
8205#endif // 0 8205#endif // 0
8206int main(int argc, char *argv[]) 8206int main(int argc, char *argv[])
8207{ 8207{
8208 8208
8209 //fprintf(stderr,"HIIIIIIIIIIIII \n"); 8209 //fprintf(stderr,"HIIIIIIIIIIIII \n");
8210 //#if 0 8210 //#if 0
8211 static int z ,start,i; 8211 static int z ,start,i;
8212 static intonly_config ; 8212 static intonly_config ;
8213#if !defined(WIN32) && defined(LOCALE_PATH) 8213#if !defined(WIN32) && defined(LOCALE_PATH)
8214 static char*locale, locale_file[201]; 8214 static char*locale, locale_file[201];
8215#endif 8215#endif
8216 static char*cp; 8216 static char*cp;
8217 static boolcount_failed; 8217 static boolcount_failed;
8218 z = 0; 8218 z = 0;
8219 start=0;only_config = -1;count_failed = false; 8219 start=0;only_config = -1;count_failed = false;
8220 s.opened = false; 8220 s.opened = false;
8221 s.msg = NULL; 8221 s.msg = NULL;
8222 s.ConfigNum = 0; 8222 s.ConfigNum = 0;
8223 8223
8224 setlocale(LC_ALL, ""); 8224 setlocale(LC_ALL, "");
8225#ifdef DEBUG 8225#ifdef DEBUG
8226 di.dl = DL_TEXTALL; 8226 di.dl = DL_TEXTALL;
8227 di.df = stdout; 8227 di.df = stdout;
8228#endif 8228#endif
8229 //#if 0 8229 //#if 0
8230 /* Any parameters? */ 8230 /* Any parameters? */
8231 if (argc == 1) { 8231 if (argc == 1) {
8232 HelpGeneral(); 8232 HelpGeneral();
8233 printmsg("Too few parameters!\n"); 8233 printmsg("Too few parameters!\n");
8234 exit(1); 8234 exit(1);
8235 } 8235 }
8236 8236
8237 /* Help? */ 8237 /* Help? */
8238 if (strncmp(argv[1 + start], "--help", 6) == 0) { 8238 if (strncmp(argv[1 + start], "--help", 6) == 0) {
8239 Help(argc - start, argv + start); 8239 Help(argc - start, argv + start);
8240 exit(1); 8240 exit(1);
8241 } 8241 }
8242 8242
8243 /* Is first parameter numeric? If so treat it as config that should be loaded. */ 8243 /* Is first parameter numeric? If so treat it as config that should be loaded. */
8244 if (isdigit(argv[1][0])) { 8244 if (isdigit(argv[1][0])) {
8245 only_config = atoi(argv[1]); 8245 only_config = atoi(argv[1]);
8246 if (only_config >= 0) start++; else only_config = -1; 8246 if (only_config >= 0) start++; else only_config = -1;
8247 } 8247 }
8248 8248
8249 GSM_ReadConfig(NULL, &s.Config[0], 0);
8250 s.ConfigNum = 1;
8251 GSM_Config *con = &s.Config[0];
8252
8253 char* tempC;
8254 tempC = argv[argc-1]+2;
8255 if ( *tempC != 0 ) {
8256 fprintf(stderr,"Using model %s \n",tempC);
8257 strcpy(con->Model,tempC );
8258 }
8259 tempC = argv[argc-2]+2;
8260 if ( *tempC != 0 ) {
8261 fprintf(stderr,"Using device %s \n",tempC);
8262 con->Device = strdup(tempC);
8263 con->DefaultDevice = false;
8264 }
8265 tempC = argv[argc-3]+2;
8266 if ( *tempC != 0 ) {
8267 fprintf(stderr,"Using connection %s \n",tempC);
8268 con->Connection = strdup(tempC);
8269 con->DefaultConnection = false;
8270 }
8271 argc = argc-3;
8272#if 0
8273 if ( ! mConnection.isEmpty() ) {
8274 cfg->Connection = strdup(mConnection.latin1());
8275 cfg->DefaultConnection = false;
8276 qDebug("Connection set %s ", cfg->Connection );
8277
8278 }
8279 if ( ! mDevice.isEmpty() ) {
8280 cfg->Device = strdup(mDevice.latin1());
8281 cfg->DefaultDevice = false;
8282 qDebug("Device set %s ", cfg->Device);
8283
8284 }
8285 if ( ! mModel.isEmpty() ) {
8286 strcpy(cfg->Model,mModel.latin1() );
8287 cfg->DefaultModel = false;
8288 qDebug("Model set %s ",cfg->Model );
8289 }
8290
8291#endif
8292
8293#if 0
8249 cfg=GSM_FindGammuRC(); 8294 cfg=GSM_FindGammuRC();
8250 for (i = 0; i <= MAX_CONFIG_NUM; i++) { 8295 for (i = 0; i <= MAX_CONFIG_NUM; i++) {
8251 if (cfg!=NULL) { 8296 if (cfg!=NULL) {
8252 cp = INI_GetValue(cfg, "gammu", "gammucoding", false); 8297 cp = INI_GetValue(cfg, "gammu", "gammucoding", false);
8253 if (cp) di.coding = cp; 8298 if (cp) di.coding = cp;
8254 8299
8255 s.Config[i].Localize = INI_GetValue(cfg, "gammu", "gammuloc", false); 8300 s.Config[i].Localize = INI_GetValue(cfg, "gammu", "gammuloc", false);
8256 if (s.Config[i].Localize) { 8301 if (s.Config[i].Localize) {
8257 s.msg=INI_ReadFile(s.Config[i].Localize, true); 8302 s.msg=INI_ReadFile(s.Config[i].Localize, true);
8258 } else { 8303 } else {
8259#if !defined(WIN32) && defined(LOCALE_PATH) 8304#if !defined(WIN32) && defined(LOCALE_PATH)
8260 locale = setlocale(LC_MESSAGES, NULL); 8305 locale = setlocale(LC_MESSAGES, NULL);
8261 if (locale != NULL) { 8306 if (locale != NULL) {
8262 snprintf(locale_file, 200, "%s/gammu_%c%c.txt", 8307 snprintf(locale_file, 200, "%s/gammu_%c%c.txt",
8263 LOCALE_PATH, 8308 LOCALE_PATH,
8264 tolower(locale[0]), 8309 tolower(locale[0]),
8265 tolower(locale[1])); 8310 tolower(locale[1]));
8266 s.msg = INI_ReadFile(locale_file, true); 8311 s.msg = INI_ReadFile(locale_file, true);
8267 } 8312 }
8268#endif 8313#endif
8269 } 8314 }
8270 } 8315 }
8271 8316
8272 /* Wanted user specific configuration? */ 8317 /* Wanted user specific configuration? */
8273 if (only_config != -1) { 8318 if (only_config != -1) {
8274 /* Here we get only in first for loop */ 8319 /* Here we get only in first for loop */
8275 if (!GSM_ReadConfig(cfg, &s.Config[0], only_config)) break; 8320 if (!GSM_ReadConfig(cfg, &s.Config[0], only_config)) break;
8276 } else { 8321 } else {
8277 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; 8322 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break;
8278 } 8323 }
8279 s.ConfigNum++; 8324 s.ConfigNum++;
8280 8325
8281 /* We want to use only one file descriptor for global and state machine debug output */ 8326 /* We want to use only one file descriptor for global and state machine debug output */
8282 s.Config[i].UseGlobalDebugFile = true; 8327 s.Config[i].UseGlobalDebugFile = true;
8283 8328
8284 /* It makes no sense to open several debug logs... */ 8329 /* It makes no sense to open several debug logs... */
8285 if (i != 0) { 8330 if (i != 0) {
8286 strcpy(s.Config[i].DebugLevel, s.Config[0].DebugLevel); 8331 strcpy(s.Config[i].DebugLevel, s.Config[0].DebugLevel);
8287 free(s.Config[i].DebugFile); 8332 free(s.Config[i].DebugFile);
8288 s.Config[i].DebugFile = strdup(s.Config[0].DebugFile); 8333 s.Config[i].DebugFile = strdup(s.Config[0].DebugFile);
8289 } else { 8334 } else {
8290 /* Just for first config */ 8335 /* Just for first config */
8291 /* When user gave debug level on command line */ 8336 /* When user gave debug level on command line */
8292 if (argc > 1 + start && GSM_SetDebugLevel(argv[1 + start], &di)) { 8337 if (argc > 1 + start && GSM_SetDebugLevel(argv[1 + start], &di)) {
8293 /* Debug level from command line will be used with phone too */ 8338 /* Debug level from command line will be used with phone too */
8294 strcpy(s.Config[i].DebugLevel,argv[1 + start]); 8339 strcpy(s.Config[i].DebugLevel,argv[1 + start]);
8295 start++; 8340 start++;
8296 } else { 8341 } else {
8297 /* Try to set debug level from config file */ 8342 /* Try to set debug level from config file */
8298 GSM_SetDebugLevel(s.Config[i].DebugLevel, &di); 8343 GSM_SetDebugLevel(s.Config[i].DebugLevel, &di);
8299 } 8344 }
8300 /* If user gave debug file in gammurc, we will use it */ 8345 /* If user gave debug file in gammurc, we will use it */
8301 error=GSM_SetDebugFile(s.Config[i].DebugFile, &di); 8346 error=GSM_SetDebugFile(s.Config[i].DebugFile, &di);
8302 Print_Error(error); 8347 Print_Error(error);
8303 } 8348 }
8304 8349
8305 /* We wanted to read just user specified configuration. */ 8350 /* We wanted to read just user specified configuration. */
8306 if (only_config != -1) {break;} 8351 if (only_config != -1) {break;}
8307 } 8352 }
8308 8353#endif
8309 /* Do we have enough parameters? */ 8354 /* Do we have enough parameters? */
8310 if (argc == 1 + start) { 8355 if (argc == 1 + start) {
8311 HelpGeneral(); 8356 HelpGeneral();
8312 printmsg("Too few parameters!\n"); 8357 printmsg("Too few parameters!\n");
8313 exit(-2); 8358 exit(-2);
8314 } 8359 }
8315 8360
8316 /* Check used version vs. compiled */ 8361 /* Check used version vs. compiled */
8317 if (!mystrncasecmp(GetGammuVersion(),VERSION,0)) { 8362 if (!mystrncasecmp(GetGammuVersion(),VERSION,0)) {
8318 printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n", 8363 printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n",
8319 GetGammuVersion(),VERSION); 8364 GetGammuVersion(),VERSION);
8320 exit(-1); 8365 exit(-1);
8321 } 8366 }
8322 8367
8323 /* Check parameters */ 8368 /* Check parameters */
8324 while (Parameters[z].Function != NULL) { 8369 while (Parameters[z].Function != NULL) {
8325 if (mystrncasecmp(Parameters[z].parameter,argv[1+start], 0)) { 8370 if (mystrncasecmp(Parameters[z].parameter,argv[1+start], 0)) {
8326 if (argc-2-start >= Parameters[z].min_arg && argc-2-start <= Parameters[z].max_arg) { 8371 if (argc-2-start >= Parameters[z].min_arg && argc-2-start <= Parameters[z].max_arg) {
8327 Parameters[z].Function(argc - start, argv + start); 8372 Parameters[z].Function(argc - start, argv + start);
8328 break; 8373 break;
8329 } else { 8374 } else {
8330 count_failed = true; 8375 count_failed = true;
8331 } 8376 }
8332 } 8377 }
8333 z++; 8378 z++;
8334 } 8379 }
8335 8380
8336 /* Tell user when we did nothing */ 8381 /* Tell user when we did nothing */
8337 if (Parameters[z].Function == NULL) { 8382 if (Parameters[z].Function == NULL) {
8338 HelpGeneral(); 8383 HelpGeneral();
8339 if (count_failed) { 8384 if (count_failed) {
8340 printmsg("Bad parameter count!\n"); 8385 printmsg("Bad parameter count!\n");
8341 } else { 8386 } else {
8342 printmsg("Bad option!\n"); 8387 printmsg("Bad option!\n");
8343 } 8388 }
8344 } 8389 }
8345 8390
8346 /* Close debug output if opened */ 8391 /* Close debug output if opened */
8347 if (di.df!=stdout) fclose(di.df); 8392 if (di.df!=stdout) fclose(di.df);
8348 //#endif // 0 8393 //#endif // 0
8349 fprintf(stderr,"kammu: Success. End. \n"); 8394 fprintf(stderr,"kammu: Success. End. \n");
8350 exit(0); 8395 exit(0);
8351} 8396}
8352 8397
8353/* How should editor hadle tabs in this file? Add editor commands here. 8398/* How should editor hadle tabs in this file? Add editor commands here.
8354 * vim: noexpandtab sw=8 ts=8 sts=8: 8399 * vim: noexpandtab sw=8 ts=8 sts=8:
8355 */ 8400 */
8356 8401
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 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 4 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qdatetime.h> 22#include <qdatetime.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qclipboard.h> 28#include <qclipboard.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qtextcodec.h> 31#include <qtextcodec.h>
32#include <qxml.h> 32#include <qxml.h>
33#include <qlabel.h> 33#include <qlabel.h>
34 34
35#include <kdebug.h> 35#include <kdebug.h>
36#include <klocale.h> 36#include <klocale.h>
37#include <kglobal.h> 37#include <kglobal.h>
38 38
39#include "calendar.h" 39#include "calendar.h"
40#include "alarm.h" 40#include "alarm.h"
41#include "recurrence.h" 41#include "recurrence.h"
42#include "calendarlocal.h" 42#include "calendarlocal.h"
43 43
44#include "phoneformat.h" 44#include "phoneformat.h"
45#include "syncdefines.h" 45#include "syncdefines.h"
46 46
47using namespace KCal; 47using namespace KCal;
48class PhoneParser : public QObject 48class PhoneParser : public QObject
49{ 49{
50public: 50public:
51 PhoneParser( ) { 51 PhoneParser( ) {
52 ; 52 ;
53 } 53 }
54 54
55 static QString dtToString( const QDateTime& dti, bool useTZ = false ) 55 static QString dtToString( const QDateTime& dti, bool useTZ = false )
56 { 56 {
57 QString datestr; 57 QString datestr;
58 QString timestr; 58 QString timestr;
59 int offset = KGlobal::locale()->localTimeOffset( dti ); 59 int offset = KGlobal::locale()->localTimeOffset( dti );
60 QDateTime dt; 60 QDateTime dt;
61 if (useTZ) 61 if (useTZ)
62 dt = dti.addSecs ( -(offset*60)); 62 dt = dti.addSecs ( -(offset*60));
63 else 63 else
64 dt = dti; 64 dt = dti;
65 if(dt.date().isValid()){ 65 if(dt.date().isValid()){
66 const QDate& date = dt.date(); 66 const QDate& date = dt.date();
67 datestr.sprintf("%04d%02d%02d", 67 datestr.sprintf("%04d%02d%02d",
68 date.year(), date.month(), date.day()); 68 date.year(), date.month(), date.day());
69 } 69 }
70 if(dt.time().isValid()){ 70 if(dt.time().isValid()){
71 const QTime& time = dt.time(); 71 const QTime& time = dt.time();
72 timestr.sprintf("T%02d%02d%02d", 72 timestr.sprintf("T%02d%02d%02d",
73 time.hour(), time.minute(), time.second()); 73 time.hour(), time.minute(), time.second());
74 } 74 }
75 return datestr + timestr; 75 return datestr + timestr;
76 } 76 }
77 77
78 78
79}; 79};
80 80
81 81
82 82
83PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) 83PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model )
84{ 84{
85 mProfileName = profileName; 85 mProfileName = profileName;
86 mDevice = device; 86 mDevice = device;
87 mConnection = connection; 87 mConnection = connection;
88 mModel = model; 88 mModel = model;
89} 89}
90 90
91PhoneFormat::~PhoneFormat() 91PhoneFormat::~PhoneFormat()
92{ 92{
93} 93}
94#if 0 94#if 0
95int PhoneFormat::initDevice(GSM_StateMachine *s) 95int PhoneFormat::initDevice(GSM_StateMachine *s)
96{ 96{
97 GSM_ReadConfig(NULL, &s->Config[0], 0); 97 GSM_ReadConfig(NULL, &s->Config[0], 0);
98 s->ConfigNum = 1; 98 s->ConfigNum = 1;
99 GSM_Config *cfg = &s->Config[0]; 99 GSM_Config *cfg = &s->Config[0];
100 if ( ! mConnection.isEmpty() ) { 100 if ( ! mConnection.isEmpty() ) {
101 cfg->Connection = strdup(mConnection.latin1()); 101 cfg->Connection = strdup(mConnection.latin1());
102 cfg->DefaultConnection = false; 102 cfg->DefaultConnection = false;
103 qDebug("Connection set %s ", cfg->Connection ); 103 qDebug("Connection set %s ", cfg->Connection );
104 104
105 } 105 }
106 if ( ! mDevice.isEmpty() ) { 106 if ( ! mDevice.isEmpty() ) {
107 cfg->Device = strdup(mDevice.latin1()); 107 cfg->Device = strdup(mDevice.latin1());
108 cfg->DefaultDevice = false; 108 cfg->DefaultDevice = false;
109 qDebug("Device set %s ", cfg->Device); 109 qDebug("Device set %s ", cfg->Device);
110 110
111 } 111 }
112 if ( ! mModel.isEmpty() ) { 112 if ( ! mModel.isEmpty() ) {
113 strcpy(cfg->Model,mModel.latin1() ); 113 strcpy(cfg->Model,mModel.latin1() );
114 cfg->DefaultModel = false; 114 cfg->DefaultModel = false;
115 qDebug("Model set %s ",cfg->Model ); 115 qDebug("Model set %s ",cfg->Model );
116 } 116 }
117 int error=GSM_InitConnection(s,3); 117 int error=GSM_InitConnection(s,3);
118 return error; 118 return error;
119} 119}
120#endif 120#endif
121ulong PhoneFormat::getCsumTodo( Todo* todo ) 121ulong PhoneFormat::getCsumTodo( Todo* todo )
122{ 122{
123 QStringList attList; 123 QStringList attList;
124 if ( todo->hasDueDate() ) 124 if ( todo->hasDueDate() )
125 attList << PhoneParser::dtToString ( todo->dtDue() ); 125 attList << PhoneParser::dtToString ( todo->dtDue() );
126 attList << todo->summary(); 126 attList << todo->summary();
127 QString completedString = "no"; 127 QString completedString = "no";
128 if ( todo->isCompleted() ) 128 if ( todo->isCompleted() )
129 completedString = "yes"; 129 completedString = "yes";
130 attList << completedString; 130 attList << completedString;
131 attList << QString::number( todo->priority() ); 131 attList << QString::number( todo->priority() );
132 QString alarmString = "na"; 132 QString alarmString = "na";
133 Alarm *alarm; 133 Alarm *alarm;
134 if ( todo->alarms().count() > 0 ) { 134 if ( todo->alarms().count() > 0 ) {
135 alarm = todo->alarms().first(); 135 alarm = todo->alarms().first();
136 if ( alarm->enabled() ) { 136 if ( alarm->enabled() ) {
137 alarmString = QString::number(alarm->startOffset().asSeconds() ); 137 alarmString = QString::number(alarm->startOffset().asSeconds() );
138 } 138 }
139 } 139 }
140 attList << alarmString; 140 attList << alarmString;
141 attList << todo->categoriesStr(); 141 attList << todo->categoriesStr();
142 attList << todo->secrecyStr(); 142 attList << todo->secrecyStr();
143 return PhoneFormat::getCsum(attList ); 143 return PhoneFormat::getCsum(attList );
144 144
145} 145}
146ulong PhoneFormat::getCsumEvent( Event* event ) 146ulong PhoneFormat::getCsumEvent( Event* event )
147{ 147{
148 QStringList attList; 148 QStringList attList;
149 attList << PhoneParser::dtToString ( event->dtStart() ); 149 attList << PhoneParser::dtToString ( event->dtStart() );
150 attList << PhoneParser::dtToString ( event->dtEnd() ); 150 attList << PhoneParser::dtToString ( event->dtEnd() );
151 attList << event->summary(); 151 attList << event->summary();
152 attList << event->location(); 152 attList << event->location();
153 QString alarmString = "na"; 153 QString alarmString = "na";
154 Alarm *alarm; 154 Alarm *alarm;
155 if ( event->alarms().count() > 0 ) { 155 if ( event->alarms().count() > 0 ) {
156 alarm = event->alarms().first(); 156 alarm = event->alarms().first();
157 if ( alarm->enabled() ) { 157 if ( alarm->enabled() ) {
158 alarmString = QString::number( alarm->startOffset().asSeconds() ); 158 alarmString = QString::number( alarm->startOffset().asSeconds() );
159 } 159 }
160 } 160 }
161 attList << alarmString; 161 attList << alarmString;
162 Recurrence* rec = event->recurrence(); 162 Recurrence* rec = event->recurrence();
163 QStringList list; 163 QStringList list;
164 bool writeEndDate = false; 164 bool writeEndDate = false;
165 switch ( rec->doesRecur() ) 165 switch ( rec->doesRecur() )
166 { 166 {
167 case Recurrence::rDaily: // 0 167 case Recurrence::rDaily: // 0
168 list.append( "0" ); 168 list.append( "0" );
169 list.append( QString::number( rec->frequency() ));//12 169 list.append( QString::number( rec->frequency() ));//12
170 list.append( "0" ); 170 list.append( "0" );
171 list.append( "0" ); 171 list.append( "0" );
172 writeEndDate = true; 172 writeEndDate = true;
173 break; 173 break;
174 case Recurrence::rWeekly:// 1 174 case Recurrence::rWeekly:// 1
175 list.append( "1" ); 175 list.append( "1" );
176 list.append( QString::number( rec->frequency()) );//12 176 list.append( QString::number( rec->frequency()) );//12
177 list.append( "0" ); 177 list.append( "0" );
178 { 178 {
179 int days = 0; 179 int days = 0;
180 QBitArray weekDays = rec->days(); 180 QBitArray weekDays = rec->days();
181 int i; 181 int i;
182 for( i = 1; i <= 7; ++i ) { 182 for( i = 1; i <= 7; ++i ) {
183 if ( weekDays[i-1] ) { 183 if ( weekDays[i-1] ) {
184 days += 1 << (i-1); 184 days += 1 << (i-1);
185 } 185 }
186 } 186 }
187 list.append( QString::number( days ) ); 187 list.append( QString::number( days ) );
188 } 188 }
189 //pending weekdays 189 //pending weekdays
190 writeEndDate = true; 190 writeEndDate = true;
191 191
192 break; 192 break;
193 case Recurrence::rMonthlyPos:// 2 193 case Recurrence::rMonthlyPos:// 2
194 list.append( "2" ); 194 list.append( "2" );
195 list.append( QString::number( rec->frequency()) );//12 195 list.append( QString::number( rec->frequency()) );//12
196 196
197 writeEndDate = true; 197 writeEndDate = true;
198 { 198 {
199 int count = 1; 199 int count = 1;
200 QPtrList<Recurrence::rMonthPos> rmp; 200 QPtrList<Recurrence::rMonthPos> rmp;
201 rmp = rec->monthPositions(); 201 rmp = rec->monthPositions();
202 if ( rmp.first()->negative ) 202 if ( rmp.first()->negative )
203 count = 5 - rmp.first()->rPos - 1; 203 count = 5 - rmp.first()->rPos - 1;
204 else 204 else
205 count = rmp.first()->rPos - 1; 205 count = rmp.first()->rPos - 1;
206 list.append( QString::number( count ) ); 206 list.append( QString::number( count ) );
207 207
208 } 208 }
209 209
210 list.append( "0" ); 210 list.append( "0" );
211 break; 211 break;
212 case Recurrence::rMonthlyDay:// 3 212 case Recurrence::rMonthlyDay:// 3
213 list.append( "3" ); 213 list.append( "3" );
214 list.append( QString::number( rec->frequency()) );//12 214 list.append( QString::number( rec->frequency()) );//12
215 list.append( "0" ); 215 list.append( "0" );
216 list.append( "0" ); 216 list.append( "0" );
217 writeEndDate = true; 217 writeEndDate = true;
218 break; 218 break;
219 case Recurrence::rYearlyMonth://4 219 case Recurrence::rYearlyMonth://4
220 list.append( "4" ); 220 list.append( "4" );
221 list.append( QString::number( rec->frequency()) );//12 221 list.append( QString::number( rec->frequency()) );//12
222 list.append( "0" ); 222 list.append( "0" );
223 list.append( "0" ); 223 list.append( "0" );
224 writeEndDate = true; 224 writeEndDate = true;
225 break; 225 break;
226 226
227 default: 227 default:
228 list.append( "255" ); 228 list.append( "255" );
229 list.append( QString() ); 229 list.append( QString() );
230 list.append( "0" ); 230 list.append( "0" );
231 list.append( QString() ); 231 list.append( QString() );
232 list.append( "0" ); 232 list.append( "0" );
233 list.append( "20991231T000000" ); 233 list.append( "20991231T000000" );
234 break; 234 break;
235 } 235 }
236 if ( writeEndDate ) { 236 if ( writeEndDate ) {
237 237
238 if ( rec->endDate().isValid() ) { // 15 + 16 238 if ( rec->endDate().isValid() ) { // 15 + 16
239 list.append( "1" ); 239 list.append( "1" );
240 list.append( PhoneParser::dtToString( rec->endDate()) ); 240 list.append( PhoneParser::dtToString( rec->endDate()) );
241 } else { 241 } else {
242 list.append( "0" ); 242 list.append( "0" );
243 list.append( "20991231T000000" ); 243 list.append( "20991231T000000" );
244 } 244 }
245 245
246 } 246 }
247 attList << list.join(""); 247 attList << list.join("");
248 attList << event->categoriesStr(); 248 attList << event->categoriesStr();
249 attList << event->secrecyStr(); 249 attList << event->secrecyStr();
250 return PhoneFormat::getCsum(attList ); 250 return PhoneFormat::getCsum(attList );
251} 251}
252ulong PhoneFormat::getCsum( const QStringList & attList) 252ulong PhoneFormat::getCsum( const QStringList & attList)
253{ 253{
254 int max = attList.count() -1; 254 int max = attList.count() -1;
255 ulong cSum = 0; 255 ulong cSum = 0;
256 int j,k,i; 256 int j,k,i;
257 int add; 257 int add;
258 for ( i = 1; i < max ; ++i ) { 258 for ( i = 1; i < max ; ++i ) {
259 QString s = attList[i]; 259 QString s = attList[i];
260 if ( ! s.isEmpty() ){ 260 if ( ! s.isEmpty() ){
261 j = s.length(); 261 j = s.length();
262 for ( k = 0; k < j; ++k ) { 262 for ( k = 0; k < j; ++k ) {
263 int mul = k +1; 263 int mul = k +1;
264 add = s[k].unicode (); 264 add = s[k].unicode ();
265 if ( k < 16 ) 265 if ( k < 16 )
266 mul = mul * mul; 266 mul = mul * mul;
267 add = add * mul *i*i*i; 267 add = add * mul *i*i*i;
268 cSum += add; 268 cSum += add;
269 } 269 }
270 } 270 }
271 } 271 }
272 return cSum; 272 return cSum;
273 273
274} 274}
275//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 275//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
276#include <stdlib.h> 276#include <stdlib.h>
277#define DEBUGMODE false 277#define DEBUGMODE false
278bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) 278bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
279{ 279{
280 280
281 QString fileName; 281 QString fileName;
282#ifdef _WIN32_ 282#ifdef _WIN32_
283 fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; 283 fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs";
284#else 284#else
285 fileName = "/tmp/kdepimtemp.vcs"; 285 fileName = "/tmp/kdepimtemp.vcs";
286#endif 286#endif
287 QString command ="./kammu --backup " + fileName + " -yes"; 287 QString command ="./kammu --backup " + fileName + " -yes -C" +
288 mConnection +" -D" + mDevice +" -M" + mModel;
288 int ret = system ( command.latin1() ); 289 int ret = system ( command.latin1() );
289 if ( ret != 0 ) 290 if ( ret != 0 )
290 return false; 291 return false;
291 VCalFormat vfload; 292 VCalFormat vfload;
292 vfload.setLocalTime ( true ); 293 vfload.setLocalTime ( true );
293 if ( ! vfload.load( calendar, fileName ) ) 294 if ( ! vfload.load( calendar, fileName ) )
294 return false; 295 return false;
295 QPtrList<Event> er = calendar->rawEvents(); 296 QPtrList<Event> er = calendar->rawEvents();
296 Event* ev = er.first(); 297 Event* ev = er.first();
297 while ( ev ) { 298 while ( ev ) {
298 int id = ev->pilotId(); 299 int id = ev->pilotId();
299 Event *event; 300 Event *event;
300 event = existingCal->event( mProfileName ,QString::number( id ) ); 301 event = existingCal->event( mProfileName ,QString::number( id ) );
301 if ( event ) { 302 if ( event ) {
302 event = (Event*)event->clone(); 303 event = (Event*)event->clone();
303 copyEvent( event, ev ); 304 copyEvent( event, ev );
304 calendar->deleteEvent( ev ); 305 calendar->deleteEvent( ev );
305 calendar->addEvent( event); 306 calendar->addEvent( event);
306 } 307 }
307 else 308 else
308 event = ev; 309 event = ev;
309 uint cSum; 310 uint cSum;
310 cSum = PhoneFormat::getCsumEvent( event ); 311 cSum = PhoneFormat::getCsumEvent( event );
311 event->setCsum( mProfileName, QString::number( cSum )); 312 event->setCsum( mProfileName, QString::number( cSum ));
312 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 313 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
313 event->setID( mProfileName,QString::number( id ) ); 314 event->setID( mProfileName,QString::number( id ) );
314 ev = er.next(); 315 ev = er.next();
315 } 316 }
316 { 317 {
317 QPtrList<Todo> tr = calendar->rawTodos(); 318 QPtrList<Todo> tr = calendar->rawTodos();
318 Todo* ev = tr.first(); 319 Todo* ev = tr.first();
319 while ( ev ) { 320 while ( ev ) {
320 321
321 QStringList cat = ev->categories(); 322 QStringList cat = ev->categories();
322 if ( cat.contains( "MeetingDEF" )) { 323 if ( cat.contains( "MeetingDEF" )) {
323 ev->setCategories( QStringList() ); 324 ev->setCategories( QStringList() );
324 } 325 }
325 int id = ev->pilotId(); 326 int id = ev->pilotId();
326 Todo *event; 327 Todo *event;
327 event = existingCal->todo( mProfileName ,QString::number( id ) ); 328 event = existingCal->todo( mProfileName ,QString::number( id ) );
328 if ( event ) { 329 if ( event ) {
329 event = (Todo*)event->clone(); 330 event = (Todo*)event->clone();
330 copyTodo( event, ev ); 331 copyTodo( event, ev );
331 calendar->deleteTodo( ev ); 332 calendar->deleteTodo( ev );
332 calendar->addTodo( event); 333 calendar->addTodo( event);
333 } 334 }
334 else 335 else
335 event = ev; 336 event = ev;
336 uint cSum; 337 uint cSum;
337 cSum = PhoneFormat::getCsumTodo( event ); 338 cSum = PhoneFormat::getCsumTodo( event );
338 event->setCsum( mProfileName, QString::number( cSum )); 339 event->setCsum( mProfileName, QString::number( cSum ));
339 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 340 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
340 event->setID( mProfileName,QString::number( id ) ); 341 event->setID( mProfileName,QString::number( id ) );
341 ev = tr.next(); 342 ev = tr.next();
342 } 343 }
343 } 344 }
344 return true; 345 return true;
345} 346}
346void PhoneFormat::copyEvent( Event* to, Event* from ) 347void PhoneFormat::copyEvent( Event* to, Event* from )
347{ 348{
348 if ( from->dtStart().isValid() ) 349 if ( from->dtStart().isValid() )
349 to->setDtStart( from->dtStart() ); 350 to->setDtStart( from->dtStart() );
350 if ( from->dtEnd().isValid() ) 351 if ( from->dtEnd().isValid() )
351 to->setDtEnd( from->dtEnd() ); 352 to->setDtEnd( from->dtEnd() );
352 if ( !from->location().isEmpty() ) 353 if ( !from->location().isEmpty() )
353 to->setLocation( from->location() ); 354 to->setLocation( from->location() );
354 if ( !from->description().isEmpty() ) 355 if ( !from->description().isEmpty() )
355 to->setDescription( from->description() ); 356 to->setDescription( from->description() );
356 if ( !from->summary().isEmpty() ) 357 if ( !from->summary().isEmpty() )
357 to->setSummary( from->summary() ); 358 to->setSummary( from->summary() );
358 359
359 QPtrListIterator<Alarm> it( from->alarms() ); 360 QPtrListIterator<Alarm> it( from->alarms() );
360 to->clearAlarms(); 361 to->clearAlarms();
361 const Alarm *a; 362 const Alarm *a;
362 while( (a = it.current()) ) { 363 while( (a = it.current()) ) {
363 Alarm *b = new Alarm( *a ); 364 Alarm *b = new Alarm( *a );
364 b->setParent( to ); 365 b->setParent( to );
365 to->addAlarm( b ); 366 to->addAlarm( b );
366 ++it; 367 ++it;
367 } 368 }
368 QStringList cat = to->categories(); 369 QStringList cat = to->categories();
369 QStringList catFrom = from->categories(); 370 QStringList catFrom = from->categories();
370 QString nCat; 371 QString nCat;
371 int iii; 372 int iii;
372 for ( iii = 0; iii < catFrom.count();++iii ) { 373 for ( iii = 0; iii < catFrom.count();++iii ) {
373 nCat = catFrom[iii]; 374 nCat = catFrom[iii];
374 if ( !nCat.isEmpty() ) 375 if ( !nCat.isEmpty() )
375 if ( !cat.contains( nCat )) { 376 if ( !cat.contains( nCat )) {
376 cat << nCat; 377 cat << nCat;
377 } 378 }
378 } 379 }
379 to->setCategories( cat ); 380 to->setCategories( cat );
380 Recurrence * r = new Recurrence( *from->recurrence(),to); 381 Recurrence * r = new Recurrence( *from->recurrence(),to);
381 to->setRecurrence( r ) ; 382 to->setRecurrence( r ) ;
382 383
383 384
384} 385}
385void PhoneFormat::copyTodo( Todo* to, Todo* from ) 386void PhoneFormat::copyTodo( Todo* to, Todo* from )
386{ 387{
387 if ( from->dtStart().isValid() ) 388 if ( from->dtStart().isValid() )
388 to->setDtStart( from->dtStart() ); 389 to->setDtStart( from->dtStart() );
389 if ( from->dtDue().isValid() ) 390 if ( from->dtDue().isValid() )
390 to->setDtDue( from->dtDue() ); 391 to->setDtDue( from->dtDue() );
391 if ( !from->location().isEmpty() ) 392 if ( !from->location().isEmpty() )
392 to->setLocation( from->location() ); 393 to->setLocation( from->location() );
393 if ( !from->description().isEmpty() ) 394 if ( !from->description().isEmpty() )
394 to->setDescription( from->description() ); 395 to->setDescription( from->description() );
395 if ( !from->summary().isEmpty() ) 396 if ( !from->summary().isEmpty() )
396 to->setSummary( from->summary() ); 397 to->setSummary( from->summary() );
397 398
398 QPtrListIterator<Alarm> it( from->alarms() ); 399 QPtrListIterator<Alarm> it( from->alarms() );
399 to->clearAlarms(); 400 to->clearAlarms();
400 const Alarm *a; 401 const Alarm *a;
401 while( (a = it.current()) ) { 402 while( (a = it.current()) ) {
402 Alarm *b = new Alarm( *a ); 403 Alarm *b = new Alarm( *a );
403 b->setParent( to ); 404 b->setParent( to );
404 to->addAlarm( b ); 405 to->addAlarm( b );
405 ++it; 406 ++it;
406 } 407 }
407 QStringList cat = to->categories(); 408 QStringList cat = to->categories();
408 QStringList catFrom = from->categories(); 409 QStringList catFrom = from->categories();
409 QString nCat; 410 QString nCat;
410 int iii; 411 int iii;
411 for ( iii = 0; iii < catFrom.count();++iii ) { 412 for ( iii = 0; iii < catFrom.count();++iii ) {
412 nCat = catFrom[iii]; 413 nCat = catFrom[iii];
413 if ( !nCat.isEmpty() ) 414 if ( !nCat.isEmpty() )
414 if ( !cat.contains( nCat )) { 415 if ( !cat.contains( nCat )) {
415 cat << nCat; 416 cat << nCat;
416 } 417 }
417 } 418 }
418 to->setCategories( cat ); 419 to->setCategories( cat );
419 if ( from->isCompleted() ) { 420 if ( from->isCompleted() ) {
420 to->setCompleted( true ); 421 to->setCompleted( true );
421 if( from->completed().isValid() ) 422 if( from->completed().isValid() )
422 to->setCompleted( from->completed() ); 423 to->setCompleted( from->completed() );
423 } else { 424 } else {
424 // set percentcomplete only, if to->isCompleted() 425 // set percentcomplete only, if to->isCompleted()
425 if ( to->isCompleted() ) 426 if ( to->isCompleted() )
426 to->setPercentComplete(from->percentComplete()); 427 to->setPercentComplete(from->percentComplete());
427 } 428 }
428 to->setPriority(from->priority()); 429 to->setPriority(from->priority());
429 430
430} 431}
431#include <qcstring.h> 432#include <qcstring.h>
432 433
433void PhoneFormat::afterSave( Incidence* inc) 434void PhoneFormat::afterSave( Incidence* inc)
434{ 435{
435 uint csum; 436 uint csum;
436 inc->removeID( mProfileName ); 437 inc->removeID( mProfileName );
437 if ( inc->type() == "Event") 438 if ( inc->type() == "Event")
438 csum = PhoneFormat::getCsumEvent( (Event*) inc ); 439 csum = PhoneFormat::getCsumEvent( (Event*) inc );
439 else 440 else
440 csum = PhoneFormat::getCsumTodo( (Todo*) inc ); 441 csum = PhoneFormat::getCsumTodo( (Todo*) inc );
441 inc->setCsum( mProfileName, QString::number( csum )); 442 inc->setCsum( mProfileName, QString::number( csum ));
442 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 443 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
443 444
444} 445}
445bool PhoneFormat::save( Calendar *calendar) 446bool PhoneFormat::save( Calendar *calendar)
446{ 447{
447 QLabel status ( i18n(" Opening device ..."), 0 ); 448 QLabel status ( i18n(" Opening device ..."), 0 );
448 int w = status.sizeHint().width()+20 ; 449 int w = status.sizeHint().width()+20 ;
449 if ( w < 200 ) w = 230; 450 if ( w < 200 ) w = 230;
450 int h = status.sizeHint().height()+20 ; 451 int h = status.sizeHint().height()+20 ;
451 int dw = QApplication::desktop()->width(); 452 int dw = QApplication::desktop()->width();
452 int dh = QApplication::desktop()->height(); 453 int dh = QApplication::desktop()->height();
453 status.setCaption(i18n("Writing to phone...") ); 454 status.setCaption(i18n("Writing to phone...") );
454 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 455 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
455 status.show(); 456 status.show();
456 status.raise(); 457 status.raise();
457 qApp->processEvents(); 458 qApp->processEvents();
458 QString message; 459 QString message;
459#ifdef _WIN32_ 460#ifdef _WIN32_
460 QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; 461 QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs";
461#else 462#else
462 QString fileName = "/tmp/kdepimtemp.vcs"; 463 QString fileName = "/tmp/kdepimtemp.vcs";
463#endif 464#endif
464 465
465 // 1 remove events which should be deleted 466 // 1 remove events which should be deleted
466 QPtrList<Event> er = calendar->rawEvents(); 467 QPtrList<Event> er = calendar->rawEvents();
467 Event* ev = er.first(); 468 Event* ev = er.first();
468 while ( ev ) { 469 while ( ev ) {
469 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 470 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
470 calendar->deleteEvent( ev ); 471 calendar->deleteEvent( ev );
471 } else { 472 } else {
472 473
473 } 474 }
474 ev = er.next(); 475 ev = er.next();
475 } 476 }
476 // 2 remove todos which should be deleted 477 // 2 remove todos which should be deleted
477 QPtrList<Todo> tl = calendar->rawTodos(); 478 QPtrList<Todo> tl = calendar->rawTodos();
478 Todo* to = tl.first(); 479 Todo* to = tl.first();
479 while ( to ) { 480 while ( to ) {
480 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 481 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
481 calendar->deleteTodo( to ); 482 calendar->deleteTodo( to );
482 } 483 }
483 to = tl.next(); 484 to = tl.next();
484 } 485 }
485 // 3 save file 486 // 3 save file
486 VCalFormat vfsave; 487 VCalFormat vfsave;
487 vfsave.setLocalTime ( true ); 488 vfsave.setLocalTime ( true );
488 if ( ! vfsave.save( calendar, fileName ) ) 489 if ( ! vfsave.save( calendar, fileName ) )
489 return false; 490 return false;
490 // 4 call kammu 491 // 4 call kammu
491 QString command ="./kammu --restore " + fileName ; 492 QString command ="./kammu --restore " + fileName + " -C" +
493 mConnection +" -D" + mDevice +" -M" + mModel;;
492 int ret = system ( command.latin1() ); 494 int ret = system ( command.latin1() );
493 if ( ret != 0 ) 495 if ( ret != 0 )
494 return false; 496 return false;
495 // 5 reread data 497 // 5 reread data
496 message = i18n(" Rereading all data ... "); 498 message = i18n(" Rereading all data ... ");
497 status.setText ( message ); 499 status.setText ( message );
498 qApp->processEvents(); 500 qApp->processEvents();
499 CalendarLocal* calendarTemp = new CalendarLocal(); 501 CalendarLocal* calendarTemp = new CalendarLocal();
500 calendarTemp->setTimeZoneId( calendar->timeZoneId()); 502 calendarTemp->setTimeZoneId( calendar->timeZoneId());
501 if ( ! load( calendarTemp,calendar) ){ 503 if ( ! load( calendarTemp,calendar) ){
502 qDebug("error reloading calendar "); 504 qDebug("error reloading calendar ");
503 delete calendarTemp; 505 delete calendarTemp;
504 return false; 506 return false;
505 } 507 }
506 // 6 compare data 508 // 6 compare data
507 509
508//algo 6 compare event 510//algo 6 compare event
509 er = calendar->rawEvents(); 511 er = calendar->rawEvents();
510 ev = er.first(); 512 ev = er.first();
511 message = i18n(" Comparing event # "); 513 message = i18n(" Comparing event # ");
512 QPtrList<Event> er1 = calendarTemp->rawEvents(); 514 QPtrList<Event> er1 = calendarTemp->rawEvents();
513 Event* ev1; 515 Event* ev1;
514 int procCount = 0; 516 int procCount = 0;
515 while ( ev ) { 517 while ( ev ) {
516 qDebug("event new ID "); 518 qDebug("event new ID ");
517 status.setText ( message + QString::number ( ++procCount ) ); 519 status.setText ( message + QString::number ( ++procCount ) );
518 qApp->processEvents(); 520 qApp->processEvents();
519 QString cSum = ev->getCsum(mProfileName); 521 QString cSum = ev->getCsum(mProfileName);
520 ev1 = er1.first(); 522 ev1 = er1.first();
521 while ( ev1 ) { 523 while ( ev1 ) {
522 if ( ev1->getCsum( mProfileName ) == cSum ) { 524 if ( ev1->getCsum( mProfileName ) == cSum ) {
523 er1.remove( ev1 ); 525 er1.remove( ev1 );
524 afterSave( ev ); 526 afterSave( ev );
525 ev->setID(mProfileName, ev1->getID(mProfileName) ); 527 ev->setID(mProfileName, ev1->getID(mProfileName) );
526 break; 528 break;
527 } 529 }
528 ev1 = er1.next(); 530 ev1 = er1.next();
529 } 531 }
530 if ( ! ev1 ) { 532 if ( ! ev1 ) {
531 ev->removeID(mProfileName); 533 ev->removeID(mProfileName);
532 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); 534 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1());
533 } 535 }
534 536
535 537
536 ev = er.next(); 538 ev = er.next();
537 } 539 }
538 //algo 6 compare todo 540 //algo 6 compare todo
539 to = tl.first(); 541 to = tl.first();
540 procCount = 0; 542 procCount = 0;
541 QPtrList<Todo> tl1 = calendarTemp->rawTodos(); 543 QPtrList<Todo> tl1 = calendarTemp->rawTodos();
542 Todo* to1 ; 544 Todo* to1 ;
543 message = i18n(" Comparing todo # "); 545 message = i18n(" Comparing todo # ");
544 while ( to ) { 546 while ( to ) {
545 qDebug("todo2 %d ", procCount); 547 qDebug("todo2 %d ", procCount);
546 status.setText ( message + QString::number ( ++procCount ) ); 548 status.setText ( message + QString::number ( ++procCount ) );
547 qApp->processEvents(); 549 qApp->processEvents();
548 QString cSum = to->getCsum(mProfileName); 550 QString cSum = to->getCsum(mProfileName);
549 Todo* to1 = tl1.first(); 551 Todo* to1 = tl1.first();
550 while ( to1 ) { 552 while ( to1 ) {
551 if ( to1->getCsum( mProfileName ) == cSum ) { 553 if ( to1->getCsum( mProfileName ) == cSum ) {
552 tl1.remove( to1 ); 554 tl1.remove( to1 );
553 afterSave( to ); 555 afterSave( to );
554 to->setID(mProfileName, to1->getID(mProfileName) ); 556 to->setID(mProfileName, to1->getID(mProfileName) );
555 break; 557 break;
556 } 558 }
557 to1 = tl1.next(); 559 to1 = tl1.next();
558 } 560 }
559 if ( ! to1 ) { 561 if ( ! to1 ) {
560 to->removeID(mProfileName); 562 to->removeID(mProfileName);
561 qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); 563 qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1());
562 } 564 }
563 565
564 to = tl.next(); 566 to = tl.next();
565 } 567 }
566 delete calendarTemp; 568 delete calendarTemp;
567 return true; 569 return true;
568 570
569 571
570 572
571} 573}
572 574
573 575
574QString PhoneFormat::toString( Calendar * ) 576QString PhoneFormat::toString( Calendar * )
575{ 577{
576 return QString::null; 578 return QString::null;
577} 579}
578bool PhoneFormat::fromString( Calendar *calendar, const QString & text) 580bool PhoneFormat::fromString( Calendar *calendar, const QString & text)
579{ 581{
580 return false; 582 return false;
581} 583}