1 /*
2 im_encryption_engine.c
3 Copyright (C) 2016 Belledonne Communications SARL
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 #include "linphone/core.h"
21 #include "linphone/im_encryption_engine.h"
22 #include "private.h"
23
24 BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneImEncryptionEngineCbs);
25
26 BELLE_SIP_INSTANCIATE_VPTR(LinphoneImEncryptionEngineCbs, belle_sip_object_t,
27 NULL, // destroy
28 NULL, // clone
29 NULL, // marshal
30 TRUE
31 );
32
linphone_im_encryption_engine_destroy(LinphoneImEncryptionEngine * imee)33 static void linphone_im_encryption_engine_destroy(LinphoneImEncryptionEngine *imee) {
34 if (imee->callbacks) linphone_im_encryption_engine_cbs_unref(imee->callbacks);
35 }
36
37 BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneImEncryptionEngine);
38
39 BELLE_SIP_INSTANCIATE_VPTR(LinphoneImEncryptionEngine, belle_sip_object_t,
40 (belle_sip_object_destroy_t)linphone_im_encryption_engine_destroy,
41 NULL, // clone
42 NULL, // marshal
43 TRUE
44 );
45
linphone_im_encryption_engine_cbs_new(void)46 LinphoneImEncryptionEngineCbs *linphone_im_encryption_engine_cbs_new(void) {
47 LinphoneImEncryptionEngineCbs *cbs = belle_sip_object_new(LinphoneImEncryptionEngineCbs);
48 belle_sip_object_ref(cbs);
49 return cbs;
50 }
51
linphone_im_encryption_engine_cbs_ref(LinphoneImEncryptionEngineCbs * cbs)52 LinphoneImEncryptionEngineCbs * linphone_im_encryption_engine_cbs_ref(LinphoneImEncryptionEngineCbs *cbs) {
53 belle_sip_object_ref(cbs);
54 return cbs;
55 }
56
linphone_im_encryption_engine_cbs_unref(LinphoneImEncryptionEngineCbs * cbs)57 void linphone_im_encryption_engine_cbs_unref(LinphoneImEncryptionEngineCbs *cbs) {
58 belle_sip_object_unref(cbs);
59 }
60
linphone_im_encryption_engine_cbs_get_user_data(const LinphoneImEncryptionEngineCbs * cbs)61 void *linphone_im_encryption_engine_cbs_get_user_data(const LinphoneImEncryptionEngineCbs *cbs) {
62 return cbs->user_data;
63 }
64
linphone_im_encryption_engine_cbs_set_user_data(LinphoneImEncryptionEngineCbs * cbs,void * data)65 void linphone_im_encryption_engine_cbs_set_user_data(LinphoneImEncryptionEngineCbs *cbs, void *data) {
66 cbs->user_data = data;
67 }
68
linphone_im_encryption_engine_new(void)69 LinphoneImEncryptionEngine *linphone_im_encryption_engine_new(void) {
70 LinphoneImEncryptionEngine *imee = belle_sip_object_new(LinphoneImEncryptionEngine);
71 belle_sip_object_ref(imee);
72 imee->lc = NULL;
73 imee->callbacks = linphone_im_encryption_engine_cbs_new();
74 return imee;
75 }
76
linphone_im_encryption_engine_ref(LinphoneImEncryptionEngine * imee)77 LinphoneImEncryptionEngine * linphone_im_encryption_engine_ref(LinphoneImEncryptionEngine *imee) {
78 belle_sip_object_ref(imee);
79 return imee;
80 }
81
linphone_im_encryption_engine_unref(LinphoneImEncryptionEngine * imee)82 void linphone_im_encryption_engine_unref(LinphoneImEncryptionEngine *imee) {
83 belle_sip_object_unref(imee);
84 }
85
linphone_im_encryption_engine_get_user_data(const LinphoneImEncryptionEngine * imee)86 void *linphone_im_encryption_engine_get_user_data(const LinphoneImEncryptionEngine *imee) {
87 return imee->user_data;
88 }
89
linphone_im_encryption_engine_set_user_data(LinphoneImEncryptionEngine * imee,void * data)90 void linphone_im_encryption_engine_set_user_data(LinphoneImEncryptionEngine *imee, void *data) {
91 imee->user_data = data;
92 }
93
linphone_im_encryption_engine_get_core(LinphoneImEncryptionEngine * imee)94 LinphoneCore * linphone_im_encryption_engine_get_core(LinphoneImEncryptionEngine *imee) {
95 return imee->lc;
96 }
97
linphone_im_encryption_engine_get_callbacks(const LinphoneImEncryptionEngine * imee)98 LinphoneImEncryptionEngineCbs* linphone_im_encryption_engine_get_callbacks(const LinphoneImEncryptionEngine *imee) {
99 return imee->callbacks;
100 }
101
linphone_im_encryption_engine_cbs_get_process_incoming_message(LinphoneImEncryptionEngineCbs * cbs)102 LinphoneImEncryptionEngineCbsIncomingMessageCb linphone_im_encryption_engine_cbs_get_process_incoming_message(LinphoneImEncryptionEngineCbs *cbs) {
103 return cbs->process_incoming_message;
104 }
105
linphone_im_encryption_engine_cbs_set_process_incoming_message(LinphoneImEncryptionEngineCbs * cbs,LinphoneImEncryptionEngineCbsIncomingMessageCb cb)106 void linphone_im_encryption_engine_cbs_set_process_incoming_message(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineCbsIncomingMessageCb cb) {
107 cbs->process_incoming_message = cb;
108 }
109
linphone_im_encryption_engine_cbs_get_process_outgoing_message(LinphoneImEncryptionEngineCbs * cbs)110 LinphoneImEncryptionEngineCbsOutgoingMessageCb linphone_im_encryption_engine_cbs_get_process_outgoing_message(LinphoneImEncryptionEngineCbs *cbs) {
111 return cbs->process_outgoing_message;
112 }
113
linphone_im_encryption_engine_cbs_set_process_outgoing_message(LinphoneImEncryptionEngineCbs * cbs,LinphoneImEncryptionEngineCbsOutgoingMessageCb cb)114 void linphone_im_encryption_engine_cbs_set_process_outgoing_message(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineCbsOutgoingMessageCb cb) {
115 cbs->process_outgoing_message = cb;
116 }
117
linphone_im_encryption_engine_cbs_get_process_downloading_file(LinphoneImEncryptionEngineCbs * cbs)118 LinphoneImEncryptionEngineCbsDownloadingFileCb linphone_im_encryption_engine_cbs_get_process_downloading_file(LinphoneImEncryptionEngineCbs *cbs) {
119 return cbs->process_downlading_file;
120 }
121
linphone_im_encryption_engine_cbs_set_process_downloading_file(LinphoneImEncryptionEngineCbs * cbs,LinphoneImEncryptionEngineCbsDownloadingFileCb cb)122 void linphone_im_encryption_engine_cbs_set_process_downloading_file(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineCbsDownloadingFileCb cb) {
123 cbs->process_downlading_file = cb;
124 }
125
linphone_im_encryption_engine_cbs_get_process_uploading_file(LinphoneImEncryptionEngineCbs * cbs)126 LinphoneImEncryptionEngineCbsUploadingFileCb linphone_im_encryption_engine_cbs_get_process_uploading_file(LinphoneImEncryptionEngineCbs *cbs) {
127 return cbs->process_uploading_file;
128 }
129
linphone_im_encryption_engine_cbs_set_process_uploading_file(LinphoneImEncryptionEngineCbs * cbs,LinphoneImEncryptionEngineCbsUploadingFileCb cb)130 void linphone_im_encryption_engine_cbs_set_process_uploading_file(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineCbsUploadingFileCb cb) {
131 cbs->process_uploading_file = cb;
132 }
133
linphone_im_encryption_engine_cbs_get_is_encryption_enabled_for_file_transfer(LinphoneImEncryptionEngineCbs * cbs)134 LinphoneImEncryptionEngineCbsIsEncryptionEnabledForFileTransferCb linphone_im_encryption_engine_cbs_get_is_encryption_enabled_for_file_transfer(LinphoneImEncryptionEngineCbs *cbs) {
135 return cbs->is_encryption_enabled_for_file_transfer;
136 }
137
linphone_im_encryption_engine_cbs_set_is_encryption_enabled_for_file_transfer(LinphoneImEncryptionEngineCbs * cbs,LinphoneImEncryptionEngineCbsIsEncryptionEnabledForFileTransferCb cb)138 void linphone_im_encryption_engine_cbs_set_is_encryption_enabled_for_file_transfer(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineCbsIsEncryptionEnabledForFileTransferCb cb) {
139 cbs->is_encryption_enabled_for_file_transfer = cb;
140 }
141
linphone_im_encryption_engine_cbs_get_generate_file_transfer_key(LinphoneImEncryptionEngineCbs * cbs)142 LinphoneImEncryptionEngineCbsGenerateFileTransferKeyCb linphone_im_encryption_engine_cbs_get_generate_file_transfer_key(LinphoneImEncryptionEngineCbs *cbs) {
143 return cbs->generate_file_transfer_key;
144 }
145
linphone_im_encryption_engine_cbs_set_generate_file_transfer_key(LinphoneImEncryptionEngineCbs * cbs,LinphoneImEncryptionEngineCbsGenerateFileTransferKeyCb cb)146 void linphone_im_encryption_engine_cbs_set_generate_file_transfer_key(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineCbsGenerateFileTransferKeyCb cb) {
147 cbs->generate_file_transfer_key = cb;
148 }
149