diff options
author | mannol <eniz_vukovic@hotmail.com> | 2014-01-25 01:32:33 +0100 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2014-01-25 01:32:33 +0100 |
commit | 65d320e31daa4709bb48b7f2a52c269dde0927e9 (patch) | |
tree | 45081a96be413d850a837d6afcee19fcfbfe7aca /toxmsi/toxmsi.h | |
parent | 51d8c41390be853a13693476802a834daf8d156a (diff) |
Done with encryption and core adaptations.
Diffstat (limited to 'toxmsi/toxmsi.h')
-rw-r--r-- | toxmsi/toxmsi.h | 145 |
1 files changed, 0 insertions, 145 deletions
diff --git a/toxmsi/toxmsi.h b/toxmsi/toxmsi.h deleted file mode 100644 index d8985c64..00000000 --- a/toxmsi/toxmsi.h +++ /dev/null | |||
@@ -1,145 +0,0 @@ | |||
1 | /* msi_initiation.h | ||
2 | * | ||
3 | * Has function for session initiation along with session description. | ||
4 | * It follows the Tox API ( http://wiki.tox.im/index.php/Messaging_Protocol ). !Red! | ||
5 | * | ||
6 | * | ||
7 | * Copyright (C) 2013 Tox project All Rights Reserved. | ||
8 | * | ||
9 | * This file is part of Tox. | ||
10 | * | ||
11 | * Tox is free software: you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation, either version 3 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * Tox is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | |||
27 | #ifndef _MSI_IMPL_H_ | ||
28 | #define _MSI_IMPL_H_ | ||
29 | |||
30 | #include <inttypes.h> | ||
31 | #include "tox.h" | ||
32 | #include <pthread.h> | ||
33 | |||
34 | #define MCBTYPE void | ||
35 | #define MCBARGS void* _arg | ||
36 | #define MCALLBACK MCBTYPE(*callback)(void* _arg) | ||
37 | |||
38 | #define MSI_PACKET 69 | ||
39 | |||
40 | #define CT_AUDIO_HEADER_VALUE "AUDIO" | ||
41 | #define CT_VIDEO_HEADER_VALUE "VIDEO" | ||
42 | |||
43 | /* define size for call_id */ | ||
44 | #define _CALL_ID_LEN 12 | ||
45 | |||
46 | typedef enum { | ||
47 | type_audio = 1, | ||
48 | type_video, | ||
49 | } call_type; | ||
50 | |||
51 | typedef enum { | ||
52 | call_inviting, /* when sending call invite */ | ||
53 | call_starting, /* when getting call invite */ | ||
54 | call_active, | ||
55 | call_hold | ||
56 | |||
57 | } call_state; | ||
58 | |||
59 | typedef int crypto_key; | ||
60 | |||
61 | typedef struct msi_call_s { /* Call info structure */ | ||
62 | call_state _state; | ||
63 | call_type _type_local; | ||
64 | call_type* _type_peer; /* Support for conference starts with this */ | ||
65 | uint8_t _id[_CALL_ID_LEN]; /* Random value identifying the call */ | ||
66 | crypto_key _key; /* What is the type again? */ | ||
67 | uint16_t _participants; /* Number of participants */ | ||
68 | uint32_t _timeoutst; /* Time of the timeout for some action to end; 0 if infinite */ | ||
69 | int _outgoing_timer_id; /* Timer id */ | ||
70 | |||
71 | } msi_call_t; | ||
72 | |||
73 | typedef struct msi_session_s { | ||
74 | pthread_mutex_t _mutex; | ||
75 | |||
76 | crypto_key _key; /* The key */ | ||
77 | |||
78 | /* Call information/handler. ( Maybe only information? ) */ | ||
79 | msi_call_t* _call; | ||
80 | |||
81 | /* Storage for message receiving */ | ||
82 | struct msi_msg_s* _oldest_msg; | ||
83 | struct msi_msg_s* _last_msg; /* tail */ | ||
84 | |||
85 | /*int _friend_id;*/ | ||
86 | tox_IP_Port _friend_id; | ||
87 | |||
88 | int _last_error_id; /* Determine the last error */ | ||
89 | const uint8_t* _last_error_str; | ||
90 | |||
91 | const uint8_t* _user_agent; | ||
92 | |||
93 | void* _agent_handler; /* Pointer to an object that is handling msi */ | ||
94 | void* _core_handler; /* Pointer to networking core or to anything that | ||
95 | * should handle interaction with core/networking | ||
96 | */ | ||
97 | void* _event_handler; /* Pointer to an object which handles the events */ | ||
98 | |||
99 | uint32_t _frequ; | ||
100 | uint32_t _call_timeout; /* Time of the timeout for some action to end; 0 if infinite */ | ||
101 | } msi_session_t; | ||
102 | |||
103 | |||
104 | |||
105 | msi_session_t* msi_init_session ( void* _core_handler, const uint8_t* _user_agent ); | ||
106 | int msi_terminate_session ( msi_session_t* _session ); | ||
107 | |||
108 | pthread_t msi_start_main_loop ( msi_session_t* _session, uint32_t _frequms ); | ||
109 | |||
110 | /* Registering callbacks */ | ||
111 | |||
112 | /*void msi_register_callback_send(int (*callback) ( int, uint8_t*, uint32_t ) );*/ | ||
113 | void msi_register_callback_send ( int ( *callback ) ( void* _core_handler, tox_IP_Port, uint8_t*, uint32_t ) ); | ||
114 | |||
115 | /* Callbacks that handle the states */ | ||
116 | void msi_register_callback_call_started ( MCALLBACK ); | ||
117 | void msi_register_callback_call_canceled ( MCALLBACK ); | ||
118 | void msi_register_callback_call_rejected ( MCALLBACK ); | ||
119 | void msi_register_callback_call_ended ( MCALLBACK ); | ||
120 | |||
121 | void msi_register_callback_recv_invite ( MCALLBACK ); | ||
122 | void msi_register_callback_recv_ringing ( MCALLBACK ); | ||
123 | void msi_register_callback_recv_starting ( MCALLBACK ); | ||
124 | void msi_register_callback_recv_ending ( MCALLBACK ); | ||
125 | void msi_register_callback_recv_error ( MCALLBACK ); | ||
126 | |||
127 | void msi_register_callback_requ_timeout ( MCALLBACK ); | ||
128 | /* -------- */ | ||
129 | |||
130 | |||
131 | /* Function handling receiving from core */ | ||
132 | /*static int msi_handlepacket ( tox_IP_Port ip_port, uint8_t* _data, uint16_t _lenght ); */ | ||
133 | |||
134 | /* functions describing the usage of msi */ | ||
135 | int msi_invite ( msi_session_t* _session, call_type _call_type, uint32_t _timeoutms ); | ||
136 | int msi_hangup ( msi_session_t* _session ); | ||
137 | |||
138 | int msi_answer ( msi_session_t* _session, call_type _call_type ); | ||
139 | int msi_cancel ( msi_session_t* _session ); | ||
140 | int msi_reject ( msi_session_t* _session ); | ||
141 | |||
142 | int msi_send_msg ( msi_session_t* _session, struct msi_msg_s* _msg ); | ||
143 | void msi_store_msg ( msi_session_t* _session, struct msi_msg_s* _msg ); | ||
144 | |||
145 | #endif /* _MSI_IMPL_H_ */ | ||