im_encryption_engine.c 5.56 KB
Newer Older
1
/*
2
im_encryption_engine.c
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Copyright (C) 2016  Belledonne Communications SARL

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

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.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

20
#include "linphone/core.h"
21
#include "private.h"
22

23 24
#include "c-wrapper/c-wrapper.h"

25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneImEncryptionEngineCbs);

BELLE_SIP_INSTANCIATE_VPTR(LinphoneImEncryptionEngineCbs, belle_sip_object_t,
	NULL, // destroy
	NULL, // clone
	NULL, // marshal
	TRUE
);

static void linphone_im_encryption_engine_destroy(LinphoneImEncryptionEngine *imee) {
	if (imee->callbacks) linphone_im_encryption_engine_cbs_unref(imee->callbacks);
}

BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneImEncryptionEngine);

BELLE_SIP_INSTANCIATE_VPTR(LinphoneImEncryptionEngine, belle_sip_object_t,
	(belle_sip_object_destroy_t)linphone_im_encryption_engine_destroy,
	NULL, // clone
	NULL, // marshal
	TRUE
);
46 47

LinphoneImEncryptionEngineCbs *linphone_im_encryption_engine_cbs_new(void) {
48 49
	LinphoneImEncryptionEngineCbs *cbs = belle_sip_object_new(LinphoneImEncryptionEngineCbs);
	belle_sip_object_ref(cbs);
50 51 52
	return cbs;
}

53 54 55 56 57 58 59
LinphoneImEncryptionEngineCbs * linphone_im_encryption_engine_cbs_ref(LinphoneImEncryptionEngineCbs *cbs) {
	belle_sip_object_ref(cbs);
	return cbs;
}

void linphone_im_encryption_engine_cbs_unref(LinphoneImEncryptionEngineCbs *cbs) {
	belle_sip_object_unref(cbs);
60 61 62 63 64 65 66 67 68 69
}

void *linphone_im_encryption_engine_cbs_get_user_data(const LinphoneImEncryptionEngineCbs *cbs) {
	return cbs->user_data;
}

void linphone_im_encryption_engine_cbs_set_user_data(LinphoneImEncryptionEngineCbs *cbs, void *data) {
	cbs->user_data = data;
}

70
LinphoneImEncryptionEngine *linphone_im_encryption_engine_new(void) {
Ghislain MARY's avatar
Ghislain MARY committed
71 72
	LinphoneImEncryptionEngine *imee = belle_sip_object_new(LinphoneImEncryptionEngine);
	belle_sip_object_ref(imee);
73
	imee->lc = NULL;
74 75 76 77
	imee->callbacks = linphone_im_encryption_engine_cbs_new();
	return imee;
}

78 79 80 81 82 83 84
LinphoneImEncryptionEngine * linphone_im_encryption_engine_ref(LinphoneImEncryptionEngine *imee) {
	belle_sip_object_ref(imee);
	return imee;
}

void linphone_im_encryption_engine_unref(LinphoneImEncryptionEngine *imee) {
	belle_sip_object_unref(imee);
85 86
}

87 88 89 90 91 92 93 94
void *linphone_im_encryption_engine_get_user_data(const LinphoneImEncryptionEngine *imee) {
	return imee->user_data;
}

void linphone_im_encryption_engine_set_user_data(LinphoneImEncryptionEngine *imee, void *data) {
	imee->user_data = data;
}

95 96 97 98
LinphoneCore * linphone_im_encryption_engine_get_core(LinphoneImEncryptionEngine *imee) {
	return imee->lc;
}

99 100 101 102
LinphoneImEncryptionEngineCbs* linphone_im_encryption_engine_get_callbacks(const LinphoneImEncryptionEngine *imee) {
	return imee->callbacks;
}

103
LinphoneImEncryptionEngineCbsIncomingMessageCb linphone_im_encryption_engine_cbs_get_process_incoming_message(LinphoneImEncryptionEngineCbs *cbs) {
104 105 106
	return cbs->process_incoming_message;
}

107
void linphone_im_encryption_engine_cbs_set_process_incoming_message(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineCbsIncomingMessageCb cb) {
108
	cbs->process_incoming_message = cb;
109 110
}

111
LinphoneImEncryptionEngineCbsOutgoingMessageCb linphone_im_encryption_engine_cbs_get_process_outgoing_message(LinphoneImEncryptionEngineCbs *cbs) {
112 113 114
	return cbs->process_outgoing_message;
}

115
void linphone_im_encryption_engine_cbs_set_process_outgoing_message(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineCbsOutgoingMessageCb cb) {
116
	cbs->process_outgoing_message = cb;
117 118
}

119
LinphoneImEncryptionEngineCbsDownloadingFileCb linphone_im_encryption_engine_cbs_get_process_downloading_file(LinphoneImEncryptionEngineCbs *cbs) {
120
	return cbs->process_downloading_file;
121 122
}

123
void linphone_im_encryption_engine_cbs_set_process_downloading_file(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineCbsDownloadingFileCb cb) {
124
	cbs->process_downloading_file = cb;
125 126
}

127
LinphoneImEncryptionEngineCbsUploadingFileCb linphone_im_encryption_engine_cbs_get_process_uploading_file(LinphoneImEncryptionEngineCbs *cbs) {
128 129 130
	return cbs->process_uploading_file;
}

131
void linphone_im_encryption_engine_cbs_set_process_uploading_file(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineCbsUploadingFileCb cb) {
132 133 134
	cbs->process_uploading_file = cb;
}

135
LinphoneImEncryptionEngineCbsIsEncryptionEnabledForFileTransferCb linphone_im_encryption_engine_cbs_get_is_encryption_enabled_for_file_transfer(LinphoneImEncryptionEngineCbs *cbs) {
136 137 138
	return cbs->is_encryption_enabled_for_file_transfer;
}

139
void linphone_im_encryption_engine_cbs_set_is_encryption_enabled_for_file_transfer(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineCbsIsEncryptionEnabledForFileTransferCb cb) {
140 141 142
	cbs->is_encryption_enabled_for_file_transfer = cb;
}

143
LinphoneImEncryptionEngineCbsGenerateFileTransferKeyCb linphone_im_encryption_engine_cbs_get_generate_file_transfer_key(LinphoneImEncryptionEngineCbs *cbs) {
144 145 146
	return cbs->generate_file_transfer_key;
}

147
void linphone_im_encryption_engine_cbs_set_generate_file_transfer_key(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineCbsGenerateFileTransferKeyCb cb) {
148
		cbs->generate_file_transfer_key = cb;
149
}