Translation update done using Pootle.
[gammu.git] / tests / sms-nokia-05.c
blob4aeb3daa8b5c496dc2f7cbbc0ad87ff5a8645351
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, 0x9F, 0x00, 0x00, 0x02, 0x51, 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, 0x33, 0x00, 0x39, 0x00, 0x33, 0x00, 0x33, 0x00, 0x33, 0x00, 0x33, 0x00, 0x33, 0x00, 0x33,
23 0x00, 0x31, 0x00, 0x30, 0x00, 0x35, 0x00, 0x38, 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 0x44, 0x0C, 0x91, 0x93, 0x23, 0x68, 0x28, 0x01, 0x85, 0x00, 0x08, 0x80, 0x90, 0x03, 0x32, 0x21,
28 0x10, 0x80, 0x8C, 0x05, 0x00, 0x03, 0xE3, 0x02, 0x01, 0x00, 0x50, 0x00, 0x65, 0x00, 0x7A, 0x00,
29 0x7A, 0x00, 0x6F, 0x00, 0x20, 0x00, 0x64, 0x00, 0x69, 0x00, 0x20, 0x00, 0x7A, 0x00, 0x75, 0x00,
30 0x6C, 0x00, 0xFA, 0x00, 0x20, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x20, 0x00, 0x6B, 0x00, 0x65, 0x00,
31 0x2E, 0x00, 0x2E, 0x00, 0x6E, 0x00, 0x6E, 0x00, 0x20, 0x00, 0x73, 0x00, 0x69, 0x00, 0x20, 0x00,
32 0x72, 0x00, 0x69, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x65, 0x00,
33 0x20, 0x00, 0x70, 0x00, 0x69, 0x00, 0xF9, 0x00, 0x20, 0x00, 0x61, 0x00, 0x69, 0x00, 0x20, 0x00,
34 0x6D, 0x00, 0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x61, 0x00, 0x67, 0x00, 0x69, 0x00, 0x3F, 0x00,
35 0x21, 0x00, 0x20, 0x00, 0x43, 0x00, 0x61, 0x00, 0x67, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00,
36 0x2E, 0x00, 0x20, 0x00, 0x42, 0x00, 0x75, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x20, 0x01,
37 0x00, 0xFF, 0x01, 0x00, 0x01, 0x00, 0x02, 0x00, 0x0E, 0x2B, 0x33, 0x39, 0x33, 0x32, 0x30, 0x35,
38 0x39, 0x35, 0x36, 0x31, 0x31, 0x31, 0x00, 0x03, 0x00, 0xA6, 0x00, 0x50, 0x00, 0x65, 0x00, 0x7A,
39 0x00, 0x7A, 0x00, 0x6F, 0x00, 0x20, 0x00, 0x64, 0x00, 0x69, 0x00, 0x20, 0x00, 0x7A, 0x00, 0x75,
40 0x00, 0x6C, 0x00, 0xFA, 0x00, 0x20, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x20, 0x00, 0x6B, 0x00, 0x65,
41 0x00, 0x2E, 0x00, 0x2E, 0x00, 0x6E, 0x00, 0x6E, 0x00, 0x20, 0x00, 0x73, 0x00, 0x69, 0x00, 0x20,
42 0x00, 0x72, 0x00, 0x69, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x65,
43 0x00, 0x20, 0x00, 0x70, 0x00, 0x69, 0x00, 0xF9, 0x00, 0x20, 0x00, 0x61, 0x00, 0x69, 0x00, 0x20,
44 0x00, 0x6D, 0x00, 0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x61, 0x00, 0x67, 0x00, 0x69, 0x00, 0x3F,
45 0x00, 0x21, 0x00, 0x20, 0x00, 0x43, 0x00, 0x61, 0x00, 0x67, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69,
46 0x00, 0x2E, 0x00, 0x20, 0x00, 0x42, 0x00, 0x75, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x20,
47 0x00, 0x6E, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x74, 0x00, 0x65, 0x00, 0x21, 0x00, 0x3A, 0x00, 0x2D,
48 0x00, 0x50, 0x00, 0x20, 0x00, 0x65, 0x00, 0x68, 0x00, 0x20, 0x00, 0x65, 0x00, 0x68, 0x00, 0x00,
49 0x04, 0x00, 0x1C, 0x00, 0x2B, 0x00, 0x33, 0x00, 0x39, 0x00, 0x33, 0x00, 0x32, 0x00, 0x38, 0x00,
50 0x36, 0x00, 0x38, 0x00, 0x32, 0x00, 0x31, 0x00, 0x30, 0x00, 0x35, 0x00, 0x38, 0x00, 0x00, 0x0C,
51 0x00, 0x01, 0x00, 0x07, 0x00, 0x01, 0x00, 0x05, 0x00, 0x01, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00,
52 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x0B, 0x00, 0x01, 0x00, 0x09, 0x00, 0x04, 0x00, 0x00, 0x00,
53 0x00, 0x00, 0x0B, 0x00, 0x01, 0x00, 0x09, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00
56 unsigned char message[] = {
57 0x00, 0x50, 0x00, 0x65, 0x00, 0x7a, 0x00, 0x7a, 0x00, 0x6f, 0x00, 0x20, 0x00, 0x64, 0x00, 0x69,
58 0x00, 0x20, 0x00, 0x7a, 0x00, 0x75, 0x00, 0x6c, 0x00, 0xfa, 0x00, 0x20, 0x00, 0x6d, 0x00, 0x61,
59 0x00, 0x20, 0x00, 0x6b, 0x00, 0x65, 0x00, 0x2e, 0x00, 0x2e, 0x00, 0x6e, 0x00, 0x6e, 0x00, 0x20,
60 0x00, 0x73, 0x00, 0x69, 0x00, 0x20, 0x00, 0x72, 0x00, 0x69, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6f,
61 0x00, 0x6e, 0x00, 0x64, 0x00, 0x65, 0x00, 0x20, 0x00, 0x70, 0x00, 0x69, 0x00, 0xf9, 0x00, 0x20,
62 0x00, 0x61, 0x00, 0x69, 0x00, 0x20, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x61,
63 0x00, 0x67, 0x00, 0x69, 0x00, 0x3f, 0x00, 0x21, 0x00, 0x20, 0x00, 0x43, 0x00, 0x61, 0x00, 0x67,
64 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x2e, 0x00, 0x20, 0x00, 0x42, 0x00, 0x75, 0x00, 0x6f,
65 0x00, 0x6e, 0x00, 0x61, 0x00, 0x20, 0x00, 0x00
68 /* This is not part of API! */
69 extern GSM_Error N6510_DecodeFilesystemSMS(GSM_StateMachine * s, GSM_MultiSMSMessage * sms, GSM_File * FFF, int location);
71 int main(int argc UNUSED, char **argv UNUSED)
73 GSM_Debug_Info *debug_info;
74 GSM_StateMachine *s;
75 GSM_File file;
76 GSM_Error error;
77 GSM_MultiSMSMessage sms;
78 size_t len;
80 debug_info = GSM_GetGlobalDebug();
81 GSM_SetDebugFileDescriptor(stderr, FALSE, debug_info);
82 GSM_SetDebugLevel("textall", debug_info);
84 /* Allocates state machine */
85 s = GSM_AllocStateMachine();
86 test_result(s != NULL);
88 debug_info = GSM_GetDebug(s);
89 GSM_SetDebugGlobal(TRUE, debug_info);
90 GSM_SetDebugFileDescriptor(stderr, FALSE, debug_info);
91 GSM_SetDebugLevel("textall", debug_info);
93 /* Init file */
94 file.Buffer = malloc(sizeof(data));
95 memcpy(file.Buffer, data, sizeof(data));
96 file.Used = sizeof(data);
97 file.ID_FullName[0] = 0;
98 file.ID_FullName[1] = 0;
99 GSM_GetCurrentDateTime(&(file.Modified));
101 /* Parse it */
102 error = N6510_DecodeFilesystemSMS(s, &sms, &file, 0);
104 /* Check expected text */
105 len = UnicodeLength(sms.SMS[0].Text);
106 if (len > (sizeof(message) / 2) - 1)
107 len = (sizeof(message) / 2) - 1;
108 test_result(mywstrncmp(sms.SMS[0].Text, message, len) == TRUE);
110 /* Display message */
111 DisplayMultiSMSInfo(&sms, FALSE, TRUE, NULL, NULL);
112 DisplayMultiSMSInfo(&sms, TRUE, TRUE, NULL, NULL);
114 /* Free state machine */
115 GSM_FreeStateMachine(s);
117 gammu_test_result(error, "N6510_DecodeFilesystemSMS");
119 return 0;
122 /* Editor configuration
123 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: