diff options
author | Maxim Biro <nurupo.contributions@gmail.com> | 2013-09-07 16:05:16 -0400 |
---|---|---|
committer | Maxim Biro <nurupo.contributions@gmail.com> | 2013-09-07 16:05:16 -0400 |
commit | f5bf85240045b46a101814caeecc0471b77f06f1 (patch) | |
tree | fe9a46245c2fd711f514e3bc40687063a1f49e39 | |
parent | eeec99723c3d9f86a904760a36e51bfcbc252717 (diff) |
Removed friendstatus from client API
-rw-r--r-- | toxcore/Messenger.c | 20 | ||||
-rw-r--r-- | toxcore/Messenger.h | 19 | ||||
-rw-r--r-- | toxcore/tox.c | 25 | ||||
-rw-r--r-- | toxcore/tox.h | 28 |
4 files changed, 55 insertions, 37 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index ff2c31aa..07893e02 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -275,18 +275,20 @@ int m_delfriend(Messenger *m, int friendnumber) | |||
275 | return 0; | 275 | return 0; |
276 | } | 276 | } |
277 | 277 | ||
278 | /* return FRIEND_ONLINE if friend is online. | 278 | int m_get_friend_connectionstatus(Messenger *m, int friendnumber) |
279 | * return FRIEND_CONFIRMED if friend is confirmed. | 279 | { |
280 | * return FRIEND_REQUESTED if the friend request was sent. | 280 | if (friend_not_valid(m, friendnumber)) |
281 | * return FRIEND_ADDED if the friend was added. | 281 | return -1; |
282 | * return NOFRIEND if there is no friend with that number. | 282 | |
283 | */ | 283 | return m->friendlist[friendnumber].status == FRIEND_ONLINE; |
284 | int m_friendstatus(Messenger *m, int friendnumber) | 284 | } |
285 | |||
286 | int m_friend_exists(Messenger *m, int friendnumber) | ||
285 | { | 287 | { |
286 | if (friend_not_valid(m, friendnumber)) | 288 | if (friend_not_valid(m, friendnumber)) |
287 | return NOFRIEND; | 289 | return 0; |
288 | 290 | ||
289 | return m->friendlist[friendnumber].status; | 291 | return m->friendlist[friendnumber].status > NOFRIEND; |
290 | } | 292 | } |
291 | 293 | ||
292 | /* Send a text chat message to an online friend. | 294 | /* Send a text chat message to an online friend. |
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index a4c6114b..c512245c 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h | |||
@@ -202,13 +202,20 @@ int getclient_id(Messenger *m, int friend_id, uint8_t *client_id); | |||
202 | /* Remove a friend. */ | 202 | /* Remove a friend. */ |
203 | int m_delfriend(Messenger *m, int friendnumber); | 203 | int m_delfriend(Messenger *m, int friendnumber); |
204 | 204 | ||
205 | /* return 4 if friend is online. | 205 | /* Checks friend's connecting status. |
206 | * return 3 if friend is confirmed. | 206 | * |
207 | * return 2 if the friend request was sent. | 207 | * return 1 if friend is connected to us (Online). |
208 | * return 1 if the friend was added. | 208 | * return 0 if friend is not connected to us (Offline). |
209 | * return 0 if there is no friend with that number. | 209 | * return -1 on failure. |
210 | */ | ||
211 | int m_get_friend_connectionstatus(Messenger *m, int friendnumber); | ||
212 | |||
213 | /* Checks if there exists a friend with given friendnumber. | ||
214 | * | ||
215 | * return 1 if friend exists. | ||
216 | * return 0 if friend doesn't exist. | ||
210 | */ | 217 | */ |
211 | int m_friendstatus(Messenger *m, int friendnumber); | 218 | int m_friend_exists(Messenger *m, int friendnumber); |
212 | 219 | ||
213 | /* Send a text chat message to an online friend. | 220 | /* Send a text chat message to an online friend. |
214 | * | 221 | * |
diff --git a/toxcore/tox.c b/toxcore/tox.c index 0af07ede..83b19e9b 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -99,16 +99,27 @@ int tox_delfriend(void *tox, int friendnumber) | |||
99 | return m_delfriend(m, friendnumber); | 99 | return m_delfriend(m, friendnumber); |
100 | } | 100 | } |
101 | 101 | ||
102 | /* return 4 if friend is online. | 102 | /* Checks friend's connecting status. |
103 | * return 3 if friend is confirmed. | 103 | * |
104 | * return 2 if the friend request was sent. | 104 | * return 1 if friend is connected to us (Online). |
105 | * return 1 if the friend was added. | 105 | * return 0 if friend is not connected to us (Offline). |
106 | * return 0 if there is no friend with that number. | 106 | * return -1 on failure. |
107 | */ | ||
108 | int tox_get_friend_connectionstatus(void *tox, int friendnumber) | ||
109 | { | ||
110 | Messenger *m = tox; | ||
111 | return m_get_friend_connectionstatus(m, friendnumber); | ||
112 | } | ||
113 | |||
114 | /* Checks if there exists a friend with given friendnumber. | ||
115 | * | ||
116 | * return 1 if friend exists. | ||
117 | * return 0 if friend doesn't exist. | ||
107 | */ | 118 | */ |
108 | int tox_friendstatus(void *tox, int friendnumber) | 119 | int tox_friend_exists(void *tox, int friendnumber) |
109 | { | 120 | { |
110 | Messenger *m = tox; | 121 | Messenger *m = tox; |
111 | return m_friendstatus(m, friendnumber); | 122 | return m_friend_exists(m, friendnumber); |
112 | } | 123 | } |
113 | 124 | ||
114 | /* Send a text chat message to an online friend. | 125 | /* Send a text chat message to an online friend. |
diff --git a/toxcore/tox.h b/toxcore/tox.h index 718f817b..811e798b 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h | |||
@@ -50,15 +50,6 @@ typedef struct { | |||
50 | uint16_t padding; | 50 | uint16_t padding; |
51 | } tox_IP_Port; | 51 | } tox_IP_Port; |
52 | 52 | ||
53 | /* Status definitions. */ | ||
54 | enum { | ||
55 | TOX_NOFRIEND, | ||
56 | TOX_FRIEND_ADDED, | ||
57 | TOX_FRIEND_REQUESTED, | ||
58 | TOX_FRIEND_CONFIRMED, | ||
59 | TOX_FRIEND_ONLINE, | ||
60 | }; | ||
61 | |||
62 | /* Errors for m_addfriend | 53 | /* Errors for m_addfriend |
63 | * FAERR - Friend Add Error | 54 | * FAERR - Friend Add Error |
64 | */ | 55 | */ |
@@ -130,13 +121,20 @@ int tox_getclient_id(Tox *tox, int friend_id, uint8_t *client_id); | |||
130 | /* Remove a friend. */ | 121 | /* Remove a friend. */ |
131 | int tox_delfriend(Tox *tox, int friendnumber); | 122 | int tox_delfriend(Tox *tox, int friendnumber); |
132 | 123 | ||
133 | /* return TOX_FRIEND_ONLINE if friend is online. | 124 | /* Checks friend's connecting status. |
134 | * return TOX_FRIEND_CONFIRMED if friend is confirmed. | 125 | * |
135 | * return TOX_FRIEND_REQUESTED if the friend request was sent. | 126 | * return 1 if friend is connected to us (Online). |
136 | * return TOX_FRIEND_ADDED if the friend was added. | 127 | * return 0 if friend is not connected to us (Offline). |
137 | * return TOX_NOFRIEND if there is no friend with that number. | 128 | * return -1 on failure. |
129 | */ | ||
130 | int tox_get_friend_connectionstatus(Tox *tox, int friendnumber); | ||
131 | |||
132 | /* Checks if there exists a friend with given friendnumber. | ||
133 | * | ||
134 | * return 1 if friend exists. | ||
135 | * return 0 if friend doesn't exist. | ||
138 | */ | 136 | */ |
139 | int tox_friendstatus(Tox *tox, int friendnumber); | 137 | int tox_friend_exists(Tox *tox, int friendnumber); |
140 | 138 | ||
141 | /* Send a text chat message to an online friend. | 139 | /* Send a text chat message to an online friend. |
142 | * | 140 | * |