im_encryption_engine.c 5.58 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 "linphone/im_encryption_engine.h"
22
#include "private.h"
23

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
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
);
45 46

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

52 53 54 55 56 57 58
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);
59 60 61 62 63 64 65 66 67 68
}

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;
}

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

77 78 79 80 81 82 83
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);
84 85
}

86 87 88 89 90 91 92 93
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;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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