/
test_handler.c
113 lines (101 loc) · 2.57 KB
/
test_handler.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* Copyright (C) 2013-2014 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include "test_handler.h"
/* Logging */
#define MMS_LOG_MODULE_NAME mms_handler_log
#include "mms_lib_log.h"
MMS_LOG_MODULE_DEFINE("mms-handler-test");
/* Class definition */
typedef MMSHandlerClass MMSHandlerTestClass;
typedef struct mms_handler_test {
MMSHandler handler;
mms_handler_message_id_cb message_id_cb;
void* message_id_param;
} MMSHandlerTest;
G_DEFINE_TYPE(MMSHandlerTest, mms_handler_test, MMS_TYPE_HANDLER);
#define MMS_TYPE_HANDLER_TEST (mms_handler_test_get_type())
#define MMS_HANDLER_TEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
MMS_TYPE_HANDLER_TEST, MMSHandlerTest))
static
char*
mms_handler_test_message_notify(
MMSHandler* handler,
const char* imsi,
const char* from,
const char* subject,
time_t expiry,
GBytes* push)
{
MMSHandlerTest* test = MMS_HANDLER_TEST(handler);
return test->message_id_cb ?
test->message_id_cb(handler, test->message_id_param) :
NULL;
}
static
gboolean
mms_handler_test_message_received(
MMSHandler* handler,
MMSMessage* msg)
{
MMS_DEBUG("Message %s received", msg->id);
return TRUE;
}
static
gboolean
mms_handler_test_message_receive_state_changed(
MMSHandler* handler,
const char* id,
MMS_RECEIVE_STATE state)
{
MMS_DEBUG("Message %s state %d", id, state);
return TRUE;
}
static
void
mms_handler_test_class_init(
MMSHandlerTestClass* klass)
{
klass->fn_message_notify = mms_handler_test_message_notify;
klass->fn_message_received = mms_handler_test_message_received;
klass->fn_message_receive_state_changed =
mms_handler_test_message_receive_state_changed;
}
static
void
mms_handler_test_init(
MMSHandlerTest* test)
{
}
MMSHandler*
mms_handler_test_new()
{
return g_object_new(MMS_TYPE_HANDLER_TEST, NULL);
}
void
mms_handler_set_message_id_cb(
MMSHandler* handler,
mms_handler_message_id_cb cb,
void* param)
{
MMSHandlerTest* test = MMS_HANDLER_TEST(handler);
test->message_id_cb = cb;
test->message_id_param = param;
}
/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/