1 #define _GNU_SOURCE /* For strcasestr */
21 #include "message-cmdline.h"
25 COMPOSE_ANIMATION
= 1,
47 const ComposeType type
;
50 ComposeMapEntry ComposeMap
[] = {
51 {"ANIMATION", COMPOSE_ANIMATION
},
52 {"BOOKMARK", COMPOSE_BOOKMARK
},
53 {"CALENDAR", COMPOSE_CALENDAR
},
54 {"CALLER", COMPOSE_CALLER
},
56 {"MMSINDICATOR", COMPOSE_MMSINDICATOR
},
57 {"MMSSETTINGS", COMPOSE_MMSSETTINGS
},
58 {"OPERATOR", COMPOSE_OPERATOR
},
59 {"PICTURE", COMPOSE_PICTURE
},
60 {"PROFILE", COMPOSE_PROFILE
},
61 {"RINGTONE", COMPOSE_RINGTONE
},
62 {"SMSTEMPLATE", COMPOSE_SMSTEMPLATE
},
63 {"TEXT", COMPOSE_TEXT
},
64 {"TODO", COMPOSE_TODO
},
65 {"VCARD10", COMPOSE_VCARD10
},
66 {"VCARD21", COMPOSE_VCARD21
},
67 {"WAPINDICATOR", COMPOSE_WAPINDICATOR
},
68 {"WAPSETTINGS", COMPOSE_WAPSETTINGS
},
73 #define BMP_AUTO_ALLOC(n) \
74 if (bitmap[n] == NULL) { \
75 bitmap[n] = (GSM_MultiBitmap *)malloc(sizeof(GSM_MultiBitmap)); \
76 if (bitmap[n] == NULL) { \
77 error = ERR_MOREMEMORY; \
80 memset(bitmap[n], 0, sizeof(GSM_MultiBitmap)); \
83 #define RNG_AUTO_ALLOC(n) \
84 if (ringtone[n] == NULL) { \
85 ringtone[n] = (GSM_Ringtone *)malloc(sizeof(GSM_Ringtone)); \
86 if (ringtone[n] == NULL) { \
87 error = ERR_MOREMEMORY; \
90 memset(ringtone[n], 0, sizeof(GSM_Ringtone)); \
93 #define SEND_SAVE_SMS_BUFFER_SIZE 10000
95 GSM_Error
CreateMessage(GSM_Message_Type
*type
, GSM_MultiSMSMessage
*sms
, int argc
, int typearg
, char *argv
[], GSM_StateMachine
*sm
)
98 * Whether SMSC is set manually (0) or should be read from phone.
104 #ifdef GSM_ENABLE_BACKUP
107 int i
,j
,z
,FramesNum
= 0;
109 GSM_Ringtone
*ringtone
[GSM_MAX_MULTI_SMS
];
110 GSM_MultiBitmap
*bitmap
[GSM_MAX_MULTI_SMS
];
111 GSM_MultiBitmap bitmap2
;
112 GSM_MultiPartSMSInfo SMSInfo
;
113 GSM_NetworkInfo NetInfo
;
114 GSM_MMSIndicator MMSInfo
;
115 FILE *ReplaceFileHadle
,*f
;
116 unsigned char ReplaceBuffer2
[200],ReplaceBuffer
[200];
117 char InputBuffer
[SEND_SAVE_SMS_BUFFER_SIZE
/2+1];
118 unsigned char Buffer
[GSM_MAX_MULTI_SMS
][SEND_SAVE_SMS_BUFFER_SIZE
];
121 gboolean ReplyViaSameSMSC
= FALSE
;
123 gboolean EMS16Bit
= FALSE
;
127 /* Parameters required only during saving */
128 int Folder
= 1; /*Inbox by default */
129 GSM_SMS_State State
= SMS_Sent
;
131 /* Required only during sending */
132 GSM_SMSValidity Validity
;
134 gboolean DeliveryReport
= FALSE
;
135 /* Whether we already got text for TEXT message */
136 gboolean HasText
= FALSE
;
137 ComposeType compose_type
= 0;
139 * Recipient or sender.
141 unsigned char RemoteNumber
[(GSM_MAX_NUMBER_LENGTH
+ 1) * 2];
145 unsigned char Name
[(GSM_MAX_SMS_NAME_LENGTH
+ 1) * 2];
147 * SMSC to use for message.
149 unsigned char SMSC
[(GSM_MAX_NUMBER_LENGTH
+ 1) * 2];
158 ReplaceBuffer
[0] = 0;
159 ReplaceBuffer
[1] = 0;
161 for (i
= 0; i
< GSM_MAX_MULTI_SMS
; i
++) {
166 #ifdef GSM_ENABLE_BACKUP
167 GSM_ClearBackup(&Backup
);
170 EncodeUnicode(RemoteNumber
, "Gammu", 5);
172 GSM_ClearMultiPartSMSInfo(&SMSInfo
);
173 SMSInfo
.ReplaceMessage
= 0;
174 SMSInfo
.EntriesNum
= 1;
176 Validity
.Relative
= 0;
179 if (*type
== SMS_Save
) {
180 startarg
= typearg
+ 1;
182 /* When not saving SMS, recipient has to be specified */
183 if (typearg
+ 1 >= argc
) {
184 printf("%s\n", _("Not enough parameters!"));
187 EncodeUnicode(RemoteNumber
, argv
[typearg
+ 1], strlen(argv
[typearg
+ 1]));
188 startarg
= typearg
+ 2;
191 if (*type
== SMS_SMSD
|| *type
== SMS_Display
) {
193 * We don't care about SMSC number here, SMSD handles this
194 * itself and for displaying we don't really need a SMSC
200 for (i
= 0; ComposeMap
[i
].type
!= 0; i
++) {
201 if (strcasecmp(argv
[typearg
], ComposeMap
[i
].name
) == 0) {
202 compose_type
= ComposeMap
[i
].type
;
207 if (compose_type
== 0) {
208 printf(_("What format of sms (\"%s\") ?\n"),argv
[typearg
]);
212 switch (compose_type
) {
214 /* Text is fed to the buffer later! */
215 SMSInfo
.Entries
[0].Buffer
= Buffer
[0];
216 SMSInfo
.Entries
[0].ID
= SMS_Text
;
217 SMSInfo
.UnicodeCoding
= FALSE
;
219 case COMPOSE_SMSTEMPLATE
:
220 SMSInfo
.UnicodeCoding
= FALSE
;
221 SMSInfo
.EntriesNum
= 1;
224 SMSInfo
.Entries
[0].Buffer
= Buffer
[0];
225 SMSInfo
.Entries
[0].ID
= SMS_AlcatelSMSTemplateName
;
228 SMSInfo
.UnicodeCoding
= FALSE
;
229 SMSInfo
.EntriesNum
= 0;
231 case COMPOSE_MMSINDICATOR
:
232 if (argc
< 3 + startarg
) {
233 printf("%s\n", _("Where are parameters?"));
236 SMSInfo
.Entries
[0].ID
= SMS_MMSIndicatorLong
;
237 SMSInfo
.Entries
[0].MMSIndicator
= &MMSInfo
;
238 if (*type
== SMS_Save
) {
239 EncodeUnicode(RemoteNumber
,"MMS Info",8);
241 strcpy(MMSInfo
.Address
, argv
[0 + startarg
]);
242 strcpy(MMSInfo
.Title
, argv
[1 + startarg
]);
243 strcpy(MMSInfo
.Sender
, argv
[2 + startarg
]);
244 MMSInfo
.Class
= GSM_MMS_Auto
;
245 MMSInfo
.MessageSize
= 0;
248 case COMPOSE_WAPINDICATOR
:
249 if (argc
< 2 + startarg
) {
250 printf("%s\n", _("Where are parameters?"));
253 SMSInfo
.Entries
[0].ID
= SMS_WAPIndicatorLong
;
254 SMSInfo
.Entries
[0].MMSIndicator
= &MMSInfo
;
255 if (*type
== SMS_Save
) {
256 EncodeUnicode(RemoteNumber
,"WAP Info",8);
258 strcpy(MMSInfo
.Address
, argv
[0 + startarg
]);
259 strcpy(MMSInfo
.Title
, argv
[1 + startarg
]);
262 case COMPOSE_RINGTONE
:
263 if (argc
< 1 + startarg
) {
264 printf("%s\n", _("Where is ringtone filename?"));
268 ringtone
[0]->Format
= RING_NOTETONE
;
269 error
=GSM_ReadRingtoneFile(argv
[startarg
], ringtone
[0]);
270 if (error
!= ERR_NONE
) goto end_compose
;
271 SMSInfo
.Entries
[0].ID
= SMS_NokiaRingtone
;
272 SMSInfo
.Entries
[0].Ringtone
= ringtone
[0];
273 if (*type
== SMS_Save
) {
274 CopyUnicodeString(RemoteNumber
, ringtone
[0]->Name
);
275 EncodeUnicode(Name
,"Ringtone ",9);
276 CopyUnicodeString(Name
+9*2, ringtone
[0]->Name
);
280 case COMPOSE_OPERATOR
:
281 if (argc
< 1 + startarg
) {
282 printf("%s\n", _("Where is logo filename?"));
286 bitmap
[0]->Bitmap
[0].Type
= GSM_OperatorLogo
;
287 error
=GSM_ReadBitmapFile(argv
[startarg
], bitmap
[0]);
288 if (error
!= ERR_NONE
) goto end_compose
;
289 strcpy(bitmap
[0]->Bitmap
[0].NetworkCode
,"000 00");
290 SMSInfo
.Entries
[0].ID
= SMS_NokiaOperatorLogo
;
291 SMSInfo
.Entries
[0].Bitmap
= bitmap
[0];
292 if (*type
== SMS_Save
) {
293 EncodeUnicode(RemoteNumber
, "OpLogo",6);
294 EncodeUnicode(Name
,"OpLogo ",7);
299 if (argc
< 1 + startarg
) {
300 printf("%s\n", _("Where is logo filename?"));
304 bitmap
[0]->Bitmap
[0].Type
= GSM_CallerGroupLogo
;
305 error
=GSM_ReadBitmapFile(argv
[startarg
], bitmap
[0]);
306 if (error
!= ERR_NONE
) goto end_compose
;
307 SMSInfo
.Entries
[0].ID
= SMS_NokiaCallerLogo
;
308 SMSInfo
.Entries
[0].Bitmap
= bitmap
[0];
309 if (*type
== SMS_Save
) {
310 EncodeUnicode(RemoteNumber
, "Caller",6);
314 case COMPOSE_ANIMATION
:
315 SMSInfo
.UnicodeCoding
= FALSE
;
316 SMSInfo
.EntriesNum
= 1;
317 if (argc
< 1 + startarg
) {
318 printf("%s\n", _("Where is number of frames?"));
322 bitmap
[0]->Number
= 0;
324 frames_num
= GetInt(argv
[startarg
]);
325 if (frames_num
> GSM_MAX_MULTI_BITMAP
) {
326 printf("%s\n", _("Too many animation frames!"));
330 bitmap2
.Bitmap
[0].Type
= GSM_StartupLogo
;
331 error
=GSM_ReadBitmapFile(argv
[startarg
+ i
],&bitmap2
);
332 if (error
!= ERR_NONE
) goto end_compose
;
333 for (j
=0;j
<bitmap2
.Number
;j
++) {
334 if (bitmap
[0]->Number
== frames_num
)
336 memcpy(&bitmap
[0]->Bitmap
[bitmap
[0]->Number
],&bitmap2
.Bitmap
[j
],sizeof(GSM_Bitmap
));
339 if (bitmap
[0]->Number
== frames_num
)
343 SMSInfo
.Entries
[0].ID
= SMS_AlcatelMonoAnimationLong
;
344 SMSInfo
.Entries
[0].Bitmap
= bitmap
[0];
345 bitmap
[0]->Bitmap
[0].Text
[0] = 0;
346 bitmap
[0]->Bitmap
[0].Text
[1] = 0;
347 startarg
+= 1 + frames_num
;
349 case COMPOSE_PICTURE
:
350 if (argc
< 1 + startarg
) {
351 printf("%s\n", _("Where is logo filename?"));
355 bitmap
[0]->Bitmap
[0].Type
= GSM_PictureImage
;
356 error
=GSM_ReadBitmapFile(argv
[startarg
], bitmap
[0]);
357 printf(_("File \"%s\"\n"),argv
[startarg
]);
358 if (error
!= ERR_NONE
) goto end_compose
;
359 SMSInfo
.Entries
[0].ID
= SMS_NokiaPictureImageLong
;
360 SMSInfo
.Entries
[0].Bitmap
= bitmap
[0];
361 SMSInfo
.UnicodeCoding
= FALSE
;
362 bitmap
[0]->Bitmap
[0].Text
[0] = 0;
363 bitmap
[0]->Bitmap
[0].Text
[1] = 0;
364 if (*type
== SMS_Save
) {
365 EncodeUnicode(RemoteNumber
, "Picture",7);
366 EncodeUnicode(Name
,"Picture Image",13);
370 #ifdef GSM_ENABLE_BACKUP
371 case COMPOSE_BOOKMARK
:
372 if (argc
< 2 + startarg
) {
373 printf("%s\n", _("Where is backup filename and location?"));
376 error
=GSM_ReadBackupFile(argv
[startarg
],&Backup
,GSM_GuessBackupFormat(argv
[startarg
], FALSE
));
377 if (error
!= ERR_NONE
&& error
!= ERR_NOTIMPLEMENTED
) goto end_compose
;
379 while (Backup
.WAPBookmark
[i
]!=NULL
) {
380 if (i
== GetInt(argv
[1 + startarg
])-1) break;
383 if (i
!= GetInt(argv
[1 + startarg
])-1) {
384 printf("%s\n", _("Bookmark not found in file"));
387 SMSInfo
.Entries
[0].ID
= SMS_NokiaWAPBookmarkLong
;
388 SMSInfo
.Entries
[0].Bookmark
= Backup
.WAPBookmark
[i
];
389 if (*type
== SMS_Save
) {
390 EncodeUnicode(RemoteNumber
, "Bookmark",8);
391 EncodeUnicode(Name
,"WAP Bookmark",12);
395 case COMPOSE_WAPSETTINGS
:
396 if (argc
< 3 + startarg
) {
397 printf("%s\n", _("Where is backup filename and location?"));
400 error
=GSM_ReadBackupFile(argv
[startarg
],&Backup
,GSM_GuessBackupFormat(argv
[startarg
], FALSE
));
401 if (error
!= ERR_NONE
&& error
!= ERR_NOTIMPLEMENTED
) goto end_compose
;
403 while (Backup
.WAPSettings
[i
]!=NULL
) {
404 if (i
== GetInt(argv
[1 + startarg
])-1) break;
407 if (i
!= GetInt(argv
[1 + startarg
])-1 || Backup
.WAPSettings
[i
] == NULL
) {
408 printf("%s\n", _("WAP settings not found in file"));
411 SMSInfo
.Entries
[0].Settings
= NULL
;
412 for (j
=0;j
<Backup
.WAPSettings
[i
]->Number
;j
++) {
413 switch (Backup
.WAPSettings
[i
]->Settings
[j
].Bearer
) {
414 case WAPSETTINGS_BEARER_GPRS
:
415 if (strcasecmp(argv
[2 + startarg
],"GPRS") == 0) {
416 SMSInfo
.Entries
[0].Settings
= &Backup
.WAPSettings
[i
]->Settings
[j
];
419 case WAPSETTINGS_BEARER_DATA
:
420 if (strcasecmp(argv
[2 + startarg
],"DATA") == 0) {
421 SMSInfo
.Entries
[0].Settings
= &Backup
.WAPSettings
[i
]->Settings
[j
];
428 if (SMSInfo
.Entries
[0].Settings
== NULL
) {
429 printf("%s\n", _("Sorry. For now there is only support for GPRS or DATA bearers end"));
432 SMSInfo
.Entries
[0].ID
= SMS_NokiaWAPSettingsLong
;
433 if (*type
== SMS_Save
) {
434 EncodeUnicode(RemoteNumber
, "Settings",8);
435 EncodeUnicode(Name
,"WAP Settings",12);
439 case COMPOSE_MMSSETTINGS
:
440 if (argc
< 2 + startarg
) {
441 printf("%s\n", _("Where is backup filename and location?"));
444 error
=GSM_ReadBackupFile(argv
[startarg
],&Backup
,GSM_GuessBackupFormat(argv
[startarg
], FALSE
));
445 if (error
!= ERR_NONE
&& error
!= ERR_NOTIMPLEMENTED
) goto end_compose
;
447 while (Backup
.MMSSettings
[i
]!=NULL
) {
448 if (i
== GetInt(argv
[1 + startarg
])-1) break;
451 if (i
!= GetInt(argv
[1 + startarg
])-1 || Backup
.MMSSettings
[i
] == NULL
) {
452 printf("%s\n", _("MMS settings not found in file"));
455 SMSInfo
.Entries
[0].Settings
= NULL
;
456 for (j
=0;j
<Backup
.MMSSettings
[i
]->Number
;j
++) {
457 switch (Backup
.MMSSettings
[i
]->Settings
[j
].Bearer
) {
458 case WAPSETTINGS_BEARER_GPRS
:
459 SMSInfo
.Entries
[0].Settings
= &Backup
.MMSSettings
[i
]->Settings
[j
];
465 if (SMSInfo
.Entries
[0].Settings
== NULL
) {
466 printf("%s\n", _("Sorry. No GPRS bearer found in MMS settings"));
469 SMSInfo
.Entries
[0].ID
= SMS_NokiaMMSSettingsLong
;
470 if (*type
== SMS_Save
) {
471 EncodeUnicode(RemoteNumber
, "Settings",8);
472 EncodeUnicode(Name
,"MMS Settings",12);
476 case COMPOSE_CALENDAR
:
477 if (argc
< 2 + startarg
) {
478 printf("%s\n", _("Where is backup filename and location?"));
481 error
=GSM_ReadBackupFile(argv
[startarg
],&Backup
,GSM_GuessBackupFormat(argv
[startarg
], FALSE
));
482 if (error
!= ERR_NONE
&& error
!= ERR_NOTIMPLEMENTED
) goto end_compose
;
484 while (Backup
.Calendar
[i
]!=NULL
) {
485 if (i
== GetInt(argv
[1 + startarg
])-1) break;
488 if (i
!= GetInt(argv
[1 + startarg
])-1) {
489 printf("%s\n", _("Calendar note not found in file"));
492 SMSInfo
.Entries
[0].ID
= SMS_NokiaVCALENDAR10Long
;
493 SMSInfo
.Entries
[0].Calendar
= Backup
.Calendar
[i
];
494 if (*type
== SMS_Save
) {
495 EncodeUnicode(RemoteNumber
, "Calendar",8);
500 if (argc
< 2 + startarg
) {
501 printf("%s\n", _("Where is backup filename and location?"));
504 error
=GSM_ReadBackupFile(argv
[startarg
],&Backup
,GSM_GuessBackupFormat(argv
[startarg
], FALSE
));
505 if (error
!= ERR_NONE
&& error
!= ERR_NOTIMPLEMENTED
) goto end_compose
;
507 while (Backup
.ToDo
[i
]!=NULL
) {
508 if (i
== GetInt(argv
[1 + startarg
])-1) break;
511 if (i
!= GetInt(argv
[1 + startarg
])-1) {
512 printf("%s\n", _("ToDo note not found in file"));
515 SMSInfo
.Entries
[0].ID
= SMS_NokiaVTODOLong
;
516 SMSInfo
.Entries
[0].ToDo
= Backup
.ToDo
[i
];
517 if (*type
== SMS_Save
) {
518 EncodeUnicode(RemoteNumber
, "ToDo",8);
522 case COMPOSE_VCARD10
:
523 case COMPOSE_VCARD21
:
524 if (argc
< 3 + startarg
) {
525 printf("%s\n", _("Where is backup filename and location and memory type?"));
528 error
=GSM_ReadBackupFile(argv
[startarg
],&Backup
,GSM_GuessBackupFormat(argv
[startarg
], FALSE
));
529 if (error
!= ERR_NONE
&& error
!= ERR_NOTIMPLEMENTED
) goto end_compose
;
531 if (strcasecmp(argv
[1 + startarg
],"SM") == 0) {
532 while (Backup
.SIMPhonebook
[i
]!=NULL
) {
533 if (i
== GetInt(argv
[2 + startarg
])-1) break;
536 if (i
!= GetInt(argv
[2 + startarg
])-1) {
537 printf("%s\n", _("Phonebook entry not found in file"));
540 SMSInfo
.Entries
[0].Phonebook
= Backup
.SIMPhonebook
[i
];
541 } else if (strcasecmp(argv
[1 + startarg
],"ME") == 0) {
542 while (Backup
.PhonePhonebook
[i
]!=NULL
) {
543 if (i
== GetInt(argv
[2 + startarg
])-1) break;
546 if (i
!= GetInt(argv
[2 + startarg
])-1) {
547 printf("%s\n", _("Phonebook entry not found in file"));
550 SMSInfo
.Entries
[0].Phonebook
= Backup
.PhonePhonebook
[i
];
552 printf(_("Unknown memory type: \"%s\"\n"),argv
[1 + startarg
]);
555 if (compose_type
== COMPOSE_VCARD10
) {
556 SMSInfo
.Entries
[0].ID
= SMS_VCARD10Long
;
558 SMSInfo
.Entries
[0].ID
= SMS_VCARD21Long
;
560 if (*type
== SMS_Save
) {
561 EncodeUnicode(RemoteNumber
, "VCARD",5);
562 EncodeUnicode(Name
, "Phonebook entry",15);
567 case COMPOSE_BOOKMARK
:
568 case COMPOSE_WAPSETTINGS
:
569 case COMPOSE_MMSSETTINGS
:
570 case COMPOSE_CALENDAR
:
572 case COMPOSE_VCARD10
:
573 case COMPOSE_VCARD21
:
574 printf("%s\n", _("Backup functionality not compiled in!"));
575 exit(100 + ERR_DISABLED
);
578 case COMPOSE_PROFILE
:
579 SMSInfo
.Entries
[0].ID
= SMS_NokiaProfileLong
;
580 if (*type
== SMS_Save
) {
581 EncodeUnicode(RemoteNumber
, "Profile",7);
586 for (i
= startarg
; i
< argc
; i
++) {
589 if (*type
== SMS_Save
|| *type
== SMS_SendSaved
) {
590 if (strcasecmp(argv
[i
],"-folder") == 0) {
595 if (*type
== SMS_Save
) {
596 if (strcasecmp(argv
[i
],"-unread") == 0) {
600 if (strcasecmp(argv
[i
],"-read") == 0) {
604 if (strcasecmp(argv
[i
],"-unsent") == 0) {
608 if (strcasecmp(argv
[i
],"-sent") == 0) {
612 if (strcasecmp(argv
[i
],"-sender") == 0) {
616 if (strcasecmp(argv
[i
],"-smsname") == 0) {
621 if (strcasecmp(argv
[i
],"-save") == 0) {
622 *type
= SMS_SendSaved
;
625 if (strcasecmp(argv
[i
],"-report") == 0) {
629 if (strcasecmp(argv
[i
],"-validity") == 0) {
634 if (strcasecmp(argv
[i
],"-smscset") == 0) {
638 if (strcasecmp(argv
[i
],"-smscnumber") == 0) {
642 if (strcasecmp(argv
[i
],"-protected") == 0) {
646 if (strcasecmp(argv
[i
],"-reply") == 0) {
647 ReplyViaSameSMSC
=TRUE
;
650 if (strcasecmp(argv
[i
],"-maxsms") == 0) {
654 if (compose_type
== COMPOSE_RINGTONE
) {
655 if (strcasecmp(argv
[i
],"-long") == 0) {
656 SMSInfo
.Entries
[0].ID
= SMS_NokiaRingtoneLong
;
659 if (strcasecmp(argv
[i
],"-scale") == 0) {
661 ringtone
[0]->NoteTone
.AllNotesScale
=TRUE
;
665 if (compose_type
== COMPOSE_TEXT
) {
666 if (strcasecmp(argv
[i
],"-text") == 0) {
670 if (strcasecmp(argv
[i
],"-textutf8") == 0) {
674 if (strcasecmp(argv
[i
],"-inputunicode") == 0) {
675 ReadUnicodeFile(Buffer
[0],InputBuffer
);
678 if (strcasecmp(argv
[i
],"-16bit") == 0) {
679 if (SMSInfo
.Entries
[0].ID
== SMS_ConcatenatedTextLong
) SMSInfo
.Entries
[0].ID
= SMS_ConcatenatedTextLong16bit
;
680 if (SMSInfo
.Entries
[0].ID
== SMS_ConcatenatedAutoTextLong
) SMSInfo
.Entries
[0].ID
= SMS_ConcatenatedAutoTextLong16bit
;
683 if (strcasecmp(argv
[i
],"-flash") == 0) {
687 if (strcasecmp(argv
[i
],"-len") == 0) {
691 /* Backward compatibility with bad docs */
692 if (strcasecmp(argv
[i
],"-maxlen") == 0) {
696 if (strcasecmp(argv
[i
],"-autolen") == 0) {
700 if (strcasecmp(argv
[i
],"-unicode") == 0) {
701 SMSInfo
.UnicodeCoding
= TRUE
;
704 if (strcasecmp(argv
[i
],"-enablevoice") == 0) {
705 SMSInfo
.Entries
[0].ID
= SMS_EnableVoice
;
708 if (strcasecmp(argv
[i
],"-disablevoice") == 0) {
709 SMSInfo
.Entries
[0].ID
= SMS_DisableVoice
;
712 if (strcasecmp(argv
[i
],"-enablefax") == 0) {
713 SMSInfo
.Entries
[0].ID
= SMS_EnableFax
;
716 if (strcasecmp(argv
[i
],"-disablefax") == 0) {
717 SMSInfo
.Entries
[0].ID
= SMS_DisableFax
;
720 if (strcasecmp(argv
[i
],"-enableemail") == 0) {
721 SMSInfo
.Entries
[0].ID
= SMS_EnableEmail
;
724 if (strcasecmp(argv
[i
],"-disableemail") == 0) {
725 SMSInfo
.Entries
[0].ID
= SMS_DisableEmail
;
728 if (strcasecmp(argv
[i
],"-voidsms") == 0) {
729 SMSInfo
.Entries
[0].ID
= SMS_VoidSMS
;
732 if (strcasecmp(argv
[i
],"-replacemessages") == 0 &&
733 SMSInfo
.Entries
[0].ID
!= SMS_ConcatenatedTextLong
) {
737 if (strcasecmp(argv
[i
],"-replacefile") == 0) {
742 if (compose_type
== COMPOSE_PICTURE
) {
743 if (strcasecmp(argv
[i
],"-text") == 0) {
747 if (strcasecmp(argv
[i
],"-unicode") == 0) {
748 SMSInfo
.UnicodeCoding
= TRUE
;
751 if (strcasecmp(argv
[i
],"-alcatelbmmi") == 0) {
753 bitmap
[0]->Bitmap
[0].Type
= GSM_StartupLogo
;
754 error
= GSM_ReadBitmapFile(argv
[startarg
-1], bitmap
[0]);
755 if (error
!= ERR_NONE
) goto end_compose
;
756 SMSInfo
.UnicodeCoding
= TRUE
;
757 SMSInfo
.Entries
[0].ID
= SMS_AlcatelMonoBitmapLong
;
762 if (compose_type
== COMPOSE_VCARD10
) {
763 if (strcasecmp(argv
[i
],"-nokia") == 0) {
764 SMSInfo
.Entries
[0].ID
= SMS_NokiaVCARD10Long
;
769 if (compose_type
== COMPOSE_VCARD21
) {
770 if (strcasecmp(argv
[i
],"-nokia") == 0) {
771 SMSInfo
.Entries
[0].ID
= SMS_NokiaVCARD21Long
;
776 if (compose_type
== COMPOSE_PROFILE
) {
777 if (strcasecmp(argv
[i
],"-name") == 0) {
781 if (strcasecmp(argv
[i
],"-ringtone") == 0) {
785 if (strcasecmp(argv
[i
],"-bitmap") == 0) {
790 if (compose_type
== COMPOSE_SMSTEMPLATE
) {
791 if (strcasecmp(argv
[i
],"-unicode") == 0) {
792 SMSInfo
.UnicodeCoding
= TRUE
;
795 if (strcasecmp(argv
[i
],"-text") == 0) {
799 if (strcasecmp(argv
[i
],"-unicodefiletext") == 0) {
803 if (strcasecmp(argv
[i
],"-defsound") == 0) {
804 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSPredefinedSound
;
808 if (strcasecmp(argv
[i
],"-defanimation") == 0) {
809 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSPredefinedAnimation
;
813 if (strcasecmp(argv
[i
],"-tone10") == 0) {
814 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSound10
;
815 if (Protected
!= 0) {
816 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
822 if (strcasecmp(argv
[i
],"-tone10long") == 0) {
823 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSound10Long
;
824 if (Protected
!= 0) {
825 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
831 if (strcasecmp(argv
[i
],"-tone12") == 0) {
832 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSound12
;
833 if (Protected
!= 0) {
834 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
840 if (strcasecmp(argv
[i
],"-tone12long") == 0) {
841 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSound12Long
;
842 if (Protected
!= 0) {
843 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
849 if (strcasecmp(argv
[i
],"-toneSE") == 0) {
850 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSonyEricssonSound
;
851 if (Protected
!= 0) {
852 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
858 if (strcasecmp(argv
[i
],"-toneSElong") == 0) {
859 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSonyEricssonSoundLong
;
860 if (Protected
!= 0) {
861 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
867 if (strcasecmp(argv
[i
],"-variablebitmap") == 0) {
868 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSVariableBitmap
;
869 if (Protected
!= 0) {
870 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
876 if (strcasecmp(argv
[i
],"-variablebitmaplong") == 0) {
877 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSVariableBitmapLong
;
878 if (Protected
!= 0) {
879 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
885 if (strcasecmp(argv
[i
],"-animation") == 0) {
886 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSAnimation
;
887 if (Protected
!= 0) {
888 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
891 BMP_AUTO_ALLOC(SMSInfo
.EntriesNum
);
892 bitmap
[SMSInfo
.EntriesNum
]->Number
= 0;
897 if (compose_type
== COMPOSE_EMS
) {
898 if (strcasecmp(argv
[i
],"-unicode") == 0) {
899 SMSInfo
.UnicodeCoding
= TRUE
;
902 if (strcasecmp(argv
[i
],"-16bit") == 0) {
906 if (strcasecmp(argv
[i
],"-format") == 0) {
910 if (strcasecmp(argv
[i
],"-text") == 0) {
914 if (strcasecmp(argv
[i
],"-unicodefiletext") == 0) {
918 if (strcasecmp(argv
[i
],"-defsound") == 0) {
919 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSPredefinedSound
;
923 if (strcasecmp(argv
[i
],"-defanimation") == 0) {
924 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSPredefinedAnimation
;
928 if (strcasecmp(argv
[i
],"-tone10") == 0) {
929 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSound10
;
930 if (Protected
!= 0) {
931 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
937 if (strcasecmp(argv
[i
],"-tone10long") == 0) {
938 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSound10Long
;
939 if (Protected
!= 0) {
940 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
946 if (strcasecmp(argv
[i
],"-tone12") == 0) {
947 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSound12
;
948 if (Protected
!= 0) {
949 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
955 if (strcasecmp(argv
[i
],"-tone12long") == 0) {
956 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSound12Long
;
957 if (Protected
!= 0) {
958 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
964 if (strcasecmp(argv
[i
],"-toneSE") == 0) {
965 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSonyEricssonSound
;
966 if (Protected
!= 0) {
967 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
973 if (strcasecmp(argv
[i
],"-toneSElong") == 0) {
974 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSonyEricssonSoundLong
;
975 if (Protected
!= 0) {
976 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
982 if (strcasecmp(argv
[i
],"-fixedbitmap") == 0) {
983 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSFixedBitmap
;
984 if (Protected
!= 0) {
985 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
991 if (strcasecmp(argv
[i
],"-variablebitmap") == 0) {
992 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSVariableBitmap
;
993 if (Protected
!= 0) {
994 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
1000 if (strcasecmp(argv
[i
],"-variablebitmaplong") == 0) {
1001 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSVariableBitmapLong
;
1002 if (Protected
!= 0) {
1003 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
1009 if (strcasecmp(argv
[i
],"-animation") == 0) {
1010 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSAnimation
;
1011 if (Protected
!= 0) {
1012 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= TRUE
;
1015 BMP_AUTO_ALLOC(SMSInfo
.EntriesNum
);
1016 bitmap
[SMSInfo
.EntriesNum
]->Number
= 0;
1021 if (compose_type
== COMPOSE_OPERATOR
) {
1022 if (strcasecmp(argv
[i
],"-netcode") == 0) {
1026 if (strcasecmp(argv
[i
],"-biglogo") == 0) {
1027 SMSInfo
.Entries
[0].ID
= SMS_NokiaOperatorLogoLong
;
1032 printf(_("Unknown parameter (\"%s\")\n"),argv
[i
]);
1035 case 1: /* SMS folder - only during saving SMS */
1036 Folder
= GetInt(argv
[i
]);
1039 case 2: /* Remote number - only during saving SMS */
1040 EncodeUnicode(RemoteNumber
,argv
[i
],strlen(argv
[i
]));
1043 case 3: /* SMSC set number */
1044 SMSCSet
= GetInt(argv
[i
]);
1047 case 4: /* Number of SMSC */
1048 EncodeUnicode(SMSC
,argv
[i
],strlen(argv
[i
]));
1052 case 5: /* Length of text SMS */
1053 param_value
= GetInt(argv
[i
]);
1054 if (param_value
<= 0) {
1055 printf(_("Wrong message length (\"%s\")\n"),argv
[i
]);
1058 printf("%d / %d\n", param_value
, chars_read
);
1059 if (param_value
< chars_read
) {
1060 Buffer
[0][param_value
* 2] = 0x00;
1061 Buffer
[0][param_value
* 2 + 1] = 0x00;
1063 SMSInfo
.Entries
[0].ID
= SMS_ConcatenatedTextLong
;
1064 if (strcasecmp(argv
[i
-1],"-autolen") == 0) {
1065 SMSInfo
.Entries
[0].ID
= SMS_ConcatenatedAutoTextLong
;
1069 case 6: /* Picture Images - text */
1071 EncodeUnicode(bitmap
[0]->Bitmap
[0].Text
,argv
[i
],strlen(argv
[i
]));
1074 case 7: /* Operator Logo - network code */
1076 strncpy(bitmap
[0]->Bitmap
[0].NetworkCode
,argv
[i
],7);
1077 if (!strcmp(DecodeUnicodeConsole(GSM_GetNetworkName(bitmap
[0]->Bitmap
[0].NetworkCode
)),"unknown")) {
1078 printf(_("Unknown GSM network code (\"%s\")\n"),argv
[i
]);
1081 if (*type
== SMS_Save
) {
1082 EncodeUnicode(RemoteNumber
, "OpLogo",6);
1083 EncodeUnicode(RemoteNumber
+6*2,bitmap
[0]->Bitmap
[0].NetworkCode
,3);
1084 EncodeUnicode(RemoteNumber
+6*2+3*2,bitmap
[0]->Bitmap
[0].NetworkCode
+4,2);
1085 if (UnicodeLength(GSM_GetNetworkName(bitmap
[0]->Bitmap
[0].NetworkCode
))<GSM_MAX_SMS_NAME_LENGTH
-7) {
1086 EncodeUnicode(Name
,"OpLogo ",7);
1087 CopyUnicodeString(Name
+7*2,GSM_GetNetworkName(bitmap
[0]->Bitmap
[0].NetworkCode
));
1089 CopyUnicodeString(Name
,RemoteNumber
);
1094 case 8:/* Reject duplicates ID */
1095 SMSInfo
.ReplaceMessage
= GetInt(argv
[i
]);
1096 if (SMSInfo
.ReplaceMessage
< 1 || SMSInfo
.ReplaceMessage
> 7) {
1097 printf(_("You have to give number between 1 and 7 (\"%s\")\n"),argv
[i
]);
1102 case 9:/* Replace file for text SMS */
1103 ReplaceFileHadle
= fopen(argv
[i
], "rb");
1104 if (ReplaceFileHadle
== NULL
) {
1105 error
= ERR_CANTOPENFILE
;
1108 memset(ReplaceBuffer
,0,sizeof(ReplaceBuffer
));
1109 if (fread(ReplaceBuffer
,1,sizeof(ReplaceBuffer
),ReplaceFileHadle
) != sizeof(ReplaceBuffer
)) {
1110 printf_err("%s", _("Error while writing file!\n"));
1112 fclose(ReplaceFileHadle
);
1113 ReadUnicodeFile(ReplaceBuffer2
,ReplaceBuffer
);
1114 for(j
=0;j
<(int)(UnicodeLength(Buffer
[0]));j
++) {
1115 for (z
=0;z
<(int)(UnicodeLength(ReplaceBuffer2
)/2);z
++) {
1116 if (ReplaceBuffer2
[z
*4] == Buffer
[0][j
] &&
1117 ReplaceBuffer2
[z
*4+1] == Buffer
[0][j
+1]) {
1118 Buffer
[0][j
] = ReplaceBuffer2
[z
*4+2];
1119 Buffer
[0][j
+1] = ReplaceBuffer2
[z
*4+3];
1127 Validity
.Format
= SMS_Validity_RelativeFormat
;
1128 if (strcasecmp(argv
[i
],"HOUR") == 0) Validity
.Relative
= SMS_VALID_1_Hour
;
1129 else if (strcasecmp(argv
[i
],"6HOURS") == 0) Validity
.Relative
= SMS_VALID_6_Hours
;
1130 else if (strcasecmp(argv
[i
],"DAY") == 0) Validity
.Relative
= SMS_VALID_1_Day
;
1131 else if (strcasecmp(argv
[i
],"3DAYS") == 0) Validity
.Relative
= SMS_VALID_3_Days
;
1132 else if (strcasecmp(argv
[i
],"WEEK") == 0) Validity
.Relative
= SMS_VALID_1_Week
;
1133 else if (strcasecmp(argv
[i
],"MAX") == 0) Validity
.Relative
= SMS_VALID_Max_Time
;
1135 printf(_("Unknown validity string (\"%s\")\n"),argv
[i
]);
1140 case 11:/* EMS text from parameter */
1141 EncodeUnicode(Buffer
[SMSInfo
.EntriesNum
],argv
[i
],strlen(argv
[i
]));
1142 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_ConcatenatedTextLong
;
1143 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Buffer
= Buffer
[SMSInfo
.EntriesNum
];
1144 SMSInfo
.EntriesNum
++;
1147 case 12:/* EMS predefined sound/animation number */
1148 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Number
= GetInt(argv
[i
]);
1149 SMSInfo
.EntriesNum
++;
1152 case 14: /* EMS ringtone - IMelody */
1153 RNG_AUTO_ALLOC(SMSInfo
.EntriesNum
);
1154 ringtone
[SMSInfo
.EntriesNum
]->Format
= RING_NOTETONE
;
1155 error
=GSM_ReadRingtoneFile(argv
[i
], ringtone
[SMSInfo
.EntriesNum
]);
1156 if (error
!= ERR_NONE
) goto end_compose
;
1157 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Ringtone
= ringtone
[SMSInfo
.EntriesNum
];
1158 SMSInfo
.EntriesNum
++;
1161 case 15:/* EMS bitmap file */
1162 BMP_AUTO_ALLOC(SMSInfo
.EntriesNum
);
1163 bitmap
[SMSInfo
.EntriesNum
]->Bitmap
[0].Type
= GSM_StartupLogo
;
1164 error
=GSM_ReadBitmapFile(argv
[i
], bitmap
[SMSInfo
.EntriesNum
]);
1165 if (error
!= ERR_NONE
) goto end_compose
;
1166 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Bitmap
= bitmap
[SMSInfo
.EntriesNum
];
1167 SMSInfo
.EntriesNum
++;
1170 case 16:/* Number of frames for EMS animation */
1171 FramesNum
= GetInt(argv
[i
]);
1172 if (FramesNum
< 1 || FramesNum
> 4) {
1173 printf(_("You have to give number of EMS frames between 1 and 4 (\"%s\")\n"),argv
[i
]);
1176 BMP_AUTO_ALLOC(SMSInfo
.EntriesNum
);
1177 bitmap
[SMSInfo
.EntriesNum
]->Number
= 0;
1180 case 17:/*File for EMS animation */
1181 BMP_AUTO_ALLOC(SMSInfo
.EntriesNum
);
1182 bitmap2
.Bitmap
[0].Type
=GSM_StartupLogo
;
1183 error
=GSM_ReadBitmapFile(argv
[i
],&bitmap2
);
1184 if (error
!= ERR_NONE
) {
1185 printf(_("Can't open file \"%s\"\n"),argv
[i
]);
1188 for (j
=0;j
<bitmap2
.Number
;j
++) {
1189 if (bitmap
[SMSInfo
.EntriesNum
]->Number
== FramesNum
) break;
1190 memcpy(&bitmap
[SMSInfo
.EntriesNum
]->Bitmap
[bitmap
[SMSInfo
.EntriesNum
]->Number
],&bitmap2
.Bitmap
[j
],sizeof(GSM_Bitmap
));
1191 bitmap
[SMSInfo
.EntriesNum
]->Number
++;
1193 if (bitmap
[SMSInfo
.EntriesNum
]->Number
== FramesNum
) {
1194 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Bitmap
= bitmap
[SMSInfo
.EntriesNum
];
1195 SMSInfo
.EntriesNum
++;
1199 case 18:/* EMS text from Unicode file */
1200 f
= fopen(argv
[i
],"rb");
1202 printf(_("Can't open file \"%s\"\n"),argv
[i
]);
1205 z
=fread(InputBuffer
,1,2000,f
);
1207 InputBuffer
[z
+1] = 0;
1209 ReadUnicodeFile(Buffer
[SMSInfo
.EntriesNum
],InputBuffer
);
1210 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_ConcatenatedTextLong
;
1211 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Buffer
= Buffer
[SMSInfo
.EntriesNum
];
1212 SMSInfo
.EntriesNum
++;
1215 case 19:/* Number of protected items */
1216 Protected
= GetInt(argv
[i
]);
1219 case 20:/* Formatting text for EMS */
1220 if (SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].ID
== SMS_ConcatenatedTextLong
) {
1221 for(j
=0;j
<(int)strlen(argv
[i
]);j
++) {
1222 switch(argv
[i
][j
]) {
1224 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Left
= TRUE
;
1227 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Center
= TRUE
;
1230 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Right
= TRUE
;
1233 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Large
= TRUE
;
1236 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Small
= TRUE
;
1239 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Bold
= TRUE
;
1242 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Italic
= TRUE
;
1245 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Underlined
= TRUE
;
1248 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Strikethrough
= TRUE
;
1251 printf(_("Unknown parameter (\"%c\")\n"),argv
[i
][j
]);
1256 printf("%s\n", _("Last parameter wasn't text"));
1262 MaxSMS
= GetInt(argv
[i
]);
1265 case 22:/* profile name */
1266 EncodeUnicode(Buffer
[0],argv
[i
],strlen(argv
[i
]));
1267 SMSInfo
.Entries
[0].Buffer
= Buffer
[0];
1270 case 23:/* profile ringtone */
1272 ringtone
[0]->Format
= RING_NOTETONE
;
1273 error
=GSM_ReadRingtoneFile(argv
[i
], ringtone
[0]);
1274 if (error
!= ERR_NONE
) goto end_compose
;
1275 SMSInfo
.Entries
[0].Ringtone
= ringtone
[0];
1278 case 24:/* profile bitmap */
1280 bitmap
[0]->Bitmap
[0].Type
= GSM_PictureImage
;
1281 error
=GSM_ReadBitmapFile(argv
[i
], bitmap
[0]);
1282 if (error
!= ERR_NONE
) goto end_compose
;
1283 bitmap
[0]->Bitmap
[0].Text
[0] = 0;
1284 bitmap
[0]->Bitmap
[0].Text
[1] = 0;
1285 SMSInfo
.Entries
[0].Bitmap
= bitmap
[0];
1288 case 25:/* sms name */
1289 if (strlen(argv
[i
])>GSM_MAX_SMS_NAME_LENGTH
) {
1290 printf(_("Too long SMS name (\"%s\"), ignored\n"),argv
[i
]);
1292 EncodeUnicode(Name
, argv
[i
],strlen(argv
[i
]));
1296 case 26:/* text from parameter */
1297 chars_read
= strlen(argv
[i
]);
1298 EncodeUnicode(Buffer
[0], argv
[i
], chars_read
);
1302 case 27:/* utf-8 text from parameter */
1303 chars_read
= strlen(argv
[i
]);
1304 DecodeUTF8(Buffer
[0], argv
[i
], chars_read
);
1311 printf_err("%s\n", _("Parameter missing!"));
1315 if (compose_type
== COMPOSE_EMS
&& EMS16Bit
) {
1316 for (i
=0;i
<SMSInfo
.EntriesNum
;i
++) {
1317 switch (SMSInfo
.Entries
[i
].ID
) {
1318 case SMS_ConcatenatedTextLong
:
1319 SMSInfo
.Entries
[i
].ID
= SMS_ConcatenatedTextLong16bit
;
1327 if (compose_type
== COMPOSE_TEXT
) {
1329 if (isatty(fileno(stdin
))) {
1330 printf(_("Enter the message text and press %s:\n"),
1338 chars_read
= fread(InputBuffer
, 1, SEND_SAVE_SMS_BUFFER_SIZE
/2, stdin
);
1339 /* Zero terminate string */
1340 InputBuffer
[chars_read
] = 0;
1341 /* Trim \n at the end of string */
1342 if (InputBuffer
[chars_read
- 1] == '\n') {
1344 InputBuffer
[chars_read
] = 0;
1346 /* Warn on no input */
1347 if (chars_read
== 0) {
1348 printf_warn("%s\n", _("No chars read, assuming it is okay!"));
1351 EncodeUnicode(Buffer
[0],InputBuffer
,chars_read
);
1354 chars_read
= UnicodeLength(Buffer
[0]);
1356 if (chars_read
!= 0) {
1357 /* Trim \n at the end of string */
1358 if (Buffer
[0][chars_read
*2-1] == '\n' && Buffer
[0][chars_read
*2-2] == 0)
1360 Buffer
[0][chars_read
*2-1] = 0;
1365 if (*type
== SMS_Display
|| *type
== SMS_SMSD
) {
1366 if (compose_type
== COMPOSE_OPERATOR
) {
1367 if (bitmap
[0]->Bitmap
[0].Type
==GSM_OperatorLogo
&& strcmp(bitmap
[0]->Bitmap
[0].NetworkCode
,"000 00")==0) {
1368 printf("%s\n", _("No network code"));
1374 printf_err("%s\n", _("You have to set network code!"));
1377 if (compose_type
== COMPOSE_OPERATOR
) {
1378 if (bitmap
[0]->Bitmap
[0].Type
== GSM_OperatorLogo
&&
1379 strcmp(bitmap
[0]->Bitmap
[0].NetworkCode
,"000 00")==0) {
1380 error
= GSM_GetNetworkInfo(sm
,&NetInfo
);
1381 if (error
!= ERR_NONE
) goto end_compose
;
1382 strcpy(bitmap
[0]->Bitmap
[0].NetworkCode
,NetInfo
.NetworkCode
);
1383 if (*type
== SMS_Save
) {
1384 EncodeUnicode(RemoteNumber
, "OpLogo",6);
1385 EncodeUnicode(RemoteNumber
+6*2,bitmap
[0]->Bitmap
[0].NetworkCode
,3);
1386 EncodeUnicode(RemoteNumber
+6*2+3*2,bitmap
[0]->Bitmap
[0].NetworkCode
+4,2);
1387 if (UnicodeLength(GSM_GetNetworkName(bitmap
[0]->Bitmap
[0].NetworkCode
))<GSM_MAX_SMS_NAME_LENGTH
-7) {
1388 EncodeUnicode(Name
,"OpLogo ",7);
1389 CopyUnicodeString(Name
+7*2,GSM_GetNetworkName(bitmap
[0]->Bitmap
[0].NetworkCode
));
1391 CopyUnicodeString(Name
,RemoteNumber
);
1398 error
= GSM_EncodeMultiPartSMS(GSM_GetGlobalDebug(), &SMSInfo
, sms
);
1399 if (error
!= ERR_NONE
) goto end_compose
;
1401 for (i
=0;i
<SMSInfo
.EntriesNum
;i
++) {
1402 switch (SMSInfo
.Entries
[i
].ID
) {
1403 case SMS_NokiaRingtone
:
1404 case SMS_NokiaRingtoneLong
:
1405 case SMS_NokiaProfileLong
:
1406 case SMS_EMSSound10
:
1407 case SMS_EMSSound12
:
1408 case SMS_EMSSonyEricssonSound
:
1409 case SMS_EMSSound10Long
:
1410 case SMS_EMSSound12Long
:
1411 case SMS_EMSSonyEricssonSoundLong
:
1412 if (SMSInfo
.Entries
[i
].RingtoneNotes
!=SMSInfo
.Entries
[i
].Ringtone
->NoteTone
.NrCommands
) {
1413 printf_warn(_("Ringtone too long. %i percent part cut\n"),
1414 (SMSInfo
.Entries
[i
].Ringtone
->NoteTone
.NrCommands
-SMSInfo
.Entries
[i
].RingtoneNotes
)*100/SMSInfo
.Entries
[i
].Ringtone
->NoteTone
.NrCommands
);
1422 /* Check whether we did not reach user limit of messages */
1423 if (MaxSMS
!= -1 && sms
->Number
> MaxSMS
) {
1424 printf_err(_("There are %i SMS messages packed and the limit is %i. Exiting\n"),sms
->Number
,MaxSMS
);
1425 error
= ERR_MOREMEMORY
;
1430 * Are we supposed to read SMSC from phone?
1434 printf_err("%s\n", _("Use -smscnumber option to give SMSC number"));
1438 PhoneSMSC
.Location
= SMSCSet
;
1439 error
= GSM_GetSMSC(sm
, &PhoneSMSC
);
1440 if (error
!= ERR_NONE
) goto end_compose
;
1442 CopyUnicodeString(SMSC
, PhoneSMSC
.Number
);
1447 * Fill up all messages with flags.
1449 for (i
=0;i
<sms
->Number
;i
++) {
1450 CopyUnicodeString(sms
->SMS
[i
].Number
, RemoteNumber
);
1451 CopyUnicodeString(sms
->SMS
[i
].Name
, Name
);
1453 sms
->SMS
[i
].Location
= 0;
1454 sms
->SMS
[i
].Folder
= Folder
;
1455 sms
->SMS
[i
].State
= State
;
1457 sms
->SMS
[i
].ReplyViaSameSMSC
= ReplyViaSameSMSC
;
1459 sms
->SMS
[i
].SMSC
.Location
= SMSCSet
;
1460 CopyUnicodeString(sms
->SMS
[i
].SMSC
.Number
, SMSC
);
1462 if (DeliveryReport
) {
1463 sms
->SMS
[i
].PDU
= SMS_Status_Report
;
1465 sms
->SMS
[i
].PDU
= SMS_Submit
;
1468 if (Validity
.Format
!= 0) {
1469 sms
->SMS
[i
].SMSC
.Validity
= Validity
;
1476 for (i
= 0; i
< GSM_MAX_MULTI_SMS
; i
++) {
1481 #ifdef GSM_ENABLE_BACKUP
1482 GSM_FreeBackup(&Backup
);
1488 /* How should editor hadle tabs in this file? Add editor commands here.
1489 * vim: noexpandtab sw=8 ts=8 sts=8: