20 #include "../../gsmstate.h" 21 #include "../../protocol/s60/s60-ids.h" 22 #include "../../gsmcomon.h" 23 #include "../../misc/coding/coding.h" 24 #include "../../gsmphones.h" 25 #include "../../gsmstate.h" 26 #include "../../service/gsmmisc.h" 27 #include "../../misc/locales.h" 31 #include "../../../helper/string.h" 33 #if defined(GSM_ENABLE_S60) 41 GSM_File PythonFile, PIPSFile, AppletFile;
42 gboolean install_python, install_pips;
53 smprintf(s,
"Failed to find applet, trying another filename!\n");
56 smprintf(s,
"Failed to load applet data!\n");
63 install_python =
FALSE;
70 install_python =
TRUE;
72 smprintf(s,
"Could not find Python for S60 to install, skipping!\n");
73 install_python =
FALSE;
82 smprintf(s,
"Could not find PIPS to install, skipping!\n");
104 strcpy(cfg->
Model,
"obexnone");
124 if (install_python) {
189 smprintf(s,
"Unsupported protocol version\n");
208 unsigned char * pos = msg->
Buffer - 1;
224 smprintf(s,
"Too many reply parts!\n");
317 pos = strchr(msg->
Buffer,
'.');
341 error = S60_GetInfo(s);
360 char *mcc, *mnc, *lac, *cellid;
366 error = S60_SplitValues(msg, s);
378 if (mcc == NULL || mnc == NULL || lac == NULL || cellid == NULL) {
404 error = S60_GetInfo(s);
419 error = S60_SplitValues(msg, s);
429 }
else if (strcmp(Priv->
MessageParts[0],
"model") == 0) {
438 pos = strchr(pos + 1,
' ');
460 smprintf(s,
"Unknown model, but it should still work\n");
465 }
else if (strcmp(Priv->
MessageParts[0],
"s60_version") == 0) {
470 }
else if (Signal != NULL && strcmp(Priv->
MessageParts[0],
"signal_dbm") == 0) {
472 }
else if (Signal != NULL && strcmp(Priv->
MessageParts[0],
"signal_bars") == 0) {
474 if (signal_value != 0) {
479 }
else if (BatteryCharge != NULL && strcmp(Priv->
MessageParts[0],
"battery") == 0) {
510 if ((*pos) + 3 >= (*size)) {
511 *locations = (
int *)realloc(*locations, ((*size) + 20) *
sizeof(int));
512 if (*locations == NULL) {
517 (*locations)[(*pos)] = location;
518 (*locations)[(*pos) + 1] = 0;
536 error = S60_SplitValues(msg, s);
560 error = S60_SplitValues(msg, s);
604 error = S60_SplitValues(msg, s);
614 if (strcmp(Priv->
MessageParts[1],
"appointment") != 0 &&
658 error = S60_SplitValues(msg, s);
694 sprintf(buffer,
"%d", Entry->
Location);
713 error = S60_GetMemoryLocations(s);
726 return S60_GetMemory(s, Entry);
733 char *pos, *type, *location, *value;
737 error = S60_SplitValues(msg, s);
751 if (pos == NULL || type == NULL || location == NULL || value == NULL) {
756 if ((strcmp(location,
"work") == 0)) {
758 }
else if ((strcmp(location,
"home") == 0)) {
765 if(strcmp(type,
"city") == 0) {
768 }
else if(strcmp(type,
"company_name") == 0) {
771 }
else if(strcmp(type,
"country") == 0) {
774 }
else if(strcmp(type,
"date") == 0) {
779 }
else if(strcmp(type,
"dtmf_string") == 0) {
782 }
else if(strcmp(type,
"email_address") == 0) {
785 }
else if(strcmp(type,
"po_box") == 0) {
787 }
else if(strcmp(type,
"extended_address") == 0) {
789 }
else if(strcmp(type,
"fax_number") == 0) {
792 }
else if(strcmp(type,
"first_name") == 0) {
795 }
else if(strcmp(type,
"second_name") == 0) {
798 }
else if(strcmp(type,
"job_title") == 0) {
801 }
else if(strcmp(type,
"last_name") == 0) {
804 }
else if(strcmp(type,
"voip") == 0) {
807 }
else if(strcmp(type,
"sip_id") == 0) {
810 }
else if(strcmp(type,
"push_to_talk") == 0) {
813 }
else if(strcmp(type,
"mobile_number") == 0) {
816 }
else if(strcmp(type,
"note") == 0) {
819 }
else if(strcmp(type,
"pager_number") == 0) {
822 }
else if(strcmp(type,
"phone_number") == 0) {
825 }
else if(strcmp(type,
"postal_address") == 0) {
828 }
else if(strcmp(type,
"postal_code") == 0) {
831 }
else if(strcmp(type,
"state") == 0) {
834 }
else if(strcmp(type,
"street_address") == 0) {
837 }
else if(strcmp(type,
"url") == 0) {
840 }
else if(strcmp(type,
"video_number") == 0) {
843 }
else if(strcmp(type,
"wvid") == 0) {
846 }
else if(strcmp(type,
"thumbnail_image") == 0) {
848 }
else if(strcmp(type,
"suffix") == 0) {
851 }
else if(strcmp(type,
"prefix") == 0) {
854 }
else if(strcmp(type,
"share_view") == 0) {
858 smprintf(s,
"WARNING: Ignoring unknown field type: %s\n", type);
863 if (strlen(value) == 0) {
872 smprintf(s,
"ERROR: reached limit of phonebook entries\n");
888 sprintf(buffer,
"%d", Entry->
Location);
897 const char *type, *location =
"none";
920 type =
"company_name";
932 type =
"dtmf_string";
936 type =
"email_address";
948 type =
"second_name";
968 type =
"push_to_talk";
972 type =
"mobile_number";
984 type =
"phone_number";
988 type =
"postal_address";
992 type =
"postal_code";
1000 type =
"street_address";
1008 type =
"video_number";
1024 type =
"share_view";
1036 snprintf(buffer,
sizeof(buffer),
"%d%c%s%c%s%c%s%c",
1058 error = S60_GetMemory(s, &oldentry);
1100 return S60_SetMemory(s, Entry);
1114 char *type, *content, *location, *start, *end, *modified, *replication, *alarm_time, *repeat, *repeat_rule, *repeat_start, *repeat_end, *interval;
1118 error = S60_SplitValues(msg, s);
1124 for (i = 0; i < 16; i++) {
1126 smprintf(s,
"Not enough parts in reply!\n");
1152 if (strcmp(type,
"appointment") == 0) {
1154 }
else if (strcmp(type,
"event") == 0) {
1156 }
else if (strcmp(type,
"anniversary") == 0) {
1158 }
else if (strcmp(type,
"reminder") == 0) {
1164 if (strlen(content) > 0) {
1170 if (strlen(location) > 0) {
1176 if (strlen(start) > 0) {
1182 if (strlen(end) > 0) {
1188 if (strlen(modified) > 0) {
1194 if (strlen(replication) > 0) {
1196 if (strcmp(replication,
"open") == 0) {
1204 if (strlen(alarm_time) > 0) {
1210 if ((strlen(repeat) > 0) && (strlen(repeat_rule) > 0)) {
1211 if (strcmp(repeat,
"daily") == 0 ) {
1212 }
else if (strcmp(repeat,
"weekly") == 0 ) {
1216 }
else if (strcmp(repeat,
"monthly_by_dates") == 0 ) {
1220 }
else if (strcmp(repeat,
"monthly_by_days") == 0 ) {
1221 }
else if (strcmp(repeat,
"yearly_by_date") == 0 ) {
1222 }
else if (strcmp(repeat,
"yearly_by_day") == 0 ) {
1227 smprintf(s,
"Unknown value for repeating: %s\n", repeat);
1232 if (strlen(repeat_start) > 0) {
1238 if (strlen(repeat_end) > 0) {
1244 if (strlen(interval) > 0) {
1263 sprintf(buffer,
"%d", Entry->
Location);
1310 switch (Entry->
Type) {
1312 type =
"appointment";
1318 type =
"anniversary";
1324 type =
"appointment";
1331 S60_SetCalendarError(s, Entry);
1333 i = S60_FindCalendarField(s, Entry,
CAL_TEXT);
1363 strcat(buffer,
"private");
1365 strcat(buffer,
"open");
1380 strcat(buffer,
"2");
1402 sprintf(buffer + strlen(buffer),
"%d", Entry->
Entries[i].
Number);
1426 error = S60_GetCalendarLocations(s);
1439 return S60_GetCalendar(s, Entry);
1447 sprintf(buffer,
"%d", Entry->
Location);
1458 char *type, *content, *location, *start, *end, *modified, *replication, *alarm_time, *priority, *crossedout, *crossedout_time;
1462 error = S60_SplitValues(msg, s);
1468 for (i = 0; i < 18; i++) {
1470 smprintf(s,
"Not enough parts in reply!\n");
1493 if (strcmp(type,
"todo") == 0) {
1499 if (strlen(content) > 0) {
1505 if (strlen(location) > 0) {
1511 if (strlen(start) > 0) {
1517 if (strlen(end) > 0) {
1523 if (strlen(modified) > 0) {
1529 if (strlen(replication) > 0) {
1531 if (strcmp(replication,
"open") == 0) {
1539 if (strlen(alarm_time) > 0) {
1545 if (strlen(priority) > 0) {
1549 if (strlen(crossedout) > 0) {
1555 if (strlen(crossedout_time) > 0) {
1571 sprintf(buffer,
"%d", Entry->
Location);
1586 error = S60_GetToDoLocations(s);
1599 return S60_GetToDo(s, Entry);
1607 sprintf(buffer,
"%d", Entry->
Location);
1644 i = S60_FindToDoField(s, Entry,
TODO_TEXT);
1674 strcat(buffer,
"private");
1676 strcat(buffer,
"open");
1691 sprintf(buffer + strlen(buffer),
"%d", Entry->
Priority);
1761 error = S60_SplitValues(msg, s);
1810 sprintf(buffer,
"%d", sms->
Location);
1821 error = S60_SplitValues(msg, s);
1831 for (i = 0; i < 6; i++) {
1833 smprintf(s,
"Not enough parts in reply!\n");
1878 error = S60_SplitValues(msg, s);
1911 error = S60_GetSMSLocations(s);
1924 return S60_GetSMS(s, sms);
1943 strcat(buffer,
"UCS2");
1947 strcat(buffer,
"7bit");
1950 strcat(buffer,
"8bit");
2050 {NULL,
"", 0x00, 0x00,
ID_None }
2084 S60_GetBatteryCharge,
2085 S60_GetSignalQuality,
2090 S60_GetMemoryStatus,
2158 S60_GetCalendarStatus,
2160 S60_GetNextCalendar,
#define NUM_CALENDAR_ENTRY_ADD
#define NUM_SEPERATOR_STR
GSM_Config * CurrentConfig
#define NUM_CALENDAR_REPLY_ENTRIES_END
#define NUM_CALENDAR_REPLY_ENTRIES_START
void GSM_SetDefaultReceivedSMSData(GSM_SMSMessage *SMS)
gboolean UseGlobalDebugFile
size_t ContactLocationsSize
unsigned char Text[(GSM_MAX_SMS_LENGTH+1) *2]
#define NUM_MESSAGE_SEND_REPLY_STATUS
#define NUM_SCREENSHOT_REPLY
#define NUM_CONTACTS_CHANGE_REMOVEFIELD
GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum)
unsigned char Number[(GSM_MAX_NUMBER_LENGTH+1) *2]
#define NUM_CALENDAR_ENTRY_CHANGE
#define NUM_MESSAGE_SEND_REPLY_OK
GSM_BinaryPicture * Picture
GSM_StateMachine * GSM_AllocStateMachine(void)
#define NUM_MESSAGE_REPLY_END
#define NUM_CALENDAR_REPLY_COUNT
#define NUM_CALENDAR_ENTRY_ADD_REPLY
GSM_ToDo_Priority Priority
#define NUM_MESSAGE_REPLY_ONE
void GSM_SetConfigNum(GSM_StateMachine *s, int sections)
GSM_MemoryType MemoryType
#define GSM_PHONEBOOK_TEXT_LENGTH
#define NUM_CONTACTS_CHANGE_ADDFIELD
#define NUM_MESSAGE_REQUEST_LIST
#define NUM_CALENDAR_REQUEST_ENTRIES_ALL
GSM_CalendarNoteType Type
size_t CalendarLocationsPos
unsigned char NetworkName[15 *2]
#define NUM_MESSAGE_REQUEST_COUNT
#define GSM_PHONEBOOK_ENTRIES
GSM_SMSMemoryStatus * SMSStatus
#define GSM_MAX_NUMBER_LENGTH
SendSMSStatusCallback SendSMSStatus
GSM_Error GSM_DispatchMessage(GSM_StateMachine *s)
#define NUM_CALENDAR_REPLY_ENTRY
#define NUM_MESSAGE_REQUEST_ONE
GSM_BinaryPicture_Types Type
#define NUM_CONTACTS_REPLY_HASH_SINGLE_END
GSM_NetworkInfo * NetworkInfo
#define NUM_CONTACTS_REPLY_HASH_SINGLE_START
GSM_OneSMSFolder Folder[GSM_MAX_SMS_FOLDERS]
void * SendSMSStatusUserData
size_t UnicodeLength(const unsigned char *str)
#define NUM_CONTACTS_REPLY_CONTACT_LINE
GSM_ToDoStatus * ToDoStatus
#define NUM_CALENDAR_ENTRY_DELETE
GSM_Error GSM_SetDebugFileDescriptor(FILE *fd, gboolean closable, GSM_Debug_Info *privdi)
GSM_CalendarStatus * CalStatus
char IMEI[GSM_MAX_IMEI_LENGTH+1]
char Version[GSM_MAX_VERSION_LENGTH+1]
char Manufacturer[GSM_MAX_MANUFACTURER_LENGTH+1]
GSM_PhoneModel * ModelInfo
#define NUM_CONTACTS_REPLY_CONTACT_END
#define GSM_MAX_SMS_LENGTH
#define NUM_CALENDAR_REQUEST_ENTRY
GSM_SignalQuality * SignalQuality
#define NUM_SYSINFO_REPLY_LINE
gboolean ReadVCALDateTime(const char *Buffer, GSM_DateTime *dt)
#define GSM_MAX_SMS_NAME_LENGTH
void GSM_ClearBatteryCharge(GSM_BatteryCharge *bat)
unsigned char DefaultNumber[(GSM_MAX_NUMBER_LENGTH+1) *2]
unsigned char Text[(GSM_PHONEBOOK_TEXT_LENGTH+1) *2]
#define NUM_SYSINFO_REPLY_START
GSM_ValidityPeriodFormat Format
#define NUM_CONTACTS_REPLY_COUNT
GSM_CalendarNoteType Type
GSM_PhoneModel * GetModelData(GSM_StateMachine *s, const char *model, const char *number, const char *irdamodel)
void EncodeUnicode(unsigned char *dest, const char *src, size_t len)
unsigned char Name[(GSM_MAX_SMS_NAME_LENGTH+1) *2]
struct GSM_Phone_Data::@2 Priv
#define NUM_MESSAGE_DELETE
GSM_SubToDoEntry Entries[GSM_TODO_ENTRIES]
size_t ContactLocationsPos
#define NUM_CONTACTS_REQUEST_COUNT
char * EncodeSpecialChars(char *dest, const char *buffer)
GSM_Error GSM_WaitFor(GSM_StateMachine *s, unsigned const char *buffer, size_t length, int type, int timeout, GSM_Phone_RequestID request)
#define NUM_CALENDAR_REQUEST_COUNT
#define NUM_CONTACTS_REPLY_CONTACT_START
#define NUM_MESSAGE_SEND_REPLY_FAILURE
#define NUM_CONTACTS_REQUEST_CONTACT
#define NUM_SYSINFO_REPLY_END
#define NUM_MESSAGE_REPLY_LIST
#define NUM_LOCATION_REPLY
GSM_Error PHONE_FindDataFile(GSM_StateMachine *s, GSM_File *File, const char *ExtraPath, const char *filename)
void DecodeUTF8(unsigned char *dest, const char *src, size_t len)
unsigned char Name[(GSM_MAX_SMS_FOLDER_NAME_LEN+1) *2]
#define NUM_LOCATION_REQUEST
#define NUM_CALENDAR_ENTRY_CHANGE_REPLY_TIME
#define NUM_CONTACTS_REQUEST_HASH_SINGLE
GSM_SMSMessage SMS[GSM_MAX_MULTI_SMS]
GSM_CalendarType EntryType
GSM_Error GSM_TerminateConnection(GSM_StateMachine *s)
GSM_BatteryCharge * BatteryCharge
#define NUM_SYSINFO_REQUEST
GSM_Config * GSM_GetConfig(GSM_StateMachine *s, int num)
GSM_NetworkInfo_State State
unsigned char Number[(GSM_MAX_NUMBER_LENGTH+1) *2]
#define NUM_HELLO_REQUEST
GSM_SubCalendarEntry Entries[GSM_CALENDAR_ENTRIES]
GSM_MemoryType MemoryType
#define NUM_CONTACTS_REPLY_HASH_SINGLE_LINE
gboolean GSM_SetDebugLevel(const char *info, GSM_Debug_Info *privdi)
#define NUM_CONTACTS_REPLY_CONTACT_NOT_FOUND
#define NUM_CONTACTS_DELETE
GSM_EntryLocation Location
void GSM_CreateFirmwareNumber(GSM_StateMachine *s)
#define NUM_MESSAGE_REPLY_COUNT
GSM_NetworkInfo_State PacketState
#define NUM_CALENDAR_REPLY_ENTRY_NOT_FOUND
gboolean EncodeUTF8(char *dest, const unsigned char *src)
GSM_Error PHONE_UploadFile(GSM_StateMachine *s, GSM_File *File)
void GSM_DateTimeToTimestamp(GSM_DateTime *Date, char *str)
GSM_MemoryStatus * MemoryStatus
GSM_SMSMessage * SaveSMSMessage
#define NUM_LOCATION_REPLY_NA
void GSM_DateTimeFromTimestamp(GSM_DateTime *Date, const char *str)
unsigned char Text[(GSM_MAX_TODO_TEXT_LENGTH+1) *2]
#define NUM_MESSAGE_SEND_REQUEST
void GSM_FreeStateMachine(GSM_StateMachine *s)
GSM_ValidityPeriod Relative
char Model[GSM_MAX_MODEL_LENGTH+1]
size_t CalendarLocationsSize
#define NUM_CONTACTS_ADD_REPLY_ID
unsigned char Text[(GSM_MAX_CALENDAR_TEXT_LENGTH+1) *2]
#define NUM_MESSAGE_SEND_REPLY_RETRY
int smprintf(GSM_StateMachine *s, const char *format,...)
int DecodeBASE64(const char *Input, unsigned char *Output, const size_t Length)
GSM_Debug_Info * GSM_GetDebug(GSM_StateMachine *s)
unsigned char Name[(GSM_MAX_SMSC_NAME_LENGTH+1) *2]
GSM_SubMemoryEntry Entries[GSM_PHONEBOOK_ENTRIES]