aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-02 17:10:22 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-02 17:10:22 +0000
commit17e35f0a3eabb698ac7a0e34e096d64ab3a6d123 (patch)
treef5f84f055e5ef8afcadc046d69d4e300bef1ed2f
parent1e0fa3c5117a2c3306b6bfa4a9d100ebde33b833 (diff)
downloadgnunet-17e35f0a3eabb698ac7a0e34e096d64ab3a6d123.tar.gz
gnunet-17e35f0a3eabb698ac7a0e34e096d64ab3a6d123.zip
-fix indentation, minor leaks
-rw-r--r--src/conversation/conversation_api.c102
-rw-r--r--src/conversation/gnunet-conversation.c52
-rw-r--r--src/include/gnunet_conversation_service.h3
3 files changed, 80 insertions, 77 deletions
diff --git a/src/conversation/conversation_api.c b/src/conversation/conversation_api.c
index c3fe8c960..5bd88c01f 100644
--- a/src/conversation/conversation_api.c
+++ b/src/conversation/conversation_api.c
@@ -81,54 +81,54 @@ struct GNUNET_CONVERSATION_CallInformation
81struct GNUNET_CONVERSATION_Handle 81struct GNUNET_CONVERSATION_Handle
82{ 82{
83 83
84 /** 84 /**
85 * Our configuration. 85 * Our configuration.
86 */ 86 */
87 const struct GNUNET_CONFIGURATION_Handle *cfg; 87 const struct GNUNET_CONFIGURATION_Handle *cfg;
88 88
89 /** 89 /**
90 * Handle to the server connection, to send messages later 90 * Handle to the server connection, to send messages later
91 */ 91 */
92 struct GNUNET_CLIENT_Connection *client; 92 struct GNUNET_CLIENT_Connection *client;
93 93
94 /** 94 /**
95 * GNS handle 95 * GNS handle
96 */ 96 */
97 struct GNUNET_GNS_Handle *gns; 97 struct GNUNET_GNS_Handle *gns;
98 98
99 /** 99 /**
100 * Namestore handle 100 * Namestore handle
101 */ 101 */
102 struct GNUNET_NAMESTORE_Handle *namestore; 102 struct GNUNET_NAMESTORE_Handle *namestore;
103 103
104 /** 104 /**
105 * TXT record for gns 105 * TXT record for gns
106 */ 106 */
107 int txt_record_set; 107 int txt_record_set;
108 108
109 /** 109 /**
110 * Callback for incoming calls 110 * Callback for incoming calls
111 */ 111 */
112 GNUNET_CONVERSATION_CallHandler *call_handler; 112 GNUNET_CONVERSATION_CallHandler *call_handler;
113 113
114 /** 114 /**
115 * Callback for rejected calls 115 * Callback for rejected calls
116 */ 116 */
117 GNUNET_CONVERSATION_RejectHandler *reject_handler; 117 GNUNET_CONVERSATION_RejectHandler *reject_handler;
118 118
119 /** 119 /**
120 * Callback for notifications 120 * Callback for notifications
121 */ 121 */
122 GNUNET_CONVERSATION_NotificationHandler *notification_handler; 122 GNUNET_CONVERSATION_NotificationHandler *notification_handler;
123 123
124 /** 124 /**
125 * Callback for missed calls 125 * Callback for missed calls
126 */ 126 */
127 GNUNET_CONVERSATION_MissedCallHandler *missed_call_handler; 127 GNUNET_CONVERSATION_MissedCallHandler *missed_call_handler;
128 128
129 /** 129 /**
130 * The pointer to the call 130 * The pointer to the call
131 */ 131 */
132 struct GNUNET_CONVERSATION_CallInformation *call; 132 struct GNUNET_CONVERSATION_CallInformation *call;
133}; 133};
134 134
@@ -210,26 +210,24 @@ check_gns_cb (void *cls, uint32_t rd_count,
210 { 210 {
211 h->txt_record_set = GNUNET_YES; 211 h->txt_record_set = GNUNET_YES;
212 } 212 }
213
214 return;
215} 213}
216 214
215
217/** 216/**
218* Check if the gns txt record for conversation exits 217 * Check if the gns txt record for conversation exits
219*/ 218 */
220static void 219static void
221check_gns (struct GNUNET_CONVERSATION_Handle *h) 220check_gns (struct GNUNET_CONVERSATION_Handle *h)
222{ 221{
223 GNUNET_GNS_lookup (h->gns, "conversation.gads", 222 GNUNET_GNS_lookup (h->gns, "conversation.gns",
224 NULL /* FIXME_ZONE */, 223 NULL /* FIXME_ZONE */,
225 GNUNET_DNSPARSER_TYPE_TXT, 224 GNUNET_DNSPARSER_TYPE_TXT,
226 GNUNET_NO, 225 GNUNET_NO,
227 NULL, 226 NULL,
228 &check_gns_cb, h); 227 &check_gns_cb, h);
229
230 return;
231} 228}
232 229
230
233/******************************************************************************/ 231/******************************************************************************/
234/*********************** RECEIVE HANDLERS ****************************/ 232/*********************** RECEIVE HANDLERS ****************************/
235/******************************************************************************/ 233/******************************************************************************/
@@ -241,7 +239,8 @@ check_gns (struct GNUNET_CONVERSATION_Handle *h)
241 * @param msg message received, NULL on timeout or fatal error 239 * @param msg message received, NULL on timeout or fatal error
242 */ 240 */
243static void 241static void
244receive_message_cb (void *cls, const struct GNUNET_MessageHeader *msg) 242receive_message_cb (void *cls,
243 const struct GNUNET_MessageHeader *msg)
245{ 244{
246 struct GNUNET_CONVERSATION_Handle *h = cls; 245 struct GNUNET_CONVERSATION_Handle *h = cls;
247 struct ServerClientSessionInitiateMessage *imsg; 246 struct ServerClientSessionInitiateMessage *imsg;
@@ -532,6 +531,7 @@ accept_call (struct GNUNET_CONVERSATION_Handle *h)
532 &transmit_session_accept_message, h); 531 &transmit_session_accept_message, h);
533} 532}
534 533
534
535/** 535/**
536 * Auxiliary function to reject a call. 536 * Auxiliary function to reject a call.
537 * 537 *
@@ -547,6 +547,7 @@ reject_call (struct GNUNET_CONVERSATION_Handle *h)
547 &transmit_session_reject_message, h); 547 &transmit_session_reject_message, h);
548} 548}
549 549
550
550/** 551/**
551 * Auxiliary function to terminate a call. 552 * Auxiliary function to terminate a call.
552 * 553 *
@@ -563,9 +564,10 @@ terminate_call (struct GNUNET_CONVERSATION_Handle *h)
563 h); 564 h);
564} 565}
565 566
567
566/** 568/**
567* 569 *
568*/ 570 */
569static void 571static void
570gns_call_cb (void *cls, uint32_t rd_count, 572gns_call_cb (void *cls, uint32_t rd_count,
571 const struct GNUNET_NAMESTORE_RecordData *rd) 573 const struct GNUNET_NAMESTORE_RecordData *rd)
@@ -635,15 +637,17 @@ gns_lookup_and_call (struct GNUNET_CONVERSATION_Handle *h, const char *callee)
635/******************************************************************************/ 637/******************************************************************************/
636 638
637struct GNUNET_CONVERSATION_Handle * 639struct GNUNET_CONVERSATION_Handle *
638GNUNET_CONVERSATION_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, 640GNUNET_CONVERSATION_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
639 GNUNET_CONVERSATION_CallHandler * call_handler, 641 void *cls,
640 GNUNET_CONVERSATION_RejectHandler * reject_handler, 642 GNUNET_CONVERSATION_CallHandler call_handler,
641 GNUNET_CONVERSATION_NotificationHandler * notification_handler, 643 GNUNET_CONVERSATION_RejectHandler reject_handler,
642 GNUNET_CONVERSATION_MissedCallHandler * missed_call_handler) 644 GNUNET_CONVERSATION_NotificationHandler notification_handler,
645 GNUNET_CONVERSATION_MissedCallHandler missed_call_handler)
643{ 646{
644 struct GNUNET_CONVERSATION_Handle *h; 647 struct GNUNET_CONVERSATION_Handle *h;
645 648
646 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "GNUNET_CONVERSATION_connect()\n"); 649 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
650 "GNUNET_CONVERSATION_connect()\n");
647 h = GNUNET_malloc (sizeof (struct GNUNET_CONVERSATION_Handle)); 651 h = GNUNET_malloc (sizeof (struct GNUNET_CONVERSATION_Handle));
648 652
649 h->cfg = cfg; 653 h->cfg = cfg;
@@ -690,6 +694,7 @@ GNUNET_CONVERSATION_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void
690 return h; 694 return h;
691} 695}
692 696
697
693void 698void
694GNUNET_CONVERSATION_disconnect (struct GNUNET_CONVERSATION_Handle *handle) 699GNUNET_CONVERSATION_disconnect (struct GNUNET_CONVERSATION_Handle *handle)
695{ 700{
@@ -732,6 +737,7 @@ GNUNET_CONVERSATION_call (struct GNUNET_CONVERSATION_Handle *h,
732 initiate_call (h, peer); 737 initiate_call (h, peer);
733} 738}
734 739
740
735void 741void
736GNUNET_CONVERSATION_hangup (struct GNUNET_CONVERSATION_Handle *h) 742GNUNET_CONVERSATION_hangup (struct GNUNET_CONVERSATION_Handle *h)
737{ 743{
@@ -741,6 +747,7 @@ GNUNET_CONVERSATION_hangup (struct GNUNET_CONVERSATION_Handle *h)
741 terminate_call (h); 747 terminate_call (h);
742} 748}
743 749
750
744void 751void
745GNUNET_CONVERSATION_accept (struct GNUNET_CONVERSATION_Handle *h) 752GNUNET_CONVERSATION_accept (struct GNUNET_CONVERSATION_Handle *h)
746{ 753{
@@ -750,6 +757,7 @@ GNUNET_CONVERSATION_accept (struct GNUNET_CONVERSATION_Handle *h)
750 accept_call (h); 757 accept_call (h);
751} 758}
752 759
760
753void 761void
754GNUNET_CONVERSATION_reject (struct GNUNET_CONVERSATION_Handle *h) 762GNUNET_CONVERSATION_reject (struct GNUNET_CONVERSATION_Handle *h)
755{ 763{
diff --git a/src/conversation/gnunet-conversation.c b/src/conversation/gnunet-conversation.c
index 60130c6d5..a4088984b 100644
--- a/src/conversation/gnunet-conversation.c
+++ b/src/conversation/gnunet-conversation.c
@@ -32,19 +32,20 @@
32#define MAX_MESSAGE_LENGTH (32 * 1024) 32#define MAX_MESSAGE_LENGTH (32 * 1024)
33 33
34/** 34/**
35* CONVERSATION handle 35 * CONVERSATION handle
36*/ 36 */
37struct GNUNET_CONVERSATION_Handle *conversation = NULL; 37static struct GNUNET_CONVERSATION_Handle *conversation;
38 38
39/** 39/**
40* Task which handles the commands 40 * Task which handles the commands
41*/ 41 */
42static GNUNET_SCHEDULER_TaskIdentifier handle_cmd_task; 42static GNUNET_SCHEDULER_TaskIdentifier handle_cmd_task;
43 43
44/** 44/**
45* Function declareation for executing a action 45 * Function declareation for executing a action
46*/ 46 */
47typedef int (*ActionFunction) (const char *argumetns, const void *xtra); 47typedef int (*ActionFunction) (const char *argumetns,
48 const void *xtra);
48 49
49/** 50/**
50* Structure which defines a command 51* Structure which defines a command
@@ -56,15 +57,10 @@ struct VoipCommand
56 const char *helptext; 57 const char *helptext;
57}; 58};
58 59
59/******************************************************************************/
60/*********************** DECLARATIONS *************************/
61/******************************************************************************/
62
63static int do_help (const char *args, const void *xtra);
64 60
65/******************************************************************************/ 61static int
66/*********************** Functions *************************/ 62do_help (const char *args,
67/******************************************************************************/ 63 const void *xtra);
68 64
69 65
70/** 66/**
@@ -167,7 +163,8 @@ missed_call_handler (void *cls,
167 struct GNUNET_CONVERSATION_Handle *handle, 163 struct GNUNET_CONVERSATION_Handle *handle,
168 struct GNUNET_CONVERSATION_MissedCallNotification *missed_calls) 164 struct GNUNET_CONVERSATION_MissedCallNotification *missed_calls)
169{ 165{
170 FPRINTF (stdout, _("You have missed calls.\n")); 166 FPRINTF (stdout,
167 _("You have missed calls.\n"));
171} 168}
172 169
173 170
@@ -189,7 +186,9 @@ static int
189do_unknown (const char *msg, 186do_unknown (const char *msg,
190 const void *xtra) 187 const void *xtra)
191{ 188{
192 FPRINTF (stderr, _("Unknown command `%s'\n"), msg); 189 FPRINTF (stderr,
190 _("Unknown command `%s'\n"),
191 msg);
193 return GNUNET_OK; 192 return GNUNET_OK;
194} 193}
195 194
@@ -201,13 +200,11 @@ static int
201do_call (const char *arg, 200do_call (const char *arg,
202 const void *xtra) 201 const void *xtra)
203{ 202{
204 char *callee = GNUNET_strdup (arg);
205
206 FPRINTF (stdout, 203 FPRINTF (stdout,
207 _("Initiating call to: %s\n"), 204 _("Initiating call to: %s\n"),
208 callee); 205 arg);
209 GNUNET_CONVERSATION_call (conversation, 206 GNUNET_CONVERSATION_call (conversation,
210 callee, 207 arg,
211 GNUNET_YES); 208 GNUNET_YES);
212 return GNUNET_OK; 209 return GNUNET_OK;
213} 210}
@@ -220,13 +217,12 @@ static int
220do_call_peer (const char *arg, 217do_call_peer (const char *arg,
221 const void *xtra) 218 const void *xtra)
222{ 219{
223 char *callee = GNUNET_strdup (arg);
224
225 FPRINTF (stdout, 220 FPRINTF (stdout,
226 _("Initiating call to: %s\n"), 221 _("Initiating call to: %s\n"),
227 callee); 222 arg);
228 GNUNET_CONVERSATION_call (conversation, callee, GNUNET_NO); 223 GNUNET_CONVERSATION_call (conversation,
229 224 arg,
225 GNUNET_NO);
230 return GNUNET_OK; 226 return GNUNET_OK;
231} 227}
232 228
@@ -278,7 +274,7 @@ do_hang_up (const char *args,
278 * List of supported commands. 274 * List of supported commands.
279 */ 275 */
280static struct VoipCommand commands[] = { 276static struct VoipCommand commands[] = {
281 {"/call ", &do_call, gettext_noop ("Use `/call gads_record'")}, 277 {"/call ", &do_call, gettext_noop ("Use `/call gns_name'")},
282 {"/callpeer ", &do_call_peer, 278 {"/callpeer ", &do_call_peer,
283 gettext_noop ("Use `/call private_key' to call a person")}, 279 gettext_noop ("Use `/call private_key' to call a person")},
284 {"/accept", &do_accept, 280 {"/accept", &do_accept,
diff --git a/src/include/gnunet_conversation_service.h b/src/include/gnunet_conversation_service.h
index 555e91adf..6b01119d8 100644
--- a/src/include/gnunet_conversation_service.h
+++ b/src/include/gnunet_conversation_service.h
@@ -93,8 +93,7 @@ struct GNUNET_CONVERSATION_Handle;
93 * @param caller peer that calls you 93 * @param caller peer that calls you
94 */ 94 */
95typedef void (GNUNET_CONVERSATION_CallHandler) (void *cls, 95typedef void (GNUNET_CONVERSATION_CallHandler) (void *cls,
96 struct 96 struct GNUNET_CONVERSATION_Handle *handle,
97 GNUNET_CONVERSATION_Handle *handle,
98 const struct GNUNET_PeerIdentity *caller); 97 const struct GNUNET_PeerIdentity *caller);
99 98
100 99