Translation update done using Pootle.
[gammu.git] / tests / sms-nokia-14.c
blobfbbe16af432bbe83e3c6d148cda7f2c5d988c0dd
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 */
12 #include "../libgammu/gsmphones.h" /* Phone data */
14 #include "../helper/message-display.h"
16 unsigned char data[] = {
17 0x01, 0x5D, 0x00, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20 const char text[] = "";
21 char decoded_text[200];
23 /* This is not part of API! */
24 extern GSM_Error N6510_ReplyGetSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine * s);
26 int main(int argc UNUSED, char **argv UNUSED)
28 GSM_Debug_Info *debug_info;
29 GSM_StateMachine *s;
30 GSM_Protocol_Message msg;
31 GSM_Error error;
32 GSM_MultiSMSMessage sms;
34 /* Init locales for proper output */
35 GSM_InitLocales(NULL);
37 debug_info = GSM_GetGlobalDebug();
38 GSM_SetDebugFileDescriptor(stderr, FALSE, debug_info);
39 GSM_SetDebugLevel("textall", debug_info);
41 /* Allocates state machine */
42 s = GSM_AllocStateMachine();
43 test_result(s != NULL);
45 debug_info = GSM_GetDebug(s);
46 GSM_SetDebugGlobal(TRUE, debug_info);
47 GSM_SetDebugFileDescriptor(stderr, FALSE, debug_info);
48 GSM_SetDebugLevel("textall", debug_info);
50 s->Phone.Data.ModelInfo = GetModelData(NULL, NULL, "unknown", NULL);
52 /* Init message */
53 msg.Type = 0x14;
54 msg.Length = sizeof(data);
55 msg.Buffer = data;
57 s->Phone.Data.GetSMSMessage = &sms;
59 /* Parse it */
60 error = N6510_ReplyGetSMSMessage(&msg, s);
62 /* Display message */
63 DisplayMultiSMSInfo(&sms, FALSE, TRUE, NULL, NULL);
64 DisplayMultiSMSInfo(&sms, TRUE, TRUE, NULL, NULL);
66 /* Free state machine */
67 GSM_FreeStateMachine(s);
69 /* Check expected text */
70 /* We do not compare full text due to locales problem */
71 EncodeUTF8(decoded_text, sms.SMS[0].Text);
72 test_result(strcmp(text, decoded_text) == 0);
74 gammu_test_result(error, "N6510_ReplyGetSMSMessage");
76 return 0;
79 /* Editor configuration
80 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: