Translation update done using Pootle.
[gammu.git] / tests / sms-nokia-18.c
blob4abcb866ef4b39b38288f59102605a0437de2972
1 /* Test for decoding SMS on Nokia 6510 driver */
3 #include <gammu.h>
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <string.h>
8 #include "common.h"
10 #include "../libgammu/protocol/protocol.h" /* Needed for GSM_Protocol_Message */
11 #include "../libgammu/gsmstate.h" /* Needed for state machine internals */
13 #include "../helper/message-display.h"
15 unsigned char data[] = {
16 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x9E, 0x00, 0x00, 0x02, 0xE2, 0x00, 0x00, 0x00, 0x00,
17 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2B,
22 0x00, 0x34, 0x00, 0x35, 0x00, 0x36, 0x00, 0x31, 0x00, 0x32, 0x00, 0x36, 0x00, 0x39, 0x00, 0x36,
23 0x00, 0x38, 0x00, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27 0x51, 0x00, 0x14, 0x91, 0x53, 0x58, 0x76, 0x98, 0x21, 0x43, 0x65, 0x87, 0x19, 0x32, 0x00, 0x00,
28 0xFF, 0xA0, 0x05, 0x00, 0x03, 0x00, 0x02, 0x01, 0x82, 0x68, 0x16, 0x68, 0x5E, 0x97, 0xD3, 0x5D,
29 0xA0, 0xE3, 0x9B, 0x4C, 0x07, 0x91, 0xEB, 0xA0, 0xB2, 0x1C, 0xB4, 0x7E, 0xB7, 0xDB, 0x65, 0x3A,
30 0x08, 0xAD, 0x2E, 0xB7, 0x41, 0xEF, 0x33, 0x68, 0x1D, 0x76, 0x83, 0xE6, 0xEC, 0x30, 0x1C, 0x5E,
31 0x06, 0x85, 0xCD, 0x20, 0x77, 0x9D, 0x05, 0x9A, 0x3F, 0x5C, 0x20, 0xA4, 0x3D, 0x3D, 0x07, 0x91,
32 0xEB, 0x20, 0x7B, 0x58, 0x0E, 0x42, 0x97, 0xE5, 0xA0, 0x75, 0xDD, 0xED, 0x2E, 0x83, 0xC8, 0x75,
33 0x90, 0xFA, 0x0D, 0x9A, 0x3F, 0x40, 0xF0, 0xF0, 0x7C, 0x5E, 0x76, 0x93, 0xCB, 0x20, 0x77, 0x7D,
34 0x3E, 0x2F, 0x83, 0xDA, 0xE9, 0x33, 0x28, 0x0D, 0x42, 0xBF, 0xED, 0x65, 0xB2, 0xB8, 0xEE, 0x26,
35 0x97, 0xDD, 0x2E, 0x50, 0xB3, 0xEC, 0x06, 0xB1, 0xD3, 0xE7, 0x32, 0x28, 0x0D, 0x22, 0x87, 0xCF,
36 0xA0, 0xB2, 0x1C, 0x44, 0xAE, 0x83, 0xD8, 0x6F, 0x3B, 0x3B, 0x7D, 0xA6, 0x83, 0xEA, 0x01, 0x01,
37 0x91, 0x01, 0x00, 0x01, 0x01, 0x03, 0x01, 0x4C, 0x00, 0x41, 0x00, 0x68, 0x00, 0x2C, 0x00, 0x20,
38 0x00, 0x73, 0x00, 0x75, 0x00, 0x72, 0x00, 0x74, 0x00, 0x2E, 0x00, 0x20, 0x00, 0x47, 0x00, 0x6F,
39 0x00, 0x64, 0x00, 0x74, 0x00, 0x20, 0x00, 0x64, 0x00, 0x75, 0x00, 0x20, 0x00, 0x65, 0x00, 0x72,
40 0x00, 0x20, 0x00, 0x6B, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x74, 0x00, 0x20,
41 0x00, 0x68, 0x00, 0x6A, 0x00, 0x65, 0x00, 0x6D, 0x00, 0x20, 0x00, 0x6F, 0x00, 0x67, 0x00, 0x20,
42 0x00, 0x6B, 0x00, 0x61, 0x00, 0x6E, 0x00, 0x20, 0x00, 0x73, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x70,
43 0x00, 0x70, 0x00, 0x65, 0x00, 0x20, 0x00, 0x61, 0x00, 0x66, 0x00, 0x20, 0x00, 0x6E, 0x00, 0x75,
44 0x00, 0x2C, 0x00, 0x20, 0x00, 0x73, 0x00, 0xE5, 0x00, 0x2E, 0x00, 0x20, 0x00, 0x48, 0x00, 0x76,
45 0x00, 0x69, 0x00, 0x73, 0x00, 0x20, 0x00, 0x64, 0x00, 0x75, 0x00, 0x20, 0x00, 0x76, 0x00, 0x61,
46 0x00, 0x72, 0x00, 0x20, 0x00, 0x68, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x6B, 0x00, 0x75,
47 0x00, 0x6E, 0x00, 0x6E, 0x00, 0x65, 0x00, 0x20, 0x00, 0x64, 0x00, 0x75, 0x00, 0x20, 0x00, 0x6A,
48 0x00, 0x6F, 0x00, 0x20, 0x00, 0x73, 0x00, 0xE5, 0x00, 0x20, 0x00, 0x70, 0x00, 0x61, 0x00, 0x73,
49 0x00, 0x73, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x65, 0x00, 0x20, 0x00, 0x6E, 0x00, 0x75,
50 0x00, 0x73, 0x00, 0x73, 0x00, 0x65, 0x00, 0x20, 0x00, 0x6D, 0x00, 0x69, 0x00, 0x67, 0x00, 0x20,
51 0x00, 0x69, 0x00, 0x20, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x76, 0x00, 0x65, 0x00, 0x64, 0x00, 0x62,
52 0x00, 0x75, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x2E, 0x00, 0x20, 0x00, 0x4D,
53 0x00, 0x65, 0x00, 0x6E, 0x00, 0x20, 0x00, 0x6C, 0x00, 0x69, 0x00, 0x67, 0x00, 0x65, 0x00, 0x20,
54 0x00, 0x69, 0x00, 0x20, 0x00, 0x64, 0x00, 0x61, 0x00, 0x67, 0x00, 0x20, 0x00, 0x65, 0x00, 0x72,
55 0x00, 0x20, 0x00, 0x64, 0x00, 0x75, 0x00, 0x20, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x76, 0x00, 0x6C,
56 0x00, 0x69, 0x00, 0x67, 0x00, 0x74, 0x00, 0x20, 0x00, 0x75, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x73,
57 0x00, 0x6B, 0x00, 0x79, 0x00, 0x6C, 0x00, 0x64, 0x00, 0x74, 0x00, 0x2E, 0x00, 0x20, 0x00, 0x3B,
58 0x00, 0x29, 0x00, 0x00, 0x04, 0x00, 0x18, 0x00, 0x2B, 0x00, 0x34, 0x00, 0x35, 0x00, 0x36, 0x00,
59 0x31, 0x00, 0x32, 0x00, 0x36, 0x00, 0x39, 0x00, 0x36, 0x00, 0x38, 0x00, 0x39, 0x00, 0x00, 0x0C,
60 0x00, 0x02, 0x37, 0x00, 0x07, 0x00, 0x01, 0x0E, 0x05, 0x00, 0x01, 0x02, 0x06, 0x00, 0x04, 0x00,
61 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x0B, 0x00, 0x01, 0x00, 0x09, 0x00, 0x04, 0x00, 0x00,
62 0x00, 0x00, 0x07, 0x00, 0x01, 0x0E, 0x05, 0x00, 0x01, 0x07, 0x12, 0x00, 0x04, 0x00, 0x00, 0x00,
63 0x00, 0x24, 0x00, 0x01, 0x00, 0x00,
66 const char text[] = "Ah, surt. Godt du er kommet hjem og kan slappe af nu, så. Hvis du var her kunne du jo så passende nusse mig i hovedbunden. Men lige i dag er du lovligt u";
67 char decoded_text[200];
69 /* This is not part of API! */
70 extern GSM_Error N6510_DecodeFilesystemSMS(GSM_StateMachine * s, GSM_MultiSMSMessage * sms, GSM_File * FFF, int location);
72 int main(int argc UNUSED, char **argv UNUSED)
74 GSM_Debug_Info *debug_info;
75 GSM_StateMachine *s;
76 GSM_File file;
77 GSM_Error error;
78 GSM_MultiSMSMessage sms;
80 /* Init locales for proper output */
81 GSM_InitLocales(NULL);
83 debug_info = GSM_GetGlobalDebug();
84 GSM_SetDebugFileDescriptor(stderr, FALSE, debug_info);
85 GSM_SetDebugLevel("textall", debug_info);
87 /* Allocates state machine */
88 s = GSM_AllocStateMachine();
89 test_result(s != NULL);
91 debug_info = GSM_GetDebug(s);
92 GSM_SetDebugGlobal(TRUE, debug_info);
94 /* Init file */
95 file.Buffer = malloc(sizeof(data));
96 memcpy(file.Buffer, data, sizeof(data));
97 file.Used = sizeof(data);
98 file.ID_FullName[0] = 0;
99 file.ID_FullName[1] = 0;
100 GSM_GetCurrentDateTime(&(file.Modified));
102 /* Parse it */
103 error = N6510_DecodeFilesystemSMS(s, &sms, &file, 0);
105 /* Display message */
106 DisplayMultiSMSInfo(&sms, FALSE, TRUE, NULL, NULL);
107 DisplayMultiSMSInfo(&sms, TRUE, TRUE, NULL, NULL);
109 /* Free state machine */
110 GSM_FreeStateMachine(s);
112 /* Check expected text */
113 /* We do not compare full text due to locales problem */
114 EncodeUTF8(decoded_text, sms.SMS[0].Text);
115 test_result(strcmp(text, decoded_text) == 0);
117 gammu_test_result(error, "N6510_DecodeFilesystemSMS");
119 return 0;
122 /* Editor configuration
123 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: