diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 22:37:19 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 22:37:19 +0000 |
commit | 4bd2dd5f82dceecd597b5829bf43b2dda9ebb505 (patch) | |
tree | eefec7343dcafac33c1f5bd36cef628229211741 | |
parent | 91e7c712a11e09ad4849f6272fd79abe3505dec2 (diff) | |
download | gnunet-gtk-4bd2dd5f82dceecd597b5829bf43b2dda9ebb505.tar.gz gnunet-gtk-4bd2dd5f82dceecd597b5829bf43b2dda9ebb505.zip |
indent
38 files changed, 5707 insertions, 5873 deletions
diff --git a/.indent.pro b/.indent.pro new file mode 100644 index 00000000..7009a914 --- /dev/null +++ b/.indent.pro | |||
@@ -0,0 +1,632 @@ | |||
1 | //GNU (default) style: | ||
2 | // | ||
3 | //-nbad -bap -nbc -bbo -bl -bli2 -bls -ncdb -nce -cp1 -cs -di2 | ||
4 | //-ndj -nfc1 -nfca -hnl -i2 -ip5 -lp -pcs -nprs -psl -saf -sai | ||
5 | //-saw -nsc -nsob | ||
6 | // | ||
7 | // ------- | ||
8 | // int foo; | ||
9 | // char *bar; | ||
10 | // bar = strdup ("whe-e-e"); | ||
11 | // ------- | ||
12 | // int foo; | ||
13 | // char *bar; | ||
14 | // | ||
15 | // bar = strdup ("whe-e-e"); | ||
16 | // ------- | ||
17 | // Broken in indent-2.2.10 | ||
18 | --blank-lines-after-declarations | ||
19 | //--no-blank-lines-after-declarations | ||
20 | // | ||
21 | // ------- | ||
22 | // int foo (...) { | ||
23 | // ... | ||
24 | // } | ||
25 | // void bar (...) { | ||
26 | // ... | ||
27 | // } | ||
28 | // ------- | ||
29 | // int foo (...) { | ||
30 | // ... | ||
31 | // } | ||
32 | // | ||
33 | // void bar (...) { | ||
34 | // ... | ||
35 | // } | ||
36 | // ------- | ||
37 | --blank-lines-after-procedures | ||
38 | // | ||
39 | // ------- | ||
40 | // /* | ||
41 | // blah | ||
42 | // */ | ||
43 | // ------- | ||
44 | // /* | ||
45 | // * blah | ||
46 | // */ | ||
47 | // ------- | ||
48 | // WARNING: tends to turn commented-out code chunks into star-walled comment blocks | ||
49 | --start-left-side-of-comments | ||
50 | // | ||
51 | // ------- | ||
52 | // if (foo) { bar } | ||
53 | // ------- | ||
54 | // if (foo) | ||
55 | // { | ||
56 | // bar | ||
57 | // } | ||
58 | // ------- | ||
59 | --braces-after-if-line | ||
60 | // | ||
61 | // ------- | ||
62 | // if (foo) | ||
63 | // { | ||
64 | // bar | ||
65 | // } else { | ||
66 | // baz | ||
67 | // } | ||
68 | // ------- | ||
69 | // if (foo) | ||
70 | // { | ||
71 | // bar | ||
72 | // } | ||
73 | // else | ||
74 | // { | ||
75 | // baz | ||
76 | // } | ||
77 | // ------- | ||
78 | --dont-cuddle-else | ||
79 | // | ||
80 | // ------- | ||
81 | // do | ||
82 | // { | ||
83 | // foo | ||
84 | // } | ||
85 | // while (bar) | ||
86 | // ------- | ||
87 | // do | ||
88 | // { | ||
89 | // foo | ||
90 | // } while (bar) | ||
91 | // ------- | ||
92 | --dont-cuddle-do-while | ||
93 | // | ||
94 | // ------- | ||
95 | // switch (foo) | ||
96 | // { | ||
97 | // case bar: | ||
98 | // baz | ||
99 | // } | ||
100 | // ------- | ||
101 | // switch (foo) | ||
102 | // { | ||
103 | // case bar: | ||
104 | // baz | ||
105 | // } | ||
106 | // ------- | ||
107 | --case-indentation0 | ||
108 | // | ||
109 | // ------- | ||
110 | // switch (foo) | ||
111 | // { | ||
112 | // case bar: | ||
113 | // { | ||
114 | // baz | ||
115 | // } | ||
116 | // } | ||
117 | // ------- | ||
118 | // switch (foo) | ||
119 | // { | ||
120 | // case bar: | ||
121 | // { | ||
122 | // baz | ||
123 | // } | ||
124 | // } | ||
125 | // ------- | ||
126 | // Yes, it looks wrong. However, braces inside cases should not be used like this anyway. | ||
127 | --case-brace-indentation0 | ||
128 | // | ||
129 | // ------- | ||
130 | // for (i = 0; foobar(i); i++); | ||
131 | // ------- | ||
132 | // for (i = 0; foobar(i); i++) ; | ||
133 | // ------- | ||
134 | --space-special-semicolon | ||
135 | // | ||
136 | // ------- | ||
137 | // foo(bar) | ||
138 | // ------- | ||
139 | // foo (bar) | ||
140 | // ------- | ||
141 | --space-after-procedure-calls | ||
142 | // | ||
143 | // ------- | ||
144 | // (int *)foo; | ||
145 | // (my_custom_type_that_was_not_passed_with_T_argument_see_below *)bar; | ||
146 | // ------- | ||
147 | // (int *) foo; | ||
148 | // (my_custom_type_that_was_not_passed_with_T_argument_see_below *)bar; | ||
149 | // ------- | ||
150 | --space-after-cast | ||
151 | // | ||
152 | // ------- | ||
153 | // sizeof(foobar) | ||
154 | // ------- | ||
155 | // sizeof (foobar) | ||
156 | // ------- | ||
157 | -bs | ||
158 | // | ||
159 | // ------- | ||
160 | // for(foo;bar;baz) | ||
161 | // ------- | ||
162 | // for (foo;bar;baz) | ||
163 | // ------- | ||
164 | --space-after-for | ||
165 | // | ||
166 | // ------- | ||
167 | // if(foo) | ||
168 | // ------- | ||
169 | // if (foo) | ||
170 | // ------- | ||
171 | --space-after-if | ||
172 | // | ||
173 | // ------- | ||
174 | // while(foo) | ||
175 | // ------- | ||
176 | // while (foo) | ||
177 | // ------- | ||
178 | --space-after-while | ||
179 | // | ||
180 | // ------- | ||
181 | // if ( foo ( a > b ) | ( bar ( baz ) ) ) | ||
182 | // ------- | ||
183 | // if (foo (a > b) | (bar (baz))) | ||
184 | // ------- | ||
185 | --no-space-after-parentheses | ||
186 | // | ||
187 | // ------- | ||
188 | // int a; | ||
189 | // char b; | ||
190 | // ------- | ||
191 | // int a; | ||
192 | // char b; | ||
193 | // ------- | ||
194 | --declaration-indentation0 | ||
195 | // | ||
196 | // ------- | ||
197 | // int a, | ||
198 | // b, | ||
199 | // c; | ||
200 | // ------- | ||
201 | // int a, b, c; | ||
202 | // ------- | ||
203 | --no-blank-lines-after-commas | ||
204 | // | ||
205 | // ------- | ||
206 | // int foo (int bar, char *baz, long wheee, intptr_t zool); | ||
207 | // ------- | ||
208 | // int foo ( | ||
209 | // int bar, | ||
210 | // char *baz, | ||
211 | // long wheee, | ||
212 | // intptr_t zool); | ||
213 | // ------- | ||
214 | --break-function-decl-args | ||
215 | // | ||
216 | // ------- | ||
217 | // int foo ( | ||
218 | // int bar, | ||
219 | // char *baz, | ||
220 | // long wheee, | ||
221 | // intptr_t zool | ||
222 | // ); | ||
223 | // ------- | ||
224 | // int foo ( | ||
225 | // int bar, | ||
226 | // char *baz, | ||
227 | // long wheee, | ||
228 | // intptr_t zool); | ||
229 | // ------- | ||
230 | --dont-break-function-decl-args-end | ||
231 | // | ||
232 | // ------- | ||
233 | // int foo (bar); | ||
234 | // ------- | ||
235 | // int | ||
236 | // foo (bar); | ||
237 | // ------- | ||
238 | --procnames-start-lines | ||
239 | // | ||
240 | // ------- | ||
241 | // struct foo { int a; }; | ||
242 | // ------- | ||
243 | // struct foo | ||
244 | // { | ||
245 | // int a; | ||
246 | // }; | ||
247 | // ------- | ||
248 | --braces-after-struct-decl-line | ||
249 | // | ||
250 | // ------- | ||
251 | // int foo (bar) { | ||
252 | // baz | ||
253 | // } | ||
254 | // ------- | ||
255 | // int foo (bar) | ||
256 | // { | ||
257 | // baz | ||
258 | // } | ||
259 | // ------- | ||
260 | --braces-after-func-def-line | ||
261 | // | ||
262 | // ------- | ||
263 | // if (foo) | ||
264 | // { | ||
265 | // while (bar) | ||
266 | // { | ||
267 | // baz; | ||
268 | // } | ||
269 | // } | ||
270 | // ------- | ||
271 | // if (foo) | ||
272 | // { | ||
273 | // while (bar) | ||
274 | // { | ||
275 | // baz; | ||
276 | // } | ||
277 | // } | ||
278 | // ------- | ||
279 | --indent-level2 | ||
280 | // | ||
281 | // ------- | ||
282 | // if (foo) | ||
283 | // { | ||
284 | // bar; | ||
285 | // } | ||
286 | // ------- | ||
287 | // if (foo) | ||
288 | // { | ||
289 | // bar; | ||
290 | // } | ||
291 | // ------- | ||
292 | --brace-indent0 | ||
293 | // | ||
294 | // ------- | ||
295 | // boom = foo (bar) - baz + | ||
296 | // whee (zool); | ||
297 | // rules = power (mono, mwahahahahahahahaahahahahahahahahahahhahahahahaha, | ||
298 | // stereo); | ||
299 | // ------- | ||
300 | // boom = foo (bar) - baz + | ||
301 | // whee (zool); | ||
302 | // rules = power (mono, mwahahahahahahahaahahahahahahahahahahhahahahahaha, | ||
303 | // stereo); | ||
304 | // ------- | ||
305 | --continuation-indentation4 | ||
306 | // | ||
307 | // ------- | ||
308 | // rules = power (mono, mwahahahahahahahaahahahahahahahahahahhahahahahaha, | ||
309 | // stereo); | ||
310 | // ------- | ||
311 | // rules = power (mono, mwahahahahahahahaahahahahahahahahahahhahahahahaha, | ||
312 | // stereo); | ||
313 | // ------- | ||
314 | --continue-at-parentheses | ||
315 | //--dont-line-up-parentheses | ||
316 | // | ||
317 | // ------- | ||
318 | // while ((((i < 2 && | ||
319 | // k > 0) || p == 0) && | ||
320 | // q == 1) || | ||
321 | // n = 0) | ||
322 | // ------- | ||
323 | // while ((((i < 2 && | ||
324 | // k > 0) || p == 0) && | ||
325 | // q == 1) || | ||
326 | // n = 0) | ||
327 | // ------- | ||
328 | --paren-indentation2 | ||
329 | // | ||
330 | // ------- | ||
331 | // char * | ||
332 | // create_world (x, y, scale) | ||
333 | // int x; | ||
334 | // int y; | ||
335 | // float scale; | ||
336 | // { | ||
337 | // ... | ||
338 | // } | ||
339 | // ------- | ||
340 | // char * | ||
341 | // create_world (x, y, scale) | ||
342 | // int x; | ||
343 | // int y; | ||
344 | // float scale; | ||
345 | // { | ||
346 | // ... | ||
347 | // } | ||
348 | // ------- | ||
349 | --parameter-indentation2 | ||
350 | // | ||
351 | // ------- | ||
352 | // if (longlonglonglonglonglonglong | ||
353 | // <tab character>short) | ||
354 | // ------- | ||
355 | // if (longlonglonglonglonglonglong | ||
356 | // short) | ||
357 | // ------- | ||
358 | --no-tabs | ||
359 | // | ||
360 | // ------- | ||
361 | // #if WINDOWS | ||
362 | // #if ZOOL | ||
363 | // #define WHEE GNUNET_NO | ||
364 | // #else | ||
365 | // #define WHEE GNUNET_YES | ||
366 | // #endif | ||
367 | // #endif | ||
368 | // ------- | ||
369 | // #if WINDOWS | ||
370 | // # if ZOOL | ||
371 | // # define WHEE GNUNET_NO | ||
372 | // # else | ||
373 | // # define WHEE GNUNET_YES | ||
374 | // # endif | ||
375 | // #endif | ||
376 | // ------- | ||
377 | --preprocessor-indentation0 | ||
378 | // | ||
379 | // ------- | ||
380 | // int foo (bar) | ||
381 | // { | ||
382 | // if (c) | ||
383 | // goto end; | ||
384 | // if (a > 0) | ||
385 | // { | ||
386 | // begin: | ||
387 | // a = 0; | ||
388 | // if (b != 0) | ||
389 | // goto begin; | ||
390 | // } | ||
391 | // end: | ||
392 | // return 0; | ||
393 | // } | ||
394 | // ------- | ||
395 | // int foo (bar) | ||
396 | // { | ||
397 | // if (c) | ||
398 | // goto end; | ||
399 | // if (a > 0) | ||
400 | // { | ||
401 | // begin: | ||
402 | // a = 0; | ||
403 | // if (b != 0) | ||
404 | // goto begin; | ||
405 | // } | ||
406 | // end: | ||
407 | // return 0; | ||
408 | // } | ||
409 | // ------- | ||
410 | --indent-label0 | ||
411 | // | ||
412 | // ------- | ||
413 | // line-longer-than-80-chars /* some comment, not counted */ | ||
414 | // ------- | ||
415 | // 80-chars-long-line /* some comment, not counted */ | ||
416 | // rest-of-the-line | ||
417 | // ------- | ||
418 | --line-length80 | ||
419 | // | ||
420 | // ------- | ||
421 | // /* comment-line-longer-than-80-chars */ | ||
422 | // ------- | ||
423 | // /* 80-chars-long-comment-line | ||
424 | // rest-of-the-line */ | ||
425 | // ------- | ||
426 | --comment-line-length80 | ||
427 | // | ||
428 | // ------- | ||
429 | // if (mask | ||
430 | // && ((mask[0] == '\0') | ||
431 | // || (mask[1] == '\0' | ||
432 | // && ((mask[0] == '0') || (mask[0] == '*'))))) | ||
433 | // ------- | ||
434 | // if (mask && | ||
435 | // ((mask[0] == '\0') || | ||
436 | // (mask[1] == '\0' && | ||
437 | // ((mask[0] == '0') || (mask[0] == '*'))))) | ||
438 | // ------- | ||
439 | --break-after-boolean-operator | ||
440 | // | ||
441 | // ------- | ||
442 | // if (mask | ||
443 | // && ((mask[0] == '\0') | ||
444 | // || (mask[1] == '\0' && ((mask[0] == '0') || (mask[0] == '*'))))) | ||
445 | // ------- | ||
446 | // if (mask /* this newline is preserved, override it with --ignore-newlines */ | ||
447 | // && ((mask[0] == '\0') | ||
448 | // || (mask[1] == '\0' && | ||
449 | // ((mask[0] == '0') || (mask[0] == '*'))))) | ||
450 | // ------- | ||
451 | // For now just keep ignoring. After everything settles down, we might want to start putting custom newlines where it is appropriate | ||
452 | // --honour-newlines | ||
453 | --ignore-newlines | ||
454 | // | ||
455 | // | ||
456 | // | ||
457 | // Also add a list of typedefed types here, like this: | ||
458 | // -T <typedefedtype1> | ||
459 | // -T <typedefedtype2> | ||
460 | // for this: | ||
461 | // typedef int typedefedtype1; | ||
462 | // typedef char *typedefedtype2; | ||
463 | // The following is obtained by running a Python script i wrote on src subdir: | ||
464 | -T GNUNET_MysqlDataProcessor | ||
465 | -T GNUNET_DHT_MessageReceivedHandler | ||
466 | -T DHTLOG_MESSAGE_TYPES | ||
467 | -T GNUNET_MysqlDataProcessor | ||
468 | -T GNUNET_DV_MessageReceivedHandler | ||
469 | -T p2p_dv_MESSAGE_NeighborInfo | ||
470 | -T p2p_dv_MESSAGE_Data | ||
471 | -T p2p_dv_MESSAGE_Disconnect | ||
472 | -T GNUNET_FS_QueueStart | ||
473 | -T GNUNET_FS_QueueStop | ||
474 | -T SuspendSignalFunction | ||
475 | -T GNUNET_FS_TEST_UriContinuation | ||
476 | -T GNUNET_FS_TreeBlockProcessor | ||
477 | -T GNUNET_FS_TreeProgressCallback | ||
478 | -T GSF_ConnectedPeerIterator | ||
479 | -T GSF_GetMessageCallback | ||
480 | -T GSF_PeerReserveCallback | ||
481 | -T GSF_PendingRequestReplyHandler | ||
482 | -T GSF_PendingRequestIterator | ||
483 | -T GSF_LocalLookupContinuation | ||
484 | -T GNUNET_ARM_Callback | ||
485 | -T GNUNET_TRANSPORT_ATS_AllocationNotification | ||
486 | -T GNUNET_ATS_AddressSuggestionCallback | ||
487 | -T GNUNET_BLOCK_GetKeyFunction | ||
488 | -T GNUNET_CHAT_JoinCallback | ||
489 | -T GNUNET_CHAT_MessageCallback | ||
490 | -T GNUNET_CHAT_MemberListCallback | ||
491 | -T GNUNET_CHAT_MessageConfirmation | ||
492 | -T GNUNET_CHAT_RoomIterator | ||
493 | -T GNUNET_CLIENT_MessageHandler | ||
494 | -T GNUNET_CLIENT_ShutdownTask | ||
495 | -T GNUNET_FileNameCallback | ||
496 | -T GNUNET_CONFIGURATION_Iterator | ||
497 | -T GNUNET_CONFIGURATION_Section_Iterator | ||
498 | -T GNUNET_CONNECTION_AccessCheck | ||
499 | -T GNUNET_CONNECTION_Receiver | ||
500 | -T GNUNET_CONNECTION_TransmitReadyNotify | ||
501 | -T GNUNET_HashCodeIterator | ||
502 | -T GNUNET_CONTAINER_HashMapIterator | ||
503 | -T GNUNET_CONTAINER_HeapCostType | ||
504 | -T GNUNET_CONTAINER_HeapIterator | ||
505 | -T GNUNET_CORE_ConnectEventHandler | ||
506 | -T GNUNET_CORE_PeerStatusEventHandler | ||
507 | -T GNUNET_CORE_DisconnectEventHandler | ||
508 | -T GNUNET_CORE_MessageCallback | ||
509 | -T GNUNET_CORE_StartupCallback | ||
510 | -T GNUNET_CORE_ControlContinuation | ||
511 | -T GNUNET_CORE_PeerConfigurationInfoCallback | ||
512 | -T GNUNET_CRYPTO_HashCompletedCallback | ||
513 | -T GNUNET_DATACACHE_Iterator | ||
514 | -T GNUNET_DATACACHE_DeleteNotifyCallback | ||
515 | -T DiskUtilizationChange | ||
516 | -T PluginDatumProcessor | ||
517 | -T PluginGetRandom | ||
518 | -T GNUNET_DATASTORE_ContinuationWithStatus | ||
519 | -T GNUNET_DATASTORE_DatumProcessor | ||
520 | -T GNUNET_DHT_GetIterator | ||
521 | -T GNUNET_DHT_FindPeerProcessor | ||
522 | -T GNUNET_DHT_ReplyProcessor | ||
523 | -T GNUNET_DISK_DirectoryIteratorCallback | ||
524 | -T GNUNET_FRAGMENT_MessageProcessor | ||
525 | -T GNUNET_DEFRAGMENT_AckProcessor | ||
526 | -T GNUNET_FS_KeywordIterator | ||
527 | -T GNUNET_FS_ProgressCallback | ||
528 | -T GNUNET_FS_FileInformationProcessor | ||
529 | -T GNUNET_FS_DataReader | ||
530 | -T GNUNET_FS_FileProcessor | ||
531 | -T GNUNET_FS_DirectoryScanner | ||
532 | -T GNUNET_FS_PublishContinuation | ||
533 | -T GNUNET_FS_IndexedFileProcessor | ||
534 | -T GNUNET_FS_NamespaceInfoProcessor | ||
535 | -T GNUNET_FS_IdentifierProcessor | ||
536 | -T GNUNET_FS_DirectoryEntryProcessor | ||
537 | -T GNUNET_HELLO_GenerateAddressListCallback | ||
538 | -T GNUNET_HELLO_AddressIterator | ||
539 | -T GNUNET_MESH_MessageCallback | ||
540 | -T GNUNET_MESH_TunnelEndHandler | ||
541 | -T GNUNET_MESH_ApplicationType | ||
542 | -T GNUNET_MESH_TunnelDisconnectHandler | ||
543 | -T GNUNET_MESH_TunnelConnectHandler | ||
544 | -T GNUNET_MESH_MessageCallback | ||
545 | -T GNUNET_MESH_TunnelEndHandler | ||
546 | -T GNUNET_MESH_ApplicationType | ||
547 | -T GNUNET_MESH_TunnelDisconnectHandler | ||
548 | -T GNUNET_MESH_TunnelConnectHandler | ||
549 | -T GNUNET_NAT_AddressCallback | ||
550 | -T GNUNET_NAT_ReversalCallback | ||
551 | -T GNUNET_NAT_TestCallback | ||
552 | -T GNUNET_NSE_Callback | ||
553 | -T GNUNET_OS_NetworkInterfaceProcessor | ||
554 | -T GNUNET_OS_LineProcessor | ||
555 | -T GNUNET_PEERINFO_Processor | ||
556 | -T GNUNET_PEER_Id | ||
557 | -T GNUNET_PLUGIN_Callback | ||
558 | -T GNUNET_PROGRAM_Main | ||
559 | -T GNUNET_PSEUDONYM_Iterator | ||
560 | -T GNUNET_RESOLVER_AddressCallback | ||
561 | -T GNUNET_RESOLVER_HostnameCallback | ||
562 | -T GNUNET_SCHEDULER_TaskIdentifier | ||
563 | -T GNUNET_SCHEDULER_Task | ||
564 | -T GNUNET_SCHEDULER_select | ||
565 | -T GNUNET_SERVER_MessageCallback | ||
566 | -T GNUNET_SERVER_DisconnectCallback | ||
567 | -T GNUNET_SERVER_MessageTokenizerCallback | ||
568 | -T GNUNET_SERVICE_Main | ||
569 | -T GNUNET_SIGNAL_Handler | ||
570 | -T GNUNET_STATISTICS_Iterator | ||
571 | -T GNUNET_STATISTICS_Callback | ||
572 | -T GNUNET_TESTING_NotifyHostkeyCreated | ||
573 | -T GNUNET_TESTING_NotifyDaemonRunning | ||
574 | -T GNUNET_TESTING_NotifyCompletion | ||
575 | -T GNUNET_TESTING_NotifyConnections | ||
576 | -T GNUNET_TESTING_NotifyConnection | ||
577 | -T GNUNET_TESTING_NotifyTopology | ||
578 | -T GNUNET_TESTING_STATISTICS_Iterator | ||
579 | -T GNUNET_TRANSPORT_SessionEnd | ||
580 | -T GNUNET_TRANSPORT_AddressNotification | ||
581 | -T GNUNET_TRANSPORT_TransmitContinuation | ||
582 | -T GNUNET_TRANSPORT_TransmitFunction | ||
583 | -T GNUNET_TRANSPORT_DisconnectFunction | ||
584 | -T GNUNET_TRANSPORT_AddressStringCallback | ||
585 | -T GNUNET_TRANSPORT_AddressPrettyPrinter | ||
586 | -T GNUNET_TRANSPORT_CheckAddress | ||
587 | -T GNUNET_TRANSPORT_AddressToString | ||
588 | -T GNUNET_TRANSPORT_ReceiveCallback | ||
589 | -T GNUNET_TRANSPORT_NotifyConnect | ||
590 | -T GNUNET_TRANSPORT_NotifyDisconnect | ||
591 | -T GNUNET_TRANSPORT_AddressLookUpCallback | ||
592 | -T GNUNET_TRANSPORT_HelloUpdateCallback | ||
593 | -T GNUNET_TRANSPORT_BlacklistCallback | ||
594 | -T sa_family_t | ||
595 | -T SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION | ||
596 | -T PLIBC_SEARCH__compar_fn_t | ||
597 | -T _win_comparison_fn_t | ||
598 | -T PLIBC_SEARCH_ACTION | ||
599 | -T PLIBC_SEARCH_VISIT | ||
600 | -T PLIBC_SEARCH__action_fn_t | ||
601 | -T PLIBC_SEARCH__free_fn_t | ||
602 | -T MESH_TunnelNumber | ||
603 | -T TransmissionContinuation | ||
604 | -T GNUNET_TESTING_ConnectionProcessor | ||
605 | -T SetupContinuation | ||
606 | -T glp_prob | ||
607 | -T glp_iocp | ||
608 | -T glp_smcp | ||
609 | -T GNUNET_TRANSPORT_ATS_AddressNotification | ||
610 | -T GNUNET_TRANSPORT_ATS_ResultCallback | ||
611 | -T GST_BlacklistTestContinuation | ||
612 | -T GST_HelloCallback | ||
613 | -T GST_NeighbourSendContinuation | ||
614 | -T GST_NeighbourIterator | ||
615 | -T GST_ValidationAddressCallback | ||
616 | -T u32 | ||
617 | -T u16 | ||
618 | -T u8 | ||
619 | -T __le32 | ||
620 | -T EmailAddress | ||
621 | -T SMTPMessage | ||
622 | -T GNUNET_TRANSPORT_TESTING_connect_cb | ||
623 | -T ieee80211_mgt_beacon_t | ||
624 | -T ieee80211_mgt_auth_t | ||
625 | -T u64 | ||
626 | -T u32 | ||
627 | -T u16 | ||
628 | -T u8 | ||
629 | -T uLong | ||
630 | -T uLong | ||
631 | -T KBlock_secret_key | ||
632 | -T MyNSGetExecutablePathProto | ||
diff --git a/pre-commit b/pre-commit new file mode 100755 index 00000000..2fc55423 --- /dev/null +++ b/pre-commit | |||
@@ -0,0 +1,8 @@ | |||
1 | #!/bin/sh | ||
2 | find src/ -name "*.c" -exec indent {} \; | ||
3 | find src/ -name "*.c" -exec indent {} \; | ||
4 | if test -x "`which 'dos2unix'`" | ||
5 | then | ||
6 | find src/ -name "*.c" -exec dos2unix {} \; | ||
7 | find src/ -name "*.c" -exec dos2unix {} \; | ||
8 | fi | ||
diff --git a/src/fs/gnunet-fs-gtk-about.c b/src/fs/gnunet-fs-gtk-about.c index 297ce718..4829db47 100644 --- a/src/fs/gnunet-fs-gtk-about.c +++ b/src/fs/gnunet-fs-gtk-about.c | |||
@@ -35,7 +35,7 @@ void | |||
35 | GNUNET_GTK_main_menu_help_about_activate_cb (GtkWidget * dummy, gpointer data) | 35 | GNUNET_GTK_main_menu_help_about_activate_cb (GtkWidget * dummy, gpointer data) |
36 | { | 36 | { |
37 | GNUNET_GTK_display_about ("gnunet_fs_gtk_about_dialog.glade", | 37 | GNUNET_GTK_display_about ("gnunet_fs_gtk_about_dialog.glade", |
38 | "GNUNET_GKT_about_dialog"); | 38 | "GNUNET_GKT_about_dialog"); |
39 | } | 39 | } |
40 | 40 | ||
41 | 41 | ||
diff --git a/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c b/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c index a8dd7b04..7a658f3f 100644 --- a/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c +++ b/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c | |||
@@ -32,8 +32,7 @@ | |||
32 | * Spin button is changed, update its colour. | 32 | * Spin button is changed, update its colour. |
33 | */ | 33 | */ |
34 | void | 34 | void |
35 | GNUNET_GTK_anonymity_spin_button_value_changed_cb (GtkWidget *w, | 35 | GNUNET_GTK_anonymity_spin_button_value_changed_cb (GtkWidget * w, gpointer data) |
36 | gpointer data) | ||
37 | { | 36 | { |
38 | GtkSpinButton *spin; | 37 | GtkSpinButton *spin; |
39 | gint val; | 38 | gint val; |
@@ -42,31 +41,31 @@ GNUNET_GTK_anonymity_spin_button_value_changed_cb (GtkWidget *w, | |||
42 | 41 | ||
43 | spin = GTK_SPIN_BUTTON (w); | 42 | spin = GTK_SPIN_BUTTON (w); |
44 | if (spin == NULL) | 43 | if (spin == NULL) |
45 | { | 44 | { |
46 | GNUNET_break (0); | 45 | GNUNET_break (0); |
47 | return; | 46 | return; |
48 | } | 47 | } |
49 | val = gtk_spin_button_get_value_as_int (spin); | 48 | val = gtk_spin_button_get_value_as_int (spin); |
50 | if (val == 0) | 49 | if (val == 0) |
50 | { | ||
51 | if ((TRUE == gdk_color_parse ("red", &bcolor)) && | ||
52 | (TRUE == | ||
53 | gdk_colormap_alloc_color (gdk_colormap_get_system (), &bcolor, FALSE, | ||
54 | TRUE)) && | ||
55 | (TRUE == gdk_color_parse ("black", &fcolor)) && | ||
56 | (TRUE == | ||
57 | gdk_colormap_alloc_color (gdk_colormap_get_system (), &fcolor, FALSE, | ||
58 | TRUE))) | ||
51 | { | 59 | { |
52 | if ((TRUE == gdk_color_parse ("red", | 60 | gtk_widget_modify_base (w, GTK_STATE_NORMAL, &bcolor); |
53 | &bcolor)) && | 61 | gtk_widget_modify_text (w, GTK_STATE_NORMAL, &fcolor); |
54 | (TRUE == gdk_colormap_alloc_color (gdk_colormap_get_system (), | ||
55 | &bcolor, FALSE, TRUE)) && | ||
56 | (TRUE == gdk_color_parse ("black", | ||
57 | &fcolor)) && | ||
58 | (TRUE == gdk_colormap_alloc_color (gdk_colormap_get_system (), | ||
59 | &fcolor, FALSE, TRUE))) | ||
60 | { | ||
61 | gtk_widget_modify_base (w, GTK_STATE_NORMAL, &bcolor); | ||
62 | gtk_widget_modify_text (w, GTK_STATE_NORMAL, &fcolor); | ||
63 | } | ||
64 | } | 62 | } |
63 | } | ||
65 | else | 64 | else |
66 | { | 65 | { |
67 | gtk_widget_modify_base (w, GTK_STATE_NORMAL, NULL); | 66 | gtk_widget_modify_base (w, GTK_STATE_NORMAL, NULL); |
68 | gtk_widget_modify_text (w, GTK_STATE_NORMAL, NULL); | 67 | gtk_widget_modify_text (w, GTK_STATE_NORMAL, NULL); |
69 | } | 68 | } |
70 | } | 69 | } |
71 | 70 | ||
72 | 71 | ||
diff --git a/src/fs/gnunet-fs-gtk-common.c b/src/fs/gnunet-fs-gtk-common.c index 55318f01..4f7b0112 100644 --- a/src/fs/gnunet-fs-gtk-common.c +++ b/src/fs/gnunet-fs-gtk-common.c | |||
@@ -40,28 +40,21 @@ | |||
40 | * @param data actual meta-data found | 40 | * @param data actual meta-data found |
41 | * @param data_len number of bytes in data | 41 | * @param data_len number of bytes in data |
42 | * @return 0 to continue (always) | 42 | * @return 0 to continue (always) |
43 | */ | 43 | */ |
44 | int | 44 | int |
45 | GNUNET_FS_GTK_add_meta_data_to_list_store (void *cls, | 45 | GNUNET_FS_GTK_add_meta_data_to_list_store (void *cls, const char *plugin_name, |
46 | const char *plugin_name, | 46 | enum EXTRACTOR_MetaType type, |
47 | enum EXTRACTOR_MetaType type, | 47 | enum EXTRACTOR_MetaFormat format, |
48 | enum EXTRACTOR_MetaFormat format, | 48 | const char *data_mime_type, |
49 | const char *data_mime_type, | 49 | const char *data, size_t data_len) |
50 | const char *data, | ||
51 | size_t data_len) | ||
52 | { | 50 | { |
53 | GtkListStore *ls = GTK_LIST_STORE (cls); | 51 | GtkListStore *ls = GTK_LIST_STORE (cls); |
54 | 52 | ||
55 | if ( (format == EXTRACTOR_METAFORMAT_UTF8) || | 53 | if ((format == EXTRACTOR_METAFORMAT_UTF8) || |
56 | (format == EXTRACTOR_METAFORMAT_C_STRING) ) | 54 | (format == EXTRACTOR_METAFORMAT_C_STRING)) |
57 | gtk_list_store_insert_with_values (ls, | 55 | gtk_list_store_insert_with_values (ls, NULL, G_MAXINT, 0, type, 1, format, |
58 | NULL, | 56 | 2, EXTRACTOR_metatype_to_string (type), |
59 | G_MAXINT, | 57 | 3, data, -1); |
60 | 0, type, | ||
61 | 1, format, | ||
62 | 2, EXTRACTOR_metatype_to_string (type), | ||
63 | 3, data, | ||
64 | -1); | ||
65 | return 0; | 58 | return 0; |
66 | } | 59 | } |
67 | 60 | ||
@@ -70,36 +63,37 @@ GNUNET_FS_GTK_add_meta_data_to_list_store (void *cls, | |||
70 | * Convert the year from the spin button to an expiration | 63 | * Convert the year from the spin button to an expiration |
71 | * time (on midnight, January 1st of that year). | 64 | * time (on midnight, January 1st of that year). |
72 | */ | 65 | */ |
73 | struct GNUNET_TIME_Absolute | 66 | struct GNUNET_TIME_Absolute |
74 | GNUNET_FS_GTK_get_expiration_time (GtkSpinButton *spin) | 67 | GNUNET_FS_GTK_get_expiration_time (GtkSpinButton * spin) |
75 | { | 68 | { |
76 | struct GNUNET_TIME_Absolute ret; | 69 | struct GNUNET_TIME_Absolute ret; |
77 | int year; | 70 | int year; |
78 | 71 | ||
79 | year = gtk_spin_button_get_value_as_int (spin); | 72 | year = gtk_spin_button_get_value_as_int (spin); |
80 | GNUNET_assert (year >= 0); | 73 | GNUNET_assert (year >= 0); |
81 | ret = GNUNET_FS_year_to_time ( (unsigned int) year); | 74 | ret = GNUNET_FS_year_to_time ((unsigned int) year); |
82 | GNUNET_break (GNUNET_TIME_absolute_get ().abs_value < ret.abs_value); | 75 | GNUNET_break (GNUNET_TIME_absolute_get ().abs_value < ret.abs_value); |
83 | return ret; | 76 | return ret; |
84 | } | 77 | } |
85 | 78 | ||
86 | 79 | ||
87 | void | 80 | void |
88 | GNUNET_FS_GTK_setup_expiration_year_adjustment (GtkBuilder *builder) | 81 | GNUNET_FS_GTK_setup_expiration_year_adjustment (GtkBuilder * builder) |
89 | { | 82 | { |
90 | GtkAdjustment *aj; | 83 | GtkAdjustment *aj; |
91 | unsigned int year; | 84 | unsigned int year; |
92 | 85 | ||
93 | year = GNUNET_FS_get_current_year (); | 86 | year = GNUNET_FS_get_current_year (); |
94 | aj = GTK_ADJUSTMENT (gtk_builder_get_object (builder, | 87 | aj = GTK_ADJUSTMENT (gtk_builder_get_object |
95 | "expiration_year_adjustment")); | 88 | (builder, "expiration_year_adjustment")); |
96 | gtk_adjustment_set_value (aj, year + 2); | 89 | gtk_adjustment_set_value (aj, year + 2); |
97 | gtk_adjustment_set_lower (aj, year + 1); | 90 | gtk_adjustment_set_lower (aj, year + 1); |
98 | } | 91 | } |
99 | 92 | ||
100 | 93 | ||
101 | GdkPixbuf * | 94 | GdkPixbuf * |
102 | GNUNET_FS_GTK_get_thumbnail_from_meta_data (const struct GNUNET_CONTAINER_MetaData *meta) | 95 | GNUNET_FS_GTK_get_thumbnail_from_meta_data (const struct |
96 | GNUNET_CONTAINER_MetaData *meta) | ||
103 | { | 97 | { |
104 | GdkPixbuf *pixbuf; | 98 | GdkPixbuf *pixbuf; |
105 | GdkPixbufLoader *loader; | 99 | GdkPixbufLoader *loader; |
@@ -128,55 +122,43 @@ GNUNET_FS_GTK_get_thumbnail_from_meta_data (const struct GNUNET_CONTAINER_MetaDa | |||
128 | */ | 122 | */ |
129 | void | 123 | void |
130 | GNUNET_FS_GTK_mmap_and_scan (const char *filename, | 124 | GNUNET_FS_GTK_mmap_and_scan (const char *filename, |
131 | GNUNET_FS_DirectoryEntryProcessor dep, | 125 | GNUNET_FS_DirectoryEntryProcessor dep, |
132 | void *dep_cls) | 126 | void *dep_cls) |
133 | { | 127 | { |
134 | struct GNUNET_DISK_FileHandle *fh; | 128 | struct GNUNET_DISK_FileHandle *fh; |
135 | struct GNUNET_DISK_MapHandle *mh; | 129 | struct GNUNET_DISK_MapHandle *mh; |
136 | uint64_t fsize; | 130 | uint64_t fsize; |
137 | void * ddata; | 131 | void *ddata; |
138 | 132 | ||
139 | if (GNUNET_OK != | 133 | if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fsize, GNUNET_YES)) |
140 | GNUNET_DISK_file_size (filename, | 134 | { |
141 | &fsize, | 135 | GNUNET_break (0); |
142 | GNUNET_YES)) | 136 | return; |
143 | { | 137 | } |
144 | GNUNET_break (0); | 138 | fh = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, |
145 | return; | 139 | GNUNET_DISK_PERM_NONE); |
146 | } | ||
147 | fh = GNUNET_DISK_file_open (filename, | ||
148 | GNUNET_DISK_OPEN_READ, | ||
149 | GNUNET_DISK_PERM_NONE); | ||
150 | if (fh == NULL) | 140 | if (fh == NULL) |
151 | { | 141 | { |
152 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", filename); | 142 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", filename); |
153 | return; | 143 | return; |
154 | } | 144 | } |
155 | ddata = GNUNET_DISK_file_map (fh, | 145 | ddata = |
156 | &mh, | 146 | GNUNET_DISK_file_map (fh, &mh, GNUNET_DISK_MAP_TYPE_READ, (size_t) fsize); |
157 | GNUNET_DISK_MAP_TYPE_READ, | ||
158 | (size_t) fsize); | ||
159 | if (ddata == NULL) | 147 | if (ddata == NULL) |
160 | { | 148 | { |
161 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "mmap", filename); | 149 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "mmap", filename); |
162 | GNUNET_break (GNUNET_OK == | 150 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fh)); |
163 | GNUNET_DISK_file_close (fh)); | 151 | return; |
164 | return; | 152 | } |
165 | } | ||
166 | if (GNUNET_SYSERR == | 153 | if (GNUNET_SYSERR == |
167 | GNUNET_FS_directory_list_contents ((size_t) fsize, | 154 | GNUNET_FS_directory_list_contents ((size_t) fsize, ddata, 0, dep, |
168 | ddata, | 155 | dep_cls)) |
169 | 0, | 156 | { |
170 | dep, dep_cls)) | 157 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
171 | { | 158 | _("Selected file `%s' is not a GNUnet directory!\n"), filename); |
172 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 159 | } |
173 | _("Selected file `%s' is not a GNUnet directory!\n"), | 160 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_unmap (mh)); |
174 | filename); | 161 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fh)); |
175 | } | ||
176 | GNUNET_break (GNUNET_OK == | ||
177 | GNUNET_DISK_file_unmap (mh)); | ||
178 | GNUNET_break (GNUNET_OK == | ||
179 | GNUNET_DISK_file_close (fh)); | ||
180 | } | 162 | } |
181 | 163 | ||
182 | 164 | ||
diff --git a/src/fs/gnunet-fs-gtk-download.c b/src/fs/gnunet-fs-gtk-download.c index 180a48ec..fe239e5a 100644 --- a/src/fs/gnunet-fs-gtk-download.c +++ b/src/fs/gnunet-fs-gtk-download.c | |||
@@ -40,58 +40,65 @@ GNUNET_FS_GTK_open_download_as_dialog (struct DownloadContext *dc) | |||
40 | struct DownloadEntry *de; | 40 | struct DownloadEntry *de; |
41 | GtkWidget *cb; | 41 | GtkWidget *cb; |
42 | 42 | ||
43 | builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_download_as_dialog.glade"); | 43 | builder = |
44 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_download_as_dialog.glade"); | ||
44 | if (builder == NULL) | 45 | if (builder == NULL) |
45 | { | 46 | { |
46 | if (dc->rr != NULL) | 47 | if (dc->rr != NULL) |
47 | gtk_tree_row_reference_free (dc->rr); | 48 | gtk_tree_row_reference_free (dc->rr); |
48 | GNUNET_free_non_null (dc->mime); | 49 | GNUNET_free_non_null (dc->mime); |
49 | GNUNET_free_non_null (dc->filename); | 50 | GNUNET_free_non_null (dc->filename); |
50 | GNUNET_FS_uri_destroy (dc->uri); | 51 | GNUNET_FS_uri_destroy (dc->uri); |
51 | GNUNET_free (dc); | 52 | GNUNET_free (dc); |
52 | return; | 53 | return; |
53 | } | 54 | } |
54 | cb = GTK_WIDGET (gtk_builder_get_object (builder, | 55 | cb = GTK_WIDGET (gtk_builder_get_object |
55 | "GNUNET_GTK_save_as_recursive_check_button")); | 56 | (builder, "GNUNET_GTK_save_as_recursive_check_button")); |
56 | if (GNUNET_FS_meta_data_test_for_directory (dc->meta)) | 57 | if (GNUNET_FS_meta_data_test_for_directory (dc->meta)) |
57 | gtk_widget_set_sensitive (cb, TRUE); | 58 | gtk_widget_set_sensitive (cb, TRUE); |
58 | ad = GTK_WIDGET (gtk_builder_get_object (builder, | 59 | ad = GTK_WIDGET (gtk_builder_get_object |
59 | "GNUNET_GTK_save_as_dialog")); | 60 | (builder, "GNUNET_GTK_save_as_dialog")); |
60 | if (dc->filename != NULL) | 61 | if (dc->filename != NULL) |
62 | { | ||
63 | char buf[1024]; | ||
64 | |||
65 | if (NULL != getcwd (buf, sizeof (buf))) | ||
61 | { | 66 | { |
62 | char buf[1024]; | 67 | if (strlen (buf) + strlen (dc->filename) + 2 < sizeof (buf)) |
63 | if (NULL != getcwd (buf, sizeof(buf))) | 68 | { |
64 | { | 69 | strcat (buf, DIR_SEPARATOR_STR); |
65 | if (strlen (buf) + strlen (dc->filename) + 2 < sizeof(buf)) | 70 | strcat (buf, dc->filename); |
66 | { | 71 | } |
67 | strcat (buf, DIR_SEPARATOR_STR); | 72 | gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (ad), buf); |
68 | strcat (buf, dc->filename); | ||
69 | } | ||
70 | gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (ad), | ||
71 | buf); | ||
72 | } | ||
73 | } | 73 | } |
74 | } | ||
74 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) | 75 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) |
75 | { | 76 | { |
76 | gtk_widget_destroy (ad); | 77 | gtk_widget_destroy (ad); |
77 | g_object_unref (G_OBJECT (builder)); | 78 | g_object_unref (G_OBJECT (builder)); |
78 | if (dc->rr != NULL) | 79 | if (dc->rr != NULL) |
79 | gtk_tree_row_reference_free (dc->rr); | 80 | gtk_tree_row_reference_free (dc->rr); |
80 | GNUNET_free_non_null (dc->mime); | 81 | GNUNET_free_non_null (dc->mime); |
81 | GNUNET_free_non_null (dc->filename); | 82 | GNUNET_free_non_null (dc->filename); |
82 | GNUNET_FS_uri_destroy (dc->uri); | 83 | GNUNET_FS_uri_destroy (dc->uri); |
83 | GNUNET_free (dc); | 84 | GNUNET_free (dc); |
84 | return; | 85 | return; |
85 | } | 86 | } |
86 | GNUNET_free_non_null (dc->filename); | 87 | GNUNET_free_non_null (dc->filename); |
87 | dc->filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(ad)); | 88 | dc->filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (ad)); |
88 | dc->is_recursive = (TRUE == gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cb))) ? GNUNET_YES : GNUNET_NO; | 89 | dc->is_recursive = |
90 | (TRUE == | ||
91 | gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cb))) ? GNUNET_YES : | ||
92 | GNUNET_NO; | ||
89 | fs = GNUNET_FS_GTK_get_fs_handle (); | 93 | fs = GNUNET_FS_GTK_get_fs_handle (); |
90 | opt = GNUNET_FS_DOWNLOAD_OPTION_NONE; | 94 | opt = GNUNET_FS_DOWNLOAD_OPTION_NONE; |
91 | if (dc->is_recursive) | 95 | if (dc->is_recursive) |
92 | opt |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE; | 96 | opt |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE; |
93 | anonymity = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 97 | anonymity = |
94 | "GNUNET_GTK_save_as_dialog_anonymity_spin_button"))); | 98 | gtk_spin_button_get_value (GTK_SPIN_BUTTON |
99 | (gtk_builder_get_object | ||
100 | (builder, | ||
101 | "GNUNET_GTK_save_as_dialog_anonymity_spin_button"))); | ||
95 | len = GNUNET_FS_uri_chk_get_file_size (dc->uri); | 102 | len = GNUNET_FS_uri_chk_get_file_size (dc->uri); |
96 | gtk_widget_destroy (ad); | 103 | gtk_widget_destroy (ad); |
97 | g_object_unref (G_OBJECT (builder)); | 104 | g_object_unref (G_OBJECT (builder)); |
@@ -99,38 +106,29 @@ GNUNET_FS_GTK_open_download_as_dialog (struct DownloadContext *dc) | |||
99 | de->uri = dc->uri; | 106 | de->uri = dc->uri; |
100 | de->meta = dc->meta; | 107 | de->meta = dc->meta; |
101 | if (dc->rr != NULL) | 108 | if (dc->rr != NULL) |
102 | { | 109 | { |
103 | de->rr = dc->rr; | 110 | de->rr = dc->rr; |
104 | de->ts = GTK_TREE_STORE (gtk_tree_row_reference_get_model (dc->rr)); | 111 | de->ts = GTK_TREE_STORE (gtk_tree_row_reference_get_model (dc->rr)); |
105 | } | 112 | } |
106 | if (dc->sr != NULL) | 113 | if (dc->sr != NULL) |
107 | { | 114 | { |
108 | GNUNET_break (NULL != | 115 | GNUNET_break (NULL != |
109 | GNUNET_FS_download_start_from_search (fs, | 116 | GNUNET_FS_download_start_from_search (fs, dc->sr, |
110 | dc->sr, | 117 | dc->filename, |
111 | dc->filename, | 118 | NULL /* tempname */ , |
112 | NULL /* tempname */, | 119 | 0 /* offset */ , |
113 | 0 /* offset */, | 120 | len, anonymity, opt, |
114 | len, | 121 | de)); |
115 | anonymity, | 122 | } |
116 | opt, | ||
117 | de)); | ||
118 | } | ||
119 | else | 123 | else |
120 | { | 124 | { |
121 | GNUNET_break (NULL != | 125 | GNUNET_break (NULL != |
122 | GNUNET_FS_download_start (fs, | 126 | GNUNET_FS_download_start (fs, dc->uri, NULL /* meta */ , |
123 | dc->uri, | 127 | dc->filename, NULL /* tempname */ , |
124 | NULL /* meta */, | 128 | 0 /* offset */ , |
125 | dc->filename, | 129 | len, anonymity, opt, de, |
126 | NULL /* tempname */, | 130 | NULL /* parent download ctx */ )); |
127 | 0 /* offset */, | 131 | } |
128 | len, | ||
129 | anonymity, | ||
130 | opt, | ||
131 | de, | ||
132 | NULL /* parent download ctx */)); | ||
133 | } | ||
134 | GNUNET_free (dc); | 132 | GNUNET_free (dc); |
135 | } | 133 | } |
136 | 134 | ||
diff --git a/src/fs/gnunet-fs-gtk-edit_publish_dialog.c b/src/fs/gnunet-fs-gtk-edit_publish_dialog.c index 3e960cf4..e6cbd105 100644 --- a/src/fs/gnunet-fs-gtk-edit_publish_dialog.c +++ b/src/fs/gnunet-fs-gtk-edit_publish_dialog.c | |||
@@ -55,16 +55,16 @@ GNUNET_GTK_edit_file_information_keyword_list_del_button_clicked_cb () | |||
55 | GtkTreeModel *tm; | 55 | GtkTreeModel *tm; |
56 | GtkTreeIter iter; | 56 | GtkTreeIter iter; |
57 | 57 | ||
58 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 58 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
59 | "GNUNET_GTK_edit_file_information_keyword_list_tree_view")); | 59 | (builder, |
60 | "GNUNET_GTK_edit_file_information_keyword_list_tree_view")); | ||
60 | sel = gtk_tree_view_get_selection (tv); | 61 | sel = gtk_tree_view_get_selection (tv); |
61 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) | 62 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
62 | { | 63 | { |
63 | GNUNET_break (0); | 64 | GNUNET_break (0); |
64 | return; | 65 | return; |
65 | } | 66 | } |
66 | gtk_list_store_remove (GTK_LIST_STORE (tm), | 67 | gtk_list_store_remove (GTK_LIST_STORE (tm), &iter); |
67 | &iter); | ||
68 | } | 68 | } |
69 | 69 | ||
70 | void | 70 | void |
@@ -75,10 +75,11 @@ GNUNET_GTK_edit_file_information_keyword_list_add_button_clicked_cb () | |||
75 | GtkListStore *ls; | 75 | GtkListStore *ls; |
76 | GtkTreeIter iter; | 76 | GtkTreeIter iter; |
77 | 77 | ||
78 | ls = GTK_LIST_STORE (gtk_builder_get_object (builder, | 78 | ls = GTK_LIST_STORE (gtk_builder_get_object |
79 | "GNUNET_GTK_keyword_list_store")); | 79 | (builder, "GNUNET_GTK_keyword_list_store")); |
80 | entry = GTK_ENTRY (gtk_builder_get_object (builder, | 80 | entry = |
81 | "GNUNET_GTK_edit_file_information_keyword_entry")); | 81 | GTK_ENTRY (gtk_builder_get_object |
82 | (builder, "GNUNET_GTK_edit_file_information_keyword_entry")); | ||
82 | keyword = gtk_entry_get_text (entry); | 83 | keyword = gtk_entry_get_text (entry); |
83 | if (strlen (keyword) > 0) | 84 | if (strlen (keyword) > 0) |
84 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, 0, keyword, -1); | 85 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, 0, keyword, -1); |
@@ -93,78 +94,92 @@ GNUNET_GTK_edit_file_information_keyword_entry_changed_cb () | |||
93 | GtkEntry *entry; | 94 | GtkEntry *entry; |
94 | GtkWidget *button; | 95 | GtkWidget *button; |
95 | 96 | ||
96 | button = GTK_WIDGET (gtk_builder_get_object (builder, | 97 | button = |
97 | "GNUNET_GTK_edit_file_information_keyword_list_add_button")); | 98 | GTK_WIDGET (gtk_builder_get_object |
98 | entry = GTK_ENTRY (gtk_builder_get_object (builder, | 99 | (builder, |
99 | "GNUNET_GTK_edit_file_information_keyword_entry")); | 100 | "GNUNET_GTK_edit_file_information_keyword_list_add_button")); |
101 | entry = | ||
102 | GTK_ENTRY (gtk_builder_get_object | ||
103 | (builder, "GNUNET_GTK_edit_file_information_keyword_entry")); | ||
100 | keyword = gtk_entry_get_text (entry); | 104 | keyword = gtk_entry_get_text (entry); |
101 | gtk_widget_set_sensitive (button, | 105 | gtk_widget_set_sensitive (button, (strlen (keyword) > 0) ? TRUE : FALSE); |
102 | (strlen (keyword) > 0) ? TRUE : FALSE); | ||
103 | } | 106 | } |
104 | 107 | ||
105 | 108 | ||
106 | static void | 109 | static void |
107 | metadata_selection_changed_cb (GtkTreeSelection *ts, | 110 | metadata_selection_changed_cb (GtkTreeSelection * ts, gpointer user_data) |
108 | gpointer user_data) | ||
109 | { | 111 | { |
110 | GtkTreeView *tv; | 112 | GtkTreeView *tv; |
111 | GtkTreeSelection *sel; | 113 | GtkTreeSelection *sel; |
112 | GtkWidget *button; | 114 | GtkWidget *button; |
113 | 115 | ||
114 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 116 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
115 | "GNUNET_GTK_edit_file_information_metadata_tree_view")); | 117 | (builder, |
118 | "GNUNET_GTK_edit_file_information_metadata_tree_view")); | ||
116 | sel = gtk_tree_view_get_selection (tv); | 119 | sel = gtk_tree_view_get_selection (tv); |
117 | button = GTK_WIDGET (gtk_builder_get_object (builder, | 120 | button = |
118 | "GNUNET_GTK_edit_file_information_metadata_delete_button")); | 121 | GTK_WIDGET (gtk_builder_get_object |
122 | (builder, | ||
123 | "GNUNET_GTK_edit_file_information_metadata_delete_button")); | ||
119 | gtk_widget_set_sensitive (button, | 124 | gtk_widget_set_sensitive (button, |
120 | gtk_tree_selection_get_selected (sel, NULL, NULL)); | 125 | gtk_tree_selection_get_selected (sel, NULL, NULL)); |
121 | } | 126 | } |
122 | 127 | ||
123 | 128 | ||
124 | static void | 129 | static void |
125 | keyword_selection_changed_cb (GtkTreeSelection *ts, | 130 | keyword_selection_changed_cb (GtkTreeSelection * ts, gpointer user_data) |
126 | gpointer user_data) | ||
127 | { | 131 | { |
128 | GtkTreeView *tv; | 132 | GtkTreeView *tv; |
129 | GtkTreeSelection *sel; | 133 | GtkTreeSelection *sel; |
130 | GtkWidget *button; | 134 | GtkWidget *button; |
131 | 135 | ||
132 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 136 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
133 | "GNUNET_GTK_edit_file_information_keyword_list_tree_view")); | 137 | (builder, |
138 | "GNUNET_GTK_edit_file_information_keyword_list_tree_view")); | ||
134 | sel = gtk_tree_view_get_selection (tv); | 139 | sel = gtk_tree_view_get_selection (tv); |
135 | button = GTK_WIDGET (gtk_builder_get_object (builder, | 140 | button = |
136 | "GNUNET_GTK_edit_file_information_keyword_list_del_button")); | 141 | GTK_WIDGET (gtk_builder_get_object |
142 | (builder, | ||
143 | "GNUNET_GTK_edit_file_information_keyword_list_del_button")); | ||
137 | 144 | ||
138 | gtk_widget_set_sensitive (button, | 145 | gtk_widget_set_sensitive (button, |
139 | gtk_tree_selection_get_selected (sel, NULL, NULL)); | 146 | gtk_tree_selection_get_selected (sel, NULL, NULL)); |
140 | button = GTK_WIDGET (gtk_builder_get_object (builder, | 147 | button = |
141 | "GNUNET_GTK_edit_file_information_keyword_list_normalize_button")); | 148 | GTK_WIDGET (gtk_builder_get_object |
149 | (builder, | ||
150 | "GNUNET_GTK_edit_file_information_keyword_list_normalize_button")); | ||
142 | gtk_widget_set_sensitive (button, | 151 | gtk_widget_set_sensitive (button, |
143 | gtk_tree_selection_get_selected (sel, NULL, NULL)); | 152 | gtk_tree_selection_get_selected (sel, NULL, NULL)); |
144 | } | 153 | } |
145 | 154 | ||
146 | 155 | ||
147 | void | 156 | void |
148 | GNUNET_GTK_edit_file_information_metadata_value_entry_changed_cb () | 157 | GNUNET_GTK_edit_file_information_metadata_value_entry_changed_cb () |
149 | { | 158 | { |
150 | GtkTreeView *tv; | 159 | GtkTreeView *tv; |
151 | GtkTreeSelection *sel; | 160 | GtkTreeSelection *sel; |
152 | const char *value; | 161 | const char *value; |
153 | GtkEntry *entry; | 162 | GtkEntry *entry; |
154 | GtkWidget *button; | 163 | GtkWidget *button; |
155 | 164 | ||
156 | entry = GTK_ENTRY (gtk_builder_get_object (builder, | 165 | entry = |
157 | "GNUNET_GTK_edit_file_information_metadata_value_entry")); | 166 | GTK_ENTRY (gtk_builder_get_object |
167 | (builder, | ||
168 | "GNUNET_GTK_edit_file_information_metadata_value_entry")); | ||
158 | value = gtk_entry_get_text (entry); | 169 | value = gtk_entry_get_text (entry); |
159 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 170 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
160 | "GNUNET_GTK_edit_file_information_metadata_type_tree_view")); | 171 | (builder, |
172 | "GNUNET_GTK_edit_file_information_metadata_type_tree_view")); | ||
161 | sel = gtk_tree_view_get_selection (tv); | 173 | sel = gtk_tree_view_get_selection (tv); |
162 | button = GTK_WIDGET (gtk_builder_get_object (builder, | 174 | button = |
163 | "GNUNET_GTK_edit_file_information_metadata_add_button")); | 175 | GTK_WIDGET (gtk_builder_get_object |
176 | (builder, | ||
177 | "GNUNET_GTK_edit_file_information_metadata_add_button")); | ||
164 | gtk_widget_set_sensitive (button, | 178 | gtk_widget_set_sensitive (button, |
165 | (strlen (value) > 0) | 179 | (strlen (value) > |
166 | ? gtk_tree_selection_get_selected (sel, NULL, NULL) | 180 | 0) ? gtk_tree_selection_get_selected (sel, NULL, |
167 | : FALSE); | 181 | NULL) : |
182 | FALSE); | ||
168 | } | 183 | } |
169 | 184 | ||
170 | 185 | ||
@@ -175,39 +190,39 @@ GNUNET_GTK_edit_file_information_keyword_entry_activate_cb () | |||
175 | } | 190 | } |
176 | 191 | ||
177 | 192 | ||
178 | void | 193 | void GNUNET_GTK_edit_file_information_metadata_preview_file_chooser_button_file_set_cb (GtkFileChooserButton * widget, gpointer user_data) |
179 | GNUNET_GTK_edit_file_information_metadata_preview_file_chooser_button_file_set_cb (GtkFileChooserButton *widget, | ||
180 | gpointer user_data) | ||
181 | { | 194 | { |
182 | gchar *fn; | 195 | gchar *fn; |
183 | GtkImage *image; | 196 | GtkImage *image; |
184 | 197 | ||
185 | fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)); | 198 | fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)); |
186 | image = GTK_IMAGE (gtk_builder_get_object (builder, | 199 | image = |
187 | "GNUNET_GTK_edit_file_information_metadata_preview_image")); | 200 | GTK_IMAGE (gtk_builder_get_object |
201 | (builder, | ||
202 | "GNUNET_GTK_edit_file_information_metadata_preview_image")); | ||
188 | gtk_image_set_from_file (image, fn); | 203 | gtk_image_set_from_file (image, fn); |
189 | preview_changed = GNUNET_YES; | 204 | preview_changed = GNUNET_YES; |
190 | } | 205 | } |
191 | 206 | ||
192 | 207 | ||
193 | void | 208 | void |
194 | GNUNET_GTK_edit_file_information_metadata_delete_button_clicked_cb() | 209 | GNUNET_GTK_edit_file_information_metadata_delete_button_clicked_cb () |
195 | { | 210 | { |
196 | GtkTreeView *tv; | 211 | GtkTreeView *tv; |
197 | GtkTreeSelection *sel; | 212 | GtkTreeSelection *sel; |
198 | GtkTreeModel *tm; | 213 | GtkTreeModel *tm; |
199 | GtkTreeIter iter; | 214 | GtkTreeIter iter; |
200 | 215 | ||
201 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 216 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
202 | "GNUNET_GTK_edit_file_information_metadata_tree_view")); | 217 | (builder, |
218 | "GNUNET_GTK_edit_file_information_metadata_tree_view")); | ||
203 | sel = gtk_tree_view_get_selection (tv); | 219 | sel = gtk_tree_view_get_selection (tv); |
204 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) | 220 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
205 | { | 221 | { |
206 | GNUNET_break (0); | 222 | GNUNET_break (0); |
207 | return; | 223 | return; |
208 | } | 224 | } |
209 | gtk_list_store_remove (GTK_LIST_STORE (tm), | 225 | gtk_list_store_remove (GTK_LIST_STORE (tm), &iter); |
210 | &iter); | ||
211 | } | 226 | } |
212 | 227 | ||
213 | 228 | ||
@@ -227,70 +242,63 @@ GNUNET_GTK_edit_file_information_metadata_add_button_clicked_cb () | |||
227 | size_t slen; | 242 | size_t slen; |
228 | char *pos; | 243 | char *pos; |
229 | 244 | ||
230 | entry = GTK_ENTRY (gtk_builder_get_object (builder, | 245 | entry = |
231 | "GNUNET_GTK_edit_file_information_metadata_value_entry")); | 246 | GTK_ENTRY (gtk_builder_get_object |
247 | (builder, | ||
248 | "GNUNET_GTK_edit_file_information_metadata_value_entry")); | ||
232 | value = gtk_entry_get_text (entry); | 249 | value = gtk_entry_get_text (entry); |
233 | if ((value == NULL) || (strlen (value) == 0)) | 250 | if ((value == NULL) || (strlen (value) == 0)) |
234 | { | 251 | { |
235 | GNUNET_break (0); | 252 | GNUNET_break (0); |
236 | return; | 253 | return; |
237 | } | 254 | } |
238 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 255 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
239 | "GNUNET_GTK_edit_file_information_metadata_type_tree_view")); | 256 | (builder, |
257 | "GNUNET_GTK_edit_file_information_metadata_type_tree_view")); | ||
240 | tm = gtk_tree_view_get_model (tv); | 258 | tm = gtk_tree_view_get_model (tv); |
241 | sel = gtk_tree_view_get_selection (tv); | 259 | sel = gtk_tree_view_get_selection (tv); |
242 | if (TRUE != gtk_tree_selection_get_selected (sel, | 260 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
243 | &tm, | 261 | { |
244 | &iter)) | 262 | GNUNET_break (0); |
263 | return; | ||
264 | } | ||
265 | gtk_tree_model_get (tm, &iter, 1, &type, -1); | ||
266 | ls = GTK_LIST_STORE (gtk_builder_get_object | ||
267 | (builder, "GNUNET_GTK_meta_data_list_store")); | ||
268 | if ((type == EXTRACTOR_METATYPE_FILENAME) && | ||
269 | (value[strlen (value) - 1] != '/') && (is_directory)) | ||
270 | { | ||
271 | GNUNET_asprintf (&avalue, "%s/", value); | ||
272 | /* if user typed '\' instead of '/', change it! */ | ||
273 | slen = strlen (avalue); | ||
274 | while ((slen > 1) && (avalue[slen - 2] == '\\')) | ||
245 | { | 275 | { |
246 | GNUNET_break (0); | 276 | avalue[slen - 2] = '/'; |
247 | return; | 277 | avalue[slen - 1] = '\0'; |
248 | } | 278 | slen--; |
249 | gtk_tree_model_get (tm, | ||
250 | &iter, | ||
251 | 1, &type, -1); | ||
252 | ls = GTK_LIST_STORE (gtk_builder_get_object (builder, | ||
253 | "GNUNET_GTK_meta_data_list_store")); | ||
254 | if ( (type == EXTRACTOR_METATYPE_FILENAME) && | ||
255 | (value[strlen(value)-1] != '/') && | ||
256 | (is_directory) ) | ||
257 | { | ||
258 | GNUNET_asprintf (&avalue, | ||
259 | "%s/", | ||
260 | value); | ||
261 | /* if user typed '\' instead of '/', change it! */ | ||
262 | slen = strlen (avalue); | ||
263 | while ( (slen > 1) && | ||
264 | (avalue[slen-2] == '\\') ) | ||
265 | { | ||
266 | avalue[slen-2] = '/'; | ||
267 | avalue[slen-1] = '\0'; | ||
268 | slen--; | ||
269 | } | ||
270 | while (NULL != (pos = strstr (avalue, "\\"))) | ||
271 | *pos = '/'; | ||
272 | /* remove '../' everywhere */ | ||
273 | while (NULL != (pos = strstr (avalue, "../"))) | ||
274 | { | ||
275 | pos[0] = '_'; | ||
276 | pos[1] = '_'; | ||
277 | pos[2] = '_'; | ||
278 | } | ||
279 | ivalue = avalue; | ||
280 | } | 279 | } |
281 | else | 280 | while (NULL != (pos = strstr (avalue, "\\"))) |
281 | *pos = '/'; | ||
282 | /* remove '../' everywhere */ | ||
283 | while (NULL != (pos = strstr (avalue, "../"))) | ||
282 | { | 284 | { |
283 | ivalue = value; | 285 | pos[0] = '_'; |
284 | avalue = NULL; | 286 | pos[1] = '_'; |
287 | pos[2] = '_'; | ||
285 | } | 288 | } |
286 | 289 | ivalue = avalue; | |
287 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, | 290 | } |
288 | 0, type, | 291 | else |
289 | 1, (guint) EXTRACTOR_METAFORMAT_UTF8, | 292 | { |
290 | 2, EXTRACTOR_metatype_to_string (type), | 293 | ivalue = value; |
291 | 3, ivalue, | 294 | avalue = NULL; |
292 | -1); | 295 | } |
293 | GNUNET_free_non_null (avalue); | 296 | |
297 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, 0, type, 1, | ||
298 | (guint) EXTRACTOR_METAFORMAT_UTF8, 2, | ||
299 | EXTRACTOR_metatype_to_string (type), 3, | ||
300 | ivalue, -1); | ||
301 | GNUNET_free_non_null (avalue); | ||
294 | gtk_entry_set_text (GTK_ENTRY (entry), ""); | 302 | gtk_entry_set_text (GTK_ENTRY (entry), ""); |
295 | } | 303 | } |
296 | 304 | ||
@@ -304,19 +312,14 @@ GNUNET_GTK_edit_file_information_metadata_add_button_clicked_cb () | |||
304 | * @return GNUNET_OK to continue to iterate | 312 | * @return GNUNET_OK to continue to iterate |
305 | */ | 313 | */ |
306 | static int | 314 | static int |
307 | add_keyword (void *cls, | 315 | add_keyword (void *cls, const char *keyword, int is_mandatory) |
308 | const char *keyword, | ||
309 | int is_mandatory) | ||
310 | { | 316 | { |
311 | GtkListStore *ls; | 317 | GtkListStore *ls; |
312 | GtkTreeIter iter; | 318 | GtkTreeIter iter; |
313 | 319 | ||
314 | ls = GTK_LIST_STORE (gtk_builder_get_object (builder, | 320 | ls = GTK_LIST_STORE (gtk_builder_get_object |
315 | "GNUNET_GTK_keyword_list_store")); | 321 | (builder, "GNUNET_GTK_keyword_list_store")); |
316 | gtk_list_store_insert_with_values (ls, &iter, | 322 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, 0, keyword, -1); |
317 | G_MAXINT, | ||
318 | 0, keyword, | ||
319 | -1); | ||
320 | return GNUNET_OK; | 323 | return GNUNET_OK; |
321 | } | 324 | } |
322 | 325 | ||
@@ -337,40 +340,33 @@ add_keyword (void *cls, | |||
337 | * @param data actual meta-data found | 340 | * @param data actual meta-data found |
338 | * @param data_len number of bytes in data | 341 | * @param data_len number of bytes in data |
339 | * @return 0 to continue extracting | 342 | * @return 0 to continue extracting |
340 | */ | 343 | */ |
341 | static int | 344 | static int |
342 | add_meta_item (void *cls, | 345 | add_meta_item (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, |
343 | const char *plugin_name, | 346 | enum EXTRACTOR_MetaFormat format, const char *data_mime_type, |
344 | enum EXTRACTOR_MetaType type, | 347 | const char *data, size_t data_len) |
345 | enum EXTRACTOR_MetaFormat format, | ||
346 | const char *data_mime_type, | ||
347 | const char *data, | ||
348 | size_t data_len) | ||
349 | { | 348 | { |
350 | GtkListStore *ls; | 349 | GtkListStore *ls; |
351 | GtkTreeIter iter; | 350 | GtkTreeIter iter; |
352 | 351 | ||
353 | switch (format) | 352 | switch (format) |
354 | { | 353 | { |
355 | case EXTRACTOR_METAFORMAT_UTF8: | 354 | case EXTRACTOR_METAFORMAT_UTF8: |
356 | case EXTRACTOR_METAFORMAT_C_STRING: | 355 | case EXTRACTOR_METAFORMAT_C_STRING: |
357 | ls = GTK_LIST_STORE (gtk_builder_get_object (builder, | 356 | ls = GTK_LIST_STORE (gtk_builder_get_object |
358 | "GNUNET_GTK_meta_data_list_store")); | 357 | (builder, "GNUNET_GTK_meta_data_list_store")); |
359 | gtk_list_store_insert_with_values (ls, &iter, | 358 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, 0, (guint) type, 1, |
360 | G_MAXINT, | 359 | (guint) format, 2, |
361 | 0, (guint) type, | 360 | EXTRACTOR_metatype_to_string (type), 3, |
362 | 1, (guint) format, | 361 | data, -1); |
363 | 2, EXTRACTOR_metatype_to_string (type), | 362 | break; |
364 | 3, data, | 363 | case EXTRACTOR_METAFORMAT_UNKNOWN: |
365 | -1); | 364 | break; |
366 | break; | 365 | case EXTRACTOR_METAFORMAT_BINARY: |
367 | case EXTRACTOR_METAFORMAT_UNKNOWN: | 366 | break; |
368 | break; | 367 | default: |
369 | case EXTRACTOR_METAFORMAT_BINARY: | 368 | GNUNET_break (0); |
370 | break; | 369 | } |
371 | default: | ||
372 | GNUNET_break (0); | ||
373 | } | ||
374 | return 0; | 370 | return 0; |
375 | } | 371 | } |
376 | 372 | ||
@@ -388,15 +384,13 @@ add_meta_item (void *cls, | |||
388 | * @param client_info pointer to client context set upon creation (can be modified) | 384 | * @param client_info pointer to client context set upon creation (can be modified) |
389 | * @return GNUNET_SYSERR (aborts after first call) | 385 | * @return GNUNET_SYSERR (aborts after first call) |
390 | */ | 386 | */ |
391 | static int | 387 | static int |
392 | file_information_extract (void *cls, | 388 | file_information_extract (void *cls, struct GNUNET_FS_FileInformation *fi, |
393 | struct GNUNET_FS_FileInformation *fi, | 389 | uint64_t length, |
394 | uint64_t length, | 390 | struct GNUNET_CONTAINER_MetaData *meta, |
395 | struct GNUNET_CONTAINER_MetaData *meta, | 391 | struct GNUNET_FS_Uri **uri, |
396 | struct GNUNET_FS_Uri **uri, | 392 | struct GNUNET_FS_BlockOptions *bo, int *do_index, |
397 | struct GNUNET_FS_BlockOptions *bo, | 393 | void **client_info) |
398 | int *do_index, | ||
399 | void **client_info) | ||
400 | { | 394 | { |
401 | GtkImage *img; | 395 | GtkImage *img; |
402 | GdkPixbuf *pixbuf; | 396 | GdkPixbuf *pixbuf; |
@@ -407,38 +401,45 @@ file_information_extract (void *cls, | |||
407 | if (NULL != *uri) | 401 | if (NULL != *uri) |
408 | GNUNET_FS_uri_ksk_get_keywords (*uri, &add_keyword, NULL); | 402 | GNUNET_FS_uri_ksk_get_keywords (*uri, &add_keyword, NULL); |
409 | if (NULL != meta) | 403 | if (NULL != meta) |
404 | { | ||
405 | GNUNET_CONTAINER_meta_data_iterate (meta, &add_meta_item, NULL); | ||
406 | pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta); | ||
407 | if (pixbuf != NULL) | ||
410 | { | 408 | { |
411 | GNUNET_CONTAINER_meta_data_iterate (meta, | 409 | img = |
412 | &add_meta_item, | 410 | GTK_IMAGE (gtk_builder_get_object |
413 | NULL); | 411 | (builder, |
414 | pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta); | 412 | "GNUNET_GTK_edit_file_information_metadata_preview_image")); |
415 | if (pixbuf != NULL) | 413 | gtk_image_set_from_pixbuf (img, pixbuf); |
416 | { | ||
417 | img = GTK_IMAGE (gtk_builder_get_object (builder, | ||
418 | "GNUNET_GTK_edit_file_information_metadata_preview_image")); | ||
419 | gtk_image_set_from_pixbuf (img, | ||
420 | pixbuf); | ||
421 | } | ||
422 | } | 414 | } |
423 | tp = bo->expiration_time.abs_value / 1000; /* ms to seconds */ | 415 | } |
416 | tp = bo->expiration_time.abs_value / 1000; /* ms to seconds */ | ||
424 | t = gmtime (&tp); | 417 | t = gmtime (&tp); |
425 | if (t == NULL) | 418 | if (t == NULL) |
426 | year = 0; | 419 | year = 0; |
427 | else | 420 | else |
428 | year = t->tm_year + 1900; | 421 | year = t->tm_year + 1900; |
429 | gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 422 | gtk_spin_button_set_value (GTK_SPIN_BUTTON |
430 | "GNUNET_GTK_edit_file_information_expiration_year_spin_button")), | 423 | (gtk_builder_get_object |
431 | year); | 424 | (builder, |
432 | gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 425 | "GNUNET_GTK_edit_file_information_expiration_year_spin_button")), |
433 | "GNUNET_GTK_edit_file_information_anonymity_spin_button")), | 426 | year); |
434 | bo->anonymity_level); | 427 | gtk_spin_button_set_value (GTK_SPIN_BUTTON |
435 | gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 428 | (gtk_builder_get_object |
436 | "GNUNET_GTK_edit_file_information_priority_spin_button")), | 429 | (builder, |
437 | bo->content_priority); | 430 | "GNUNET_GTK_edit_file_information_anonymity_spin_button")), |
438 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, | 431 | bo->anonymity_level); |
439 | "GNUNET_GTK_edit_file_information_index_check_button")), | 432 | gtk_spin_button_set_value (GTK_SPIN_BUTTON |
440 | *do_index); | 433 | (gtk_builder_get_object |
441 | return GNUNET_SYSERR; /* only visit top-level item */ | 434 | (builder, |
435 | "GNUNET_GTK_edit_file_information_priority_spin_button")), | ||
436 | bo->content_priority); | ||
437 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON | ||
438 | (gtk_builder_get_object | ||
439 | (builder, | ||
440 | "GNUNET_GTK_edit_file_information_index_check_button")), | ||
441 | *do_index); | ||
442 | return GNUNET_SYSERR; /* only visit top-level item */ | ||
442 | } | 443 | } |
443 | 444 | ||
444 | 445 | ||
@@ -458,70 +459,62 @@ file_information_extract (void *cls, | |||
458 | * @param data actual meta-data found | 459 | * @param data actual meta-data found |
459 | * @param data_len number of bytes in data | 460 | * @param data_len number of bytes in data |
460 | * @return 0 to continue extracting | 461 | * @return 0 to continue extracting |
461 | */ | 462 | */ |
462 | static int | 463 | static int |
463 | preserve_meta_items (void *cls, | 464 | preserve_meta_items (void *cls, const char *plugin_name, |
464 | const char *plugin_name, | 465 | enum EXTRACTOR_MetaType type, |
465 | enum EXTRACTOR_MetaType type, | 466 | enum EXTRACTOR_MetaFormat format, |
466 | enum EXTRACTOR_MetaFormat format, | 467 | const char *data_mime_type, const char *data, |
467 | const char *data_mime_type, | 468 | size_t data_len) |
468 | const char *data, | ||
469 | size_t data_len) | ||
470 | { | 469 | { |
471 | struct GNUNET_CONTAINER_MetaData *md = cls; | 470 | struct GNUNET_CONTAINER_MetaData *md = cls; |
472 | GtkTreeModel *tm; | 471 | GtkTreeModel *tm; |
473 | GtkTreeIter iter; | 472 | GtkTreeIter iter; |
474 | gchar *value; | 473 | gchar *value; |
475 | guint ntype; | 474 | guint ntype; |
476 | guint nformat; | 475 | guint nformat; |
477 | int keep; | 476 | int keep; |
478 | 477 | ||
479 | keep = GNUNET_NO; | 478 | keep = GNUNET_NO; |
480 | switch (format) | 479 | switch (format) |
480 | { | ||
481 | case EXTRACTOR_METAFORMAT_UTF8: | ||
482 | case EXTRACTOR_METAFORMAT_C_STRING: | ||
483 | tm = GTK_TREE_MODEL (gtk_builder_get_object | ||
484 | (builder, "GNUNET_GTK_meta_data_list_store")); | ||
485 | if (TRUE == gtk_tree_model_get_iter_first (tm, &iter)) | ||
481 | { | 486 | { |
482 | case EXTRACTOR_METAFORMAT_UTF8: | 487 | do |
483 | case EXTRACTOR_METAFORMAT_C_STRING: | 488 | { |
484 | tm = GTK_TREE_MODEL (gtk_builder_get_object (builder, | 489 | gtk_tree_model_get (tm, &iter, 0, &ntype, 1, &nformat, 3, &value, -1); |
485 | "GNUNET_GTK_meta_data_list_store")); | 490 | if ((ntype == type) && (nformat == format) && |
486 | if (TRUE == | 491 | (0 == strcmp (value, data))) |
487 | gtk_tree_model_get_iter_first (tm, &iter)) | 492 | { |
488 | { | 493 | gtk_list_store_remove (GTK_LIST_STORE (tm), &iter); |
489 | do | 494 | keep = GNUNET_YES; |
490 | { | 495 | g_free (value); |
491 | gtk_tree_model_get (tm, &iter, | 496 | break; |
492 | 0, &ntype, | 497 | } |
493 | 1, &nformat, | 498 | g_free (value); |
494 | 3, &value, | 499 | } |
495 | -1); | 500 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); |
496 | if ( (ntype == type) && | ||
497 | (nformat == format) && | ||
498 | (0 == strcmp (value, data)) ) | ||
499 | { | ||
500 | gtk_list_store_remove (GTK_LIST_STORE (tm), &iter); | ||
501 | keep = GNUNET_YES; | ||
502 | g_free (value); | ||
503 | break; | ||
504 | } | ||
505 | g_free (value); | ||
506 | } | ||
507 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | ||
508 | } | ||
509 | break; | ||
510 | case EXTRACTOR_METAFORMAT_UNKNOWN: | ||
511 | break; | ||
512 | case EXTRACTOR_METAFORMAT_BINARY: | ||
513 | if (preview_changed == GNUNET_NO) | ||
514 | keep = GNUNET_YES; | ||
515 | break; | ||
516 | default: | ||
517 | GNUNET_break (0); | ||
518 | break; | ||
519 | } | 501 | } |
502 | break; | ||
503 | case EXTRACTOR_METAFORMAT_UNKNOWN: | ||
504 | break; | ||
505 | case EXTRACTOR_METAFORMAT_BINARY: | ||
506 | if (preview_changed == GNUNET_NO) | ||
507 | keep = GNUNET_YES; | ||
508 | break; | ||
509 | default: | ||
510 | GNUNET_break (0); | ||
511 | break; | ||
512 | } | ||
520 | if (GNUNET_YES == keep) | 513 | if (GNUNET_YES == keep) |
521 | GNUNET_break (GNUNET_OK == | 514 | GNUNET_break (GNUNET_OK == |
522 | GNUNET_CONTAINER_meta_data_insert (md, | 515 | GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, |
523 | plugin_name, type, format, | 516 | format, data_mime_type, |
524 | data_mime_type, data, data_len)); | 517 | data, data_len)); |
525 | return 0; | 518 | return 0; |
526 | } | 519 | } |
527 | 520 | ||
@@ -539,15 +532,13 @@ preserve_meta_items (void *cls, | |||
539 | * @param client_info pointer to client context set upon creation (can be modified) | 532 | * @param client_info pointer to client context set upon creation (can be modified) |
540 | * @return GNUNET_SYSERR (aborts after first call) | 533 | * @return GNUNET_SYSERR (aborts after first call) |
541 | */ | 534 | */ |
542 | static int | 535 | static int |
543 | file_information_update (void *cls, | 536 | file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, |
544 | struct GNUNET_FS_FileInformation *fi, | 537 | uint64_t length, |
545 | uint64_t length, | 538 | struct GNUNET_CONTAINER_MetaData *meta, |
546 | struct GNUNET_CONTAINER_MetaData *meta, | 539 | struct GNUNET_FS_Uri **uri, |
547 | struct GNUNET_FS_Uri **uri, | 540 | struct GNUNET_FS_BlockOptions *bo, int *do_index, |
548 | struct GNUNET_FS_BlockOptions *bo, | 541 | void **client_info) |
549 | int *do_index, | ||
550 | void **client_info) | ||
551 | { | 542 | { |
552 | char **short_fn = cls; | 543 | char **short_fn = cls; |
553 | struct GNUNET_CONTAINER_MetaData *nm; | 544 | struct GNUNET_CONTAINER_MetaData *nm; |
@@ -556,7 +547,7 @@ file_information_update (void *cls, | |||
556 | struct GNUNET_FS_Uri *nxt; | 547 | struct GNUNET_FS_Uri *nxt; |
557 | struct GNUNET_FS_Uri *mrg; | 548 | struct GNUNET_FS_Uri *mrg; |
558 | gchar *value; | 549 | gchar *value; |
559 | guint ntype; | 550 | guint ntype; |
560 | guint nformat; | 551 | guint nformat; |
561 | GtkSpinButton *sb; | 552 | GtkSpinButton *sb; |
562 | gchar *fn; | 553 | gchar *fn; |
@@ -565,15 +556,25 @@ file_information_update (void *cls, | |||
565 | const char *mime; | 556 | const char *mime; |
566 | GFile *f; | 557 | GFile *f; |
567 | GFileInfo *finfo; | 558 | GFileInfo *finfo; |
568 | 559 | ||
569 | bo->anonymity_level = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 560 | bo->anonymity_level = |
570 | "GNUNET_GTK_edit_file_information_anonymity_spin_button"))); | 561 | gtk_spin_button_get_value (GTK_SPIN_BUTTON |
571 | bo->content_priority = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 562 | (gtk_builder_get_object |
572 | "GNUNET_GTK_edit_file_information_priority_spin_button"))); | 563 | (builder, |
573 | *do_index = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, | 564 | "GNUNET_GTK_edit_file_information_anonymity_spin_button"))); |
574 | "GNUNET_GTK_edit_file_information_index_check_button"))); | 565 | bo->content_priority = |
575 | sb =GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 566 | gtk_spin_button_get_value (GTK_SPIN_BUTTON |
576 | "GNUNET_GTK_edit_file_information_expiration_year_spin_button")); | 567 | (gtk_builder_get_object |
568 | (builder, | ||
569 | "GNUNET_GTK_edit_file_information_priority_spin_button"))); | ||
570 | *do_index = | ||
571 | gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON | ||
572 | (gtk_builder_get_object | ||
573 | (builder, | ||
574 | "GNUNET_GTK_edit_file_information_index_check_button"))); | ||
575 | sb = GTK_SPIN_BUTTON (gtk_builder_get_object | ||
576 | (builder, | ||
577 | "GNUNET_GTK_edit_file_information_expiration_year_spin_button")); | ||
577 | bo->expiration_time = GNUNET_FS_GTK_get_expiration_time (sb); | 578 | bo->expiration_time = GNUNET_FS_GTK_get_expiration_time (sb); |
578 | /* update URI */ | 579 | /* update URI */ |
579 | if (NULL != (*uri)) | 580 | if (NULL != (*uri)) |
@@ -581,95 +582,83 @@ file_information_update (void *cls, | |||
581 | *uri = NULL; | 582 | *uri = NULL; |
582 | nxt = NULL; | 583 | nxt = NULL; |
583 | mrg = NULL; | 584 | mrg = NULL; |
584 | 585 | ||
585 | tm = GTK_TREE_MODEL (gtk_builder_get_object (builder, | 586 | tm = GTK_TREE_MODEL (gtk_builder_get_object |
586 | "GNUNET_GTK_keyword_list_store")); | 587 | (builder, "GNUNET_GTK_keyword_list_store")); |
587 | if (TRUE == | 588 | if (TRUE == gtk_tree_model_get_iter_first (tm, &iter)) |
588 | gtk_tree_model_get_iter_first (tm, &iter)) | 589 | { |
590 | do | ||
589 | { | 591 | { |
590 | do | 592 | gtk_tree_model_get (tm, &iter, 0, &value, -1); |
591 | { | 593 | nxt = GNUNET_FS_uri_ksk_create_from_args (1, (const char **) &value); |
592 | gtk_tree_model_get (tm, &iter, | 594 | mrg = GNUNET_FS_uri_ksk_merge (nxt, *uri); |
593 | 0, &value, | 595 | GNUNET_FS_uri_destroy (nxt); |
594 | -1); | 596 | if (NULL != *uri) |
595 | nxt = GNUNET_FS_uri_ksk_create_from_args (1, (const char**) &value); | 597 | GNUNET_FS_uri_destroy (*uri); |
596 | mrg = GNUNET_FS_uri_ksk_merge (nxt, *uri); | 598 | *uri = mrg; |
597 | GNUNET_FS_uri_destroy (nxt); | 599 | g_free (value); |
598 | if (NULL != *uri) | ||
599 | GNUNET_FS_uri_destroy (*uri); | ||
600 | *uri = mrg; | ||
601 | g_free (value); | ||
602 | } | ||
603 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | ||
604 | } | 600 | } |
601 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | ||
602 | } | ||
605 | 603 | ||
606 | /* update meta */ | 604 | /* update meta */ |
607 | nm = GNUNET_CONTAINER_meta_data_create (); | 605 | nm = GNUNET_CONTAINER_meta_data_create (); |
608 | GNUNET_CONTAINER_meta_data_iterate (meta, | 606 | GNUNET_CONTAINER_meta_data_iterate (meta, &preserve_meta_items, nm); |
609 | &preserve_meta_items, | ||
610 | nm); | ||
611 | 607 | ||
612 | GNUNET_CONTAINER_meta_data_clear (meta); | 608 | GNUNET_CONTAINER_meta_data_clear (meta); |
613 | tm = GTK_TREE_MODEL (gtk_builder_get_object (builder, | 609 | tm = GTK_TREE_MODEL (gtk_builder_get_object |
614 | "GNUNET_GTK_meta_data_list_store")); | 610 | (builder, "GNUNET_GTK_meta_data_list_store")); |
615 | if (TRUE == | 611 | if (TRUE == gtk_tree_model_get_iter_first (tm, &iter)) |
616 | gtk_tree_model_get_iter_first (tm, &iter)) | 612 | { |
613 | do | ||
617 | { | 614 | { |
618 | do | 615 | gtk_tree_model_get (tm, &iter, 0, &ntype, 1, &nformat, 3, &value, -1); |
619 | { | 616 | GNUNET_CONTAINER_meta_data_insert (nm, "<user>", ntype, nformat, |
620 | gtk_tree_model_get (tm, &iter, | 617 | "text/plain", value, |
621 | 0, &ntype, | 618 | strlen (value) + 1); |
622 | 1, &nformat, | 619 | g_free (value); |
623 | 3, &value, | ||
624 | -1); | ||
625 | GNUNET_CONTAINER_meta_data_insert (nm, | ||
626 | "<user>", | ||
627 | ntype, | ||
628 | nformat, | ||
629 | "text/plain", | ||
630 | value, | ||
631 | strlen (value)+1); | ||
632 | g_free (value); | ||
633 | } | ||
634 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | ||
635 | } | 620 | } |
621 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | ||
622 | } | ||
636 | GNUNET_CONTAINER_meta_data_merge (meta, nm); | 623 | GNUNET_CONTAINER_meta_data_merge (meta, nm); |
637 | if (preview_changed == GNUNET_YES) | 624 | if (preview_changed == GNUNET_YES) |
625 | { | ||
626 | fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER | ||
627 | (gtk_builder_get_object | ||
628 | (builder, | ||
629 | "GNUNET_GTK_edit_file_information_metadata_preview_file_chooser_button"))); | ||
630 | f = g_file_new_for_path (fn); | ||
631 | finfo = | ||
632 | g_file_query_info (f, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, 0, NULL, | ||
633 | NULL); | ||
634 | if (FALSE == g_file_load_contents (f, NULL, &data, &data_size, NULL, NULL)) | ||
638 | { | 635 | { |
639 | fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (gtk_builder_get_object (builder, | 636 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
640 | "GNUNET_GTK_edit_file_information_metadata_preview_file_chooser_button"))); | 637 | _("Could not load preview `%s' into memory\n"), fn); |
641 | f = g_file_new_for_path (fn); | ||
642 | finfo = g_file_query_info (f, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, 0, NULL, NULL); | ||
643 | if (FALSE == g_file_load_contents (f, NULL, &data, &data_size, NULL, NULL)) | ||
644 | { | ||
645 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
646 | _("Could not load preview `%s' into memory\n"), | ||
647 | fn); | ||
648 | } | ||
649 | else | ||
650 | { | ||
651 | mime = g_file_info_get_attribute_string (finfo, | ||
652 | G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE); | ||
653 | GNUNET_CONTAINER_meta_data_insert (meta, | ||
654 | "<user>", | ||
655 | EXTRACTOR_METATYPE_THUMBNAIL, | ||
656 | EXTRACTOR_METAFORMAT_BINARY, | ||
657 | mime, | ||
658 | data, | ||
659 | data_size); | ||
660 | } | ||
661 | g_object_unref (finfo); | ||
662 | g_object_unref (f); | ||
663 | } | 638 | } |
639 | else | ||
640 | { | ||
641 | mime = | ||
642 | g_file_info_get_attribute_string (finfo, | ||
643 | G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE); | ||
644 | GNUNET_CONTAINER_meta_data_insert (meta, "<user>", | ||
645 | EXTRACTOR_METATYPE_THUMBNAIL, | ||
646 | EXTRACTOR_METAFORMAT_BINARY, mime, | ||
647 | data, data_size); | ||
648 | } | ||
649 | g_object_unref (finfo); | ||
650 | g_object_unref (f); | ||
651 | } | ||
664 | GNUNET_CONTAINER_meta_data_destroy (nm); | 652 | GNUNET_CONTAINER_meta_data_destroy (nm); |
665 | 653 | ||
666 | /* update short_fn */ | 654 | /* update short_fn */ |
667 | GNUNET_free_non_null (*short_fn); | 655 | GNUNET_free_non_null (*short_fn); |
668 | *short_fn = GNUNET_CONTAINER_meta_data_get_first_by_types (meta, | 656 | *short_fn = |
669 | EXTRACTOR_METATYPE_FILENAME, | 657 | GNUNET_CONTAINER_meta_data_get_first_by_types (meta, |
670 | -1); | 658 | EXTRACTOR_METATYPE_FILENAME, |
659 | -1); | ||
671 | /* FIXME: update expiration time? (not yet in dialog!) */ | 660 | /* FIXME: update expiration time? (not yet in dialog!) */ |
672 | return GNUNET_SYSERR; /* only visit top-level item */ | 661 | return GNUNET_SYSERR; /* only visit top-level item */ |
673 | } | 662 | } |
674 | 663 | ||
675 | 664 | ||
@@ -677,11 +666,9 @@ file_information_update (void *cls, | |||
677 | * Open the dialog to edit file information data. | 666 | * Open the dialog to edit file information data. |
678 | */ | 667 | */ |
679 | void | 668 | void |
680 | GNUNET_FS_GTK_edit_publish_dialog (int *do_index, | 669 | GNUNET_FS_GTK_edit_publish_dialog (int *do_index, char **short_fn, |
681 | char **short_fn, | 670 | guint * anonymity_level, guint * priority, |
682 | guint *anonymity_level, | 671 | struct GNUNET_FS_FileInformation *fip) |
683 | guint *priority, | ||
684 | struct GNUNET_FS_FileInformation *fip) | ||
685 | { | 672 | { |
686 | GtkWidget *ad; | 673 | GtkWidget *ad; |
687 | GtkListStore *ls; | 674 | GtkListStore *ls; |
@@ -692,77 +679,92 @@ GNUNET_FS_GTK_edit_publish_dialog (int *do_index, | |||
692 | GtkTreeSelection *sel; | 679 | GtkTreeSelection *sel; |
693 | 680 | ||
694 | GNUNET_assert (builder == NULL); | 681 | GNUNET_assert (builder == NULL); |
695 | builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_edit_dialog.glade"); | 682 | builder = |
683 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_edit_dialog.glade"); | ||
696 | if (builder == NULL) | 684 | if (builder == NULL) |
697 | { | 685 | { |
698 | GNUNET_break (0); | 686 | GNUNET_break (0); |
699 | return; | 687 | return; |
700 | } | 688 | } |
701 | preview_changed = GNUNET_NO; | 689 | preview_changed = GNUNET_NO; |
702 | GNUNET_FS_GTK_setup_expiration_year_adjustment (builder); | 690 | GNUNET_FS_GTK_setup_expiration_year_adjustment (builder); |
703 | if (GNUNET_FS_file_information_is_directory (fip)) | 691 | if (GNUNET_FS_file_information_is_directory (fip)) |
704 | { | 692 | { |
705 | /* indexing does not apply to directories */ | 693 | /* indexing does not apply to directories */ |
706 | gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (builder, | 694 | gtk_widget_hide (GTK_WIDGET |
707 | "GNUNET_GTK_edit_file_information_index_check_button"))); | 695 | (gtk_builder_get_object |
708 | gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (builder, | 696 | (builder, |
709 | "GNUNET_GTK_edit_file_information_index_label"))); | 697 | "GNUNET_GTK_edit_file_information_index_check_button"))); |
710 | 698 | gtk_widget_hide (GTK_WIDGET | |
711 | } | 699 | (gtk_builder_get_object |
712 | 700 | (builder, | |
713 | ad = GTK_WIDGET (gtk_builder_get_object (builder, | 701 | "GNUNET_GTK_edit_file_information_index_label"))); |
714 | "GNUNET_GTK_edit_file_information_dialog")); | 702 | |
715 | ls = GTK_LIST_STORE (gtk_builder_get_object (builder, | 703 | } |
716 | "GNUNET_GTK_metatype_list_store")); | 704 | |
705 | ad = GTK_WIDGET (gtk_builder_get_object | ||
706 | (builder, "GNUNET_GTK_edit_file_information_dialog")); | ||
707 | ls = GTK_LIST_STORE (gtk_builder_get_object | ||
708 | (builder, "GNUNET_GTK_metatype_list_store")); | ||
717 | max_type = EXTRACTOR_metatype_get_max (); | 709 | max_type = EXTRACTOR_metatype_get_max (); |
718 | type = 1; | 710 | type = 1; |
719 | while (type < max_type - 1) | 711 | while (type < max_type - 1) |
720 | { | 712 | { |
721 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, | 713 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, 0, |
722 | 0, EXTRACTOR_metatype_to_string (type), | 714 | EXTRACTOR_metatype_to_string (type), 1, |
723 | 1, type, | 715 | type, 2, |
724 | 2, EXTRACTOR_metatype_to_description (type), | 716 | EXTRACTOR_metatype_to_description (type), |
725 | -1); | 717 | -1); |
726 | type++; | 718 | type++; |
727 | } | 719 | } |
728 | 720 | ||
729 | GNUNET_FS_file_information_inspect (fip, | 721 | GNUNET_FS_file_information_inspect (fip, &file_information_extract, NULL); |
730 | &file_information_extract, | 722 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
731 | NULL); | 723 | (builder, |
732 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 724 | "GNUNET_GTK_edit_file_information_metadata_type_tree_view")); |
733 | "GNUNET_GTK_edit_file_information_metadata_type_tree_view")); | ||
734 | sel = gtk_tree_view_get_selection (tv); | 725 | sel = gtk_tree_view_get_selection (tv); |
735 | g_signal_connect(G_OBJECT(sel), "changed", | 726 | g_signal_connect (G_OBJECT (sel), "changed", |
736 | G_CALLBACK(GNUNET_GTK_edit_file_information_metadata_value_entry_changed_cb), NULL); | 727 | G_CALLBACK |
737 | 728 | (GNUNET_GTK_edit_file_information_metadata_value_entry_changed_cb), | |
738 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 729 | NULL); |
739 | "GNUNET_GTK_edit_file_information_metadata_tree_view")); | 730 | |
731 | tv = GTK_TREE_VIEW (gtk_builder_get_object | ||
732 | (builder, | ||
733 | "GNUNET_GTK_edit_file_information_metadata_tree_view")); | ||
740 | sel = gtk_tree_view_get_selection (tv); | 734 | sel = gtk_tree_view_get_selection (tv); |
741 | g_signal_connect(G_OBJECT(sel), "changed", | 735 | g_signal_connect (G_OBJECT (sel), "changed", |
742 | G_CALLBACK(metadata_selection_changed_cb), NULL); | 736 | G_CALLBACK (metadata_selection_changed_cb), NULL); |
743 | 737 | ||
744 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 738 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
745 | "GNUNET_GTK_edit_file_information_keyword_list_tree_view")); | 739 | (builder, |
740 | "GNUNET_GTK_edit_file_information_keyword_list_tree_view")); | ||
746 | sel = gtk_tree_view_get_selection (tv); | 741 | sel = gtk_tree_view_get_selection (tv); |
747 | g_signal_connect(G_OBJECT(sel), "changed", | 742 | g_signal_connect (G_OBJECT (sel), "changed", |
748 | G_CALLBACK(keyword_selection_changed_cb), NULL); | 743 | G_CALLBACK (keyword_selection_changed_cb), NULL); |
749 | gtk_window_set_title (GTK_WINDOW (ad), *short_fn); | 744 | gtk_window_set_title (GTK_WINDOW (ad), *short_fn); |
750 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) | 745 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) |
751 | { | 746 | { |
752 | gtk_widget_destroy (ad); | 747 | gtk_widget_destroy (ad); |
753 | g_object_unref (G_OBJECT (builder)); | 748 | g_object_unref (G_OBJECT (builder)); |
754 | builder = NULL; | 749 | builder = NULL; |
755 | return; | 750 | return; |
756 | } | 751 | } |
757 | GNUNET_FS_file_information_inspect (fip, | 752 | GNUNET_FS_file_information_inspect (fip, &file_information_update, short_fn); |
758 | &file_information_update, | 753 | *anonymity_level = |
759 | short_fn); | 754 | gtk_spin_button_get_value (GTK_SPIN_BUTTON |
760 | *anonymity_level = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 755 | (gtk_builder_get_object |
761 | "GNUNET_GTK_edit_file_information_anonymity_spin_button"))); | 756 | (builder, |
762 | *priority = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 757 | "GNUNET_GTK_edit_file_information_anonymity_spin_button"))); |
763 | "GNUNET_GTK_edit_file_information_priority_spin_button"))); | 758 | *priority = |
764 | *do_index = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, | 759 | gtk_spin_button_get_value (GTK_SPIN_BUTTON |
765 | "GNUNET_GTK_edit_file_information_index_check_button"))); | 760 | (gtk_builder_get_object |
761 | (builder, | ||
762 | "GNUNET_GTK_edit_file_information_priority_spin_button"))); | ||
763 | *do_index = | ||
764 | gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON | ||
765 | (gtk_builder_get_object | ||
766 | (builder, | ||
767 | "GNUNET_GTK_edit_file_information_index_check_button"))); | ||
766 | gtk_widget_destroy (ad); | 768 | gtk_widget_destroy (ad); |
767 | g_object_unref (G_OBJECT (builder)); | 769 | g_object_unref (G_OBJECT (builder)); |
768 | builder = NULL; | 770 | builder = NULL; |
diff --git a/src/fs/gnunet-fs-gtk-event_handler.c b/src/fs/gnunet-fs-gtk-event_handler.c index 3b53fca5..569462ed 100644 --- a/src/fs/gnunet-fs-gtk-event_handler.c +++ b/src/fs/gnunet-fs-gtk-event_handler.c | |||
@@ -66,19 +66,19 @@ struct PublishEntry | |||
66 | 66 | ||
67 | /** | 67 | /** |
68 | * Tab storing this entry. | 68 | * Tab storing this entry. |
69 | */ | 69 | */ |
70 | struct PublishTab *tab; | 70 | struct PublishTab *tab; |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * Where in the tab is this entry? | 73 | * Where in the tab is this entry? |
74 | */ | 74 | */ |
75 | GtkTreeRowReference *rr; | 75 | GtkTreeRowReference *rr; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * URI of the file (set after completion). | 78 | * URI of the file (set after completion). |
79 | */ | 79 | */ |
80 | struct GNUNET_FS_Uri *uri; | 80 | struct GNUNET_FS_Uri *uri; |
81 | 81 | ||
82 | int is_top; | 82 | int is_top; |
83 | }; | 83 | }; |
84 | 84 | ||
@@ -87,12 +87,12 @@ struct SearchResult | |||
87 | { | 87 | { |
88 | /** | 88 | /** |
89 | * Where in the tab is this result? | 89 | * Where in the tab is this result? |
90 | */ | 90 | */ |
91 | GtkTreeRowReference *rr; | 91 | GtkTreeRowReference *rr; |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Tab storing this result. | 94 | * Tab storing this result. |
95 | */ | 95 | */ |
96 | struct SearchTab *tab; | 96 | struct SearchTab *tab; |
97 | 97 | ||
98 | /** | 98 | /** |
@@ -115,59 +115,51 @@ static struct PublishTab *publish_tab_tail; | |||
115 | 115 | ||
116 | 116 | ||
117 | static struct DownloadEntry * | 117 | static struct DownloadEntry * |
118 | change_download_colour (struct DownloadEntry *de, | 118 | change_download_colour (struct DownloadEntry *de, const char *colour) |
119 | const char *colour) | ||
120 | { | 119 | { |
121 | GtkTreeIter iter; | 120 | GtkTreeIter iter; |
122 | GtkTreePath *path; | 121 | GtkTreePath *path; |
123 | 122 | ||
124 | path = gtk_tree_row_reference_get_path (de->rr); | 123 | path = gtk_tree_row_reference_get_path (de->rr); |
125 | if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (de->ts), | 124 | if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (de->ts), &iter, path)) |
126 | &iter, path)) | 125 | { |
127 | { | 126 | GNUNET_break (0); |
128 | GNUNET_break (0); | 127 | gtk_tree_path_free (path); |
129 | gtk_tree_path_free (path); | 128 | return de; |
130 | return de; | 129 | } |
131 | } | ||
132 | gtk_tree_path_free (path); | 130 | gtk_tree_path_free (path); |
133 | gtk_tree_store_set (de->ts, &iter, | 131 | gtk_tree_store_set (de->ts, &iter, 8, colour, -1); |
134 | 8, colour, | ||
135 | -1); | ||
136 | return de; | 132 | return de; |
137 | } | 133 | } |
138 | 134 | ||
139 | 135 | ||
140 | static struct PublishEntry * | 136 | static struct PublishEntry * |
141 | change_publish_colour (struct PublishEntry *pe, | 137 | change_publish_colour (struct PublishEntry *pe, const char *colour) |
142 | const char *colour) | ||
143 | { | 138 | { |
144 | GtkTreeIter iter; | 139 | GtkTreeIter iter; |
145 | GtkTreePath *path; | 140 | GtkTreePath *path; |
146 | 141 | ||
147 | if (pe == NULL) | 142 | if (pe == NULL) |
148 | { | 143 | { |
149 | GNUNET_break (0); | 144 | GNUNET_break (0); |
150 | return NULL; | 145 | return NULL; |
151 | } | 146 | } |
152 | path = gtk_tree_row_reference_get_path (pe->rr); | 147 | path = gtk_tree_row_reference_get_path (pe->rr); |
153 | if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (pe->tab->ts), | 148 | if (TRUE != |
154 | &iter, path)) | 149 | gtk_tree_model_get_iter (GTK_TREE_MODEL (pe->tab->ts), &iter, path)) |
155 | { | 150 | { |
156 | GNUNET_break (0); | 151 | GNUNET_break (0); |
157 | gtk_tree_path_free (path); | 152 | gtk_tree_path_free (path); |
158 | return pe; | 153 | return pe; |
159 | } | 154 | } |
160 | gtk_tree_path_free (path); | 155 | gtk_tree_path_free (path); |
161 | gtk_tree_store_set (pe->tab->ts, &iter, | 156 | gtk_tree_store_set (pe->tab->ts, &iter, 2, colour, -1); |
162 | 2, colour, | ||
163 | -1); | ||
164 | return pe; | 157 | return pe; |
165 | } | 158 | } |
166 | 159 | ||
167 | 160 | ||
168 | static void | 161 | static void |
169 | stop_download (struct DownloadEntry *de, | 162 | stop_download (struct DownloadEntry *de, int is_suspend) |
170 | int is_suspend) | ||
171 | { | 163 | { |
172 | change_download_colour (de, "white"); | 164 | change_download_colour (de, "white"); |
173 | gtk_tree_row_reference_free (de->rr); | 165 | gtk_tree_row_reference_free (de->rr); |
@@ -187,7 +179,7 @@ struct AddDirectoryEntryContext | |||
187 | 179 | ||
188 | /** | 180 | /** |
189 | * Row reference of parent (the directory). | 181 | * Row reference of parent (the directory). |
190 | */ | 182 | */ |
191 | GtkTreeRowReference *prr; | 183 | GtkTreeRowReference *prr; |
192 | 184 | ||
193 | int check_duplicates; | 185 | int check_duplicates; |
@@ -210,13 +202,11 @@ struct AddDirectoryEntryContext | |||
210 | * embedded with the directory itself). | 202 | * embedded with the directory itself). |
211 | * @param data data available for the file (length bytes) | 203 | * @param data data available for the file (length bytes) |
212 | */ | 204 | */ |
213 | static void | 205 | static void |
214 | add_directory_entry (void *cls, | 206 | add_directory_entry (void *cls, const char *filename, |
215 | const char *filename, | 207 | const struct GNUNET_FS_Uri *uri, |
216 | const struct GNUNET_FS_Uri *uri, | 208 | const struct GNUNET_CONTAINER_MetaData *meta, |
217 | const struct GNUNET_CONTAINER_MetaData *meta, | 209 | size_t length, const void *data) |
218 | size_t length, | ||
219 | const void *data) | ||
220 | { | 210 | { |
221 | struct AddDirectoryEntryContext *ade = cls; | 211 | struct AddDirectoryEntryContext *ade = cls; |
222 | GtkTreeIter iter; | 212 | GtkTreeIter iter; |
@@ -226,168 +216,144 @@ add_directory_entry (void *cls, | |||
226 | struct GNUNET_FS_Uri *xuri; | 216 | struct GNUNET_FS_Uri *xuri; |
227 | 217 | ||
228 | if (uri == NULL) | 218 | if (uri == NULL) |
219 | { | ||
220 | /* directory meta data itself */ | ||
221 | /* FIXME: consider merging it in... */ | ||
222 | return; | ||
223 | } | ||
224 | if (ade->check_duplicates == GNUNET_YES) | ||
225 | { | ||
226 | path = gtk_tree_row_reference_get_path (ade->prr); | ||
227 | tm = gtk_tree_row_reference_get_model (ade->prr); | ||
228 | if (TRUE != gtk_tree_model_get_iter (tm, &piter, path)) | ||
229 | { | 229 | { |
230 | /* directory meta data itself */ | 230 | GNUNET_break (0); |
231 | /* FIXME: consider merging it in... */ | 231 | gtk_tree_path_free (path); |
232 | return; | 232 | return; |
233 | } | 233 | } |
234 | if (ade->check_duplicates == GNUNET_YES) | 234 | gtk_tree_path_free (path); |
235 | if (TRUE == gtk_tree_model_iter_children (tm, &iter, &piter)) | ||
235 | { | 236 | { |
236 | path = gtk_tree_row_reference_get_path (ade->prr); | 237 | do |
237 | tm = gtk_tree_row_reference_get_model (ade->prr); | 238 | { |
238 | if (TRUE != gtk_tree_model_get_iter (tm, | 239 | gtk_tree_model_get (tm, &iter, 1, &xuri, -1); |
239 | &piter, path)) | 240 | if (GNUNET_YES == GNUNET_FS_uri_test_equal (xuri, uri)) |
240 | { | 241 | return; /* already present */ |
241 | GNUNET_break (0); | 242 | } |
242 | gtk_tree_path_free (path); | 243 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); |
243 | return; | ||
244 | } | ||
245 | gtk_tree_path_free (path); | ||
246 | if (TRUE == gtk_tree_model_iter_children (tm, | ||
247 | &iter, | ||
248 | &piter)) | ||
249 | { | ||
250 | do | ||
251 | { | ||
252 | gtk_tree_model_get (tm, | ||
253 | &iter, | ||
254 | 1, &xuri, | ||
255 | -1); | ||
256 | if (GNUNET_YES == | ||
257 | GNUNET_FS_uri_test_equal (xuri, uri)) | ||
258 | return; /* already present */ | ||
259 | } | ||
260 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | ||
261 | } | ||
262 | } | 244 | } |
263 | GNUNET_GTK_add_search_result (ade->de->tab, | 245 | } |
264 | &iter, | 246 | GNUNET_GTK_add_search_result (ade->de->tab, &iter, ade->prr, uri, meta, NULL, |
265 | ade->prr, | 247 | 0); |
266 | uri, | ||
267 | meta, | ||
268 | NULL, | ||
269 | 0); | ||
270 | } | 248 | } |
271 | 249 | ||
272 | 250 | ||
273 | static struct DownloadEntry * | 251 | static struct DownloadEntry * |
274 | mark_download_progress (struct DownloadEntry *de, | 252 | mark_download_progress (struct DownloadEntry *de, uint64_t size, |
275 | uint64_t size, | 253 | uint64_t completed, const void *block_data, |
276 | uint64_t completed, | 254 | uint64_t offset, uint64_t block_size, |
277 | const void *block_data, | 255 | unsigned int depth) |
278 | uint64_t offset, | ||
279 | uint64_t block_size, | ||
280 | unsigned int depth) | ||
281 | { | 256 | { |
282 | struct AddDirectoryEntryContext ade; | 257 | struct AddDirectoryEntryContext ade; |
283 | GtkTreeIter iter; | 258 | GtkTreeIter iter; |
284 | GtkTreePath *path; | 259 | GtkTreePath *path; |
285 | 260 | ||
286 | path = gtk_tree_row_reference_get_path (de->rr); | 261 | path = gtk_tree_row_reference_get_path (de->rr); |
287 | if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (de->ts), | 262 | if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (de->ts), &iter, path)) |
288 | &iter, path)) | 263 | { |
289 | { | 264 | GNUNET_break (0); |
290 | GNUNET_break (0); | 265 | gtk_tree_path_free (path); |
291 | gtk_tree_path_free (path); | 266 | return de; |
292 | return de; | 267 | } |
293 | } | ||
294 | gtk_tree_path_free (path); | 268 | gtk_tree_path_free (path); |
295 | gtk_tree_store_set (de->ts, &iter, | 269 | gtk_tree_store_set (de->ts, &iter, 4, |
296 | 4, (guint) ((size > 0) ? (100 * completed / size) : 100) /* progress */, | 270 | (guint) ((size > |
297 | -1); | 271 | 0) ? (100 * completed / |
298 | if ( (depth == 0) && | 272 | size) : 100) /* progress */ , |
299 | (block_size > 0) && | 273 | -1); |
300 | (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (de->meta)) ) | 274 | if ((depth == 0) && (block_size > 0) && |
275 | (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (de->meta))) | ||
276 | { | ||
277 | ade.de = de; | ||
278 | ade.prr = de->rr; | ||
279 | ade.check_duplicates = GNUNET_NO; | ||
280 | if (GNUNET_SYSERR == | ||
281 | GNUNET_FS_directory_list_contents ((size_t) block_size, block_data, | ||
282 | offset, &add_directory_entry, &ade)) | ||
301 | { | 283 | { |
302 | ade.de = de; | 284 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
303 | ade.prr = de->rr; | 285 | _ |
304 | ade.check_duplicates = GNUNET_NO; | 286 | ("Metadata wrongly claims that this is a GNUnet directory!\n")); |
305 | if (GNUNET_SYSERR == | ||
306 | GNUNET_FS_directory_list_contents ((size_t) block_size, | ||
307 | block_data, | ||
308 | offset, | ||
309 | &add_directory_entry, | ||
310 | &ade)) | ||
311 | { | ||
312 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
313 | _("Metadata wrongly claims that this is a GNUnet directory!\n")); | ||
314 | } | ||
315 | } | 287 | } |
288 | } | ||
316 | return de; | 289 | return de; |
317 | } | 290 | } |
318 | 291 | ||
319 | 292 | ||
320 | static struct DownloadEntry * | 293 | static struct DownloadEntry * |
321 | mark_download_error (struct DownloadEntry *de, | 294 | mark_download_error (struct DownloadEntry *de, const char *emsg) |
322 | const char *emsg) | ||
323 | { | 295 | { |
324 | GtkTreeIter iter; | 296 | GtkTreeIter iter; |
325 | GtkTreePath *path; | 297 | GtkTreePath *path; |
326 | 298 | ||
327 | de = change_download_colour (de, | 299 | de = change_download_colour (de, "red"); |
328 | "red"); | 300 | de->is_done = GNUNET_YES; |
329 | de->is_done = GNUNET_YES; | ||
330 | path = gtk_tree_row_reference_get_path (de->rr); | 301 | path = gtk_tree_row_reference_get_path (de->rr); |
331 | if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (de->tab->ts), | 302 | if (TRUE != |
332 | &iter, path)) | 303 | gtk_tree_model_get_iter (GTK_TREE_MODEL (de->tab->ts), &iter, path)) |
333 | { | 304 | { |
334 | GNUNET_break (0); | 305 | GNUNET_break (0); |
335 | gtk_tree_path_free (path); | 306 | gtk_tree_path_free (path); |
336 | return de; | 307 | return de; |
337 | } | 308 | } |
338 | gtk_tree_path_free (path); | 309 | gtk_tree_path_free (path); |
339 | gtk_tree_store_set (de->tab->ts, &iter, | 310 | gtk_tree_store_set (de->tab->ts, &iter, 4, 0, 7, emsg, -1); |
340 | 4, 0, | ||
341 | 7, emsg, | ||
342 | -1); | ||
343 | return de; | 311 | return de; |
344 | } | 312 | } |
345 | 313 | ||
346 | 314 | ||
347 | static struct DownloadEntry * | 315 | static struct DownloadEntry * |
348 | mark_download_completed (struct DownloadEntry *de, | 316 | mark_download_completed (struct DownloadEntry *de, uint64_t size, |
349 | uint64_t size, | 317 | const char *filename) |
350 | const char *filename) | ||
351 | { | 318 | { |
352 | struct AddDirectoryEntryContext ade; | 319 | struct AddDirectoryEntryContext ade; |
353 | 320 | ||
354 | de->is_done = GNUNET_YES; | 321 | de->is_done = GNUNET_YES; |
355 | (void) mark_download_progress (de, size, size, NULL, 0, 0, 0); | 322 | (void) mark_download_progress (de, size, size, NULL, 0, 0, 0); |
356 | if ( (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (de->meta)) && | 323 | if ((GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (de->meta)) && |
357 | (filename != NULL) ) | 324 | (filename != NULL)) |
358 | { | 325 | { |
359 | ade.de = de; | 326 | ade.de = de; |
360 | ade.prr = de->rr; | 327 | ade.prr = de->rr; |
361 | ade.check_duplicates = GNUNET_NO; | 328 | ade.check_duplicates = GNUNET_NO; |
362 | GNUNET_FS_GTK_mmap_and_scan (filename, | 329 | GNUNET_FS_GTK_mmap_and_scan (filename, &add_directory_entry, &ade); |
363 | &add_directory_entry, | 330 | } |
364 | &ade); | ||
365 | } | ||
366 | (void) change_download_colour (de, "green"); | 331 | (void) change_download_colour (de, "green"); |
367 | return de; | 332 | return de; |
368 | } | 333 | } |
369 | 334 | ||
370 | 335 | ||
371 | static struct PublishEntry * | 336 | static struct PublishEntry * |
372 | mark_publish_progress (struct PublishEntry *pe, | 337 | mark_publish_progress (struct PublishEntry *pe, uint64_t size, |
373 | uint64_t size, | 338 | uint64_t completed) |
374 | uint64_t completed) | ||
375 | { | 339 | { |
376 | GtkTreeIter iter; | 340 | GtkTreeIter iter; |
377 | GtkTreePath *path; | 341 | GtkTreePath *path; |
378 | 342 | ||
379 | path = gtk_tree_row_reference_get_path (pe->rr); | 343 | path = gtk_tree_row_reference_get_path (pe->rr); |
380 | if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (pe->tab->ts), | 344 | if (TRUE != |
381 | &iter, path)) | 345 | gtk_tree_model_get_iter (GTK_TREE_MODEL (pe->tab->ts), &iter, path)) |
382 | { | 346 | { |
383 | GNUNET_break (0); | 347 | GNUNET_break (0); |
384 | gtk_tree_path_free (path); | 348 | gtk_tree_path_free (path); |
385 | return pe; | 349 | return pe; |
386 | } | 350 | } |
387 | gtk_tree_path_free (path); | 351 | gtk_tree_path_free (path); |
388 | gtk_tree_store_set (pe->tab->ts, &iter, | 352 | gtk_tree_store_set (pe->tab->ts, &iter, 3, |
389 | 3, (guint) ((size > 0) ? (100 * completed / size) : 100) /* progress */, | 353 | (guint) ((size > |
390 | -1); | 354 | 0) ? (100 * completed / |
355 | size) : 100) /* progress */ , | ||
356 | -1); | ||
391 | return pe; | 357 | return pe; |
392 | } | 358 | } |
393 | 359 | ||
@@ -403,10 +369,8 @@ mark_publish_progress (struct PublishEntry *pe, | |||
403 | * to refer to the new model. | 369 | * to refer to the new model. |
404 | */ | 370 | */ |
405 | static void | 371 | static void |
406 | move_children (GtkTreeModel *src_model, | 372 | move_children (GtkTreeModel * src_model, GtkTreeIter * src_iter, |
407 | GtkTreeIter *src_iter, | 373 | GtkTreeModel * dst_model, GtkTreeIter * dst_iter) |
408 | GtkTreeModel *dst_model, | ||
409 | GtkTreeIter *dst_iter) | ||
410 | { | 374 | { |
411 | GtkTreeIter src_child; | 375 | GtkTreeIter src_child; |
412 | GtkTreeIter dst_child; | 376 | GtkTreeIter dst_child; |
@@ -424,76 +388,49 @@ move_children (GtkTreeModel *src_model, | |||
424 | gchar *mimetype; | 388 | gchar *mimetype; |
425 | guint applicability_rank; | 389 | guint applicability_rank; |
426 | guint availability_certainty; | 390 | guint availability_certainty; |
427 | gint availability_rank; | 391 | gint availability_rank; |
428 | 392 | ||
429 | if (TRUE == gtk_tree_model_iter_children (src_model, | 393 | if (TRUE == gtk_tree_model_iter_children (src_model, &src_child, src_iter)) |
430 | &src_child, | 394 | { |
431 | src_iter)) | 395 | do |
432 | { | 396 | { |
433 | do | 397 | gtk_tree_model_get (src_model, &src_child, 0, &meta, 1, &uri, 2, |
434 | { | 398 | &filesize, 3, &preview, 4, &percent_progress, 5, |
435 | gtk_tree_model_get (src_model, | 399 | &percent_availability, 6, &filename, 7, |
436 | &src_child, | 400 | &uri_as_string, 8, &status_colour, 9, &search_result, |
437 | 0, &meta, | 401 | 10, &mimetype, 11, &applicability_rank, 12, |
438 | 1, &uri, | 402 | &availability_certainty, 13, &availability_rank, -1); |
439 | 2, &filesize, | 403 | gtk_tree_store_insert_with_values (GTK_TREE_STORE (dst_model), &dst_child, |
440 | 3, &preview, | 404 | dst_iter, G_MAXINT, 0, meta, 1, uri, 2, |
441 | 4, &percent_progress, | 405 | filesize, 3, preview, 4, |
442 | 5, &percent_availability, | 406 | percent_progress, 5, |
443 | 6, &filename, | 407 | percent_availability, 6, filename, 7, |
444 | 7, &uri_as_string, | 408 | uri_as_string, 8, status_colour, 9, |
445 | 8, &status_colour, | 409 | search_result, 10, mimetype, 11, |
446 | 9, &search_result, | 410 | applicability_rank, 12, |
447 | 10, &mimetype, | 411 | availability_certainty, 13, |
448 | 11, &applicability_rank, | 412 | availability_rank, -1); |
449 | 12, &availability_certainty, | 413 | g_free (filename); |
450 | 13, &availability_rank, | 414 | g_free (uri_as_string); |
451 | -1); | 415 | g_free (status_colour); |
452 | gtk_tree_store_insert_with_values (GTK_TREE_STORE (dst_model), | 416 | g_free (mimetype); |
453 | &dst_child, | 417 | if (preview != NULL) |
454 | dst_iter, | 418 | g_object_unref (preview); |
455 | G_MAXINT, | 419 | gtk_tree_row_reference_free (search_result->rr); |
456 | 0, meta, | 420 | path = gtk_tree_model_get_path (dst_model, &dst_child); |
457 | 1, uri, | 421 | search_result->rr = gtk_tree_row_reference_new (dst_model, path); |
458 | 2, filesize, | 422 | gtk_tree_path_free (path); |
459 | 3, preview, | 423 | if (search_result->download != NULL) |
460 | 4, percent_progress, | 424 | { |
461 | 5, percent_availability, | 425 | search_result->download->ts = GTK_TREE_STORE (dst_model); |
462 | 6, filename, | 426 | gtk_tree_row_reference_free (search_result->download->rr); |
463 | 7, uri_as_string, | 427 | search_result->download->rr = |
464 | 8, status_colour, | 428 | gtk_tree_row_reference_copy (search_result->rr); |
465 | 9, search_result, | 429 | } |
466 | 10, mimetype, | 430 | move_children (src_model, &src_child, dst_model, &dst_child); |
467 | 11, applicability_rank, | ||
468 | 12, availability_certainty, | ||
469 | 13, availability_rank, | ||
470 | -1); | ||
471 | g_free (filename); | ||
472 | g_free (uri_as_string); | ||
473 | g_free (status_colour); | ||
474 | g_free (mimetype); | ||
475 | if (preview != NULL) | ||
476 | g_object_unref (preview); | ||
477 | gtk_tree_row_reference_free (search_result->rr); | ||
478 | path = gtk_tree_model_get_path (dst_model, | ||
479 | &dst_child); | ||
480 | search_result->rr = gtk_tree_row_reference_new (dst_model, | ||
481 | path); | ||
482 | gtk_tree_path_free (path); | ||
483 | if (search_result->download != NULL) | ||
484 | { | ||
485 | search_result->download->ts = GTK_TREE_STORE (dst_model); | ||
486 | gtk_tree_row_reference_free (search_result->download->rr); | ||
487 | search_result->download->rr = gtk_tree_row_reference_copy (search_result->rr); | ||
488 | } | ||
489 | move_children (src_model, | ||
490 | &src_child, | ||
491 | dst_model, | ||
492 | &dst_child); | ||
493 | } | ||
494 | while (TRUE == gtk_tree_model_iter_next (src_model, | ||
495 | &src_child)); | ||
496 | } | 431 | } |
432 | while (TRUE == gtk_tree_model_iter_next (src_model, &src_child)); | ||
433 | } | ||
497 | } | 434 | } |
498 | 435 | ||
499 | 436 | ||
@@ -503,17 +440,13 @@ move_children (GtkTreeModel *src_model, | |||
503 | * model's fields (since they have been moved). | 440 | * model's fields (since they have been moved). |
504 | */ | 441 | */ |
505 | static void | 442 | static void |
506 | delete_stale_subtree (GtkTreeModel *model, | 443 | delete_stale_subtree (GtkTreeModel * model, GtkTreeIter * iter) |
507 | GtkTreeIter *iter) | ||
508 | { | 444 | { |
509 | GtkTreeIter child; | 445 | GtkTreeIter child; |
510 | 446 | ||
511 | while (TRUE == gtk_tree_model_iter_children (model, | 447 | while (TRUE == gtk_tree_model_iter_children (model, &child, iter)) |
512 | &child, | ||
513 | iter)) | ||
514 | delete_stale_subtree (model, &child); | 448 | delete_stale_subtree (model, &child); |
515 | gtk_tree_store_remove (GTK_TREE_STORE (model), | 449 | gtk_tree_store_remove (GTK_TREE_STORE (model), iter); |
516 | iter); | ||
517 | } | 450 | } |
518 | 451 | ||
519 | 452 | ||
@@ -522,10 +455,8 @@ delete_stale_subtree (GtkTreeModel *model, | |||
522 | * search parent by moving it to the URI tab. | 455 | * search parent by moving it to the URI tab. |
523 | */ | 456 | */ |
524 | static struct DownloadEntry * | 457 | static struct DownloadEntry * |
525 | download_lost_parent (struct DownloadEntry *de, | 458 | download_lost_parent (struct DownloadEntry *de, uint64_t size, |
526 | uint64_t size, | 459 | uint64_t completed, int is_active) |
527 | uint64_t completed, | ||
528 | int is_active) | ||
529 | { | 460 | { |
530 | GtkTreeIter iter; | 461 | GtkTreeIter iter; |
531 | GtkTreePath *path; | 462 | GtkTreePath *path; |
@@ -536,42 +467,30 @@ download_lost_parent (struct DownloadEntry *de, | |||
536 | 467 | ||
537 | rr_old = de->rr; | 468 | rr_old = de->rr; |
538 | de->sr = NULL; | 469 | de->sr = NULL; |
539 | tab = GNUNET_GTK_add_to_uri_tab (&iter, | 470 | tab = GNUNET_GTK_add_to_uri_tab (&iter, NULL, de->meta, de->uri); |
540 | NULL, | ||
541 | de->meta, | ||
542 | de->uri); | ||
543 | de->ts = tab->ts; | 471 | de->ts = tab->ts; |
544 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (de->ts), | 472 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (de->ts), &iter); |
545 | &iter); | 473 | de->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (de->ts), path); |
546 | de->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (de->ts), | ||
547 | path); | ||
548 | gtk_tree_path_free (path); | 474 | gtk_tree_path_free (path); |
549 | mark_download_progress (de, size, completed, | 475 | mark_download_progress (de, size, completed, NULL, 0, 0, 0); |
550 | NULL, 0, 0, 0); | ||
551 | tm_old = gtk_tree_row_reference_get_model (rr_old); | 476 | tm_old = gtk_tree_row_reference_get_model (rr_old); |
552 | path = gtk_tree_row_reference_get_path (rr_old); | 477 | path = gtk_tree_row_reference_get_path (rr_old); |
553 | gtk_tree_row_reference_free (rr_old); | 478 | gtk_tree_row_reference_free (rr_old); |
554 | gtk_tree_model_get_iter (tm_old, | 479 | gtk_tree_model_get_iter (tm_old, &iter_old, path); |
555 | &iter_old, | ||
556 | path); | ||
557 | gtk_tree_path_free (path); | 480 | gtk_tree_path_free (path); |
558 | move_children (tm_old, | 481 | move_children (tm_old, &iter_old, GTK_TREE_MODEL (de->ts), &iter); |
559 | &iter_old, | 482 | delete_stale_subtree (tm_old, &iter_old); |
560 | GTK_TREE_MODEL (de->ts), | ||
561 | &iter); | ||
562 | delete_stale_subtree (tm_old, | ||
563 | &iter_old); | ||
564 | if (size > completed) | 483 | if (size > completed) |
565 | { | 484 | { |
566 | if (is_active) | 485 | if (is_active) |
567 | change_download_colour (de, "yellow"); | 486 | change_download_colour (de, "yellow"); |
568 | else | 487 | else |
569 | change_download_colour (de, "blue"); | 488 | change_download_colour (de, "blue"); |
570 | } | 489 | } |
571 | else | 490 | else |
572 | { | 491 | { |
573 | change_download_colour (de, "green"); | 492 | change_download_colour (de, "green"); |
574 | } | 493 | } |
575 | return de; | 494 | return de; |
576 | } | 495 | } |
577 | 496 | ||
@@ -589,63 +508,55 @@ download_lost_parent (struct DownloadEntry *de, | |||
589 | * @param completed current progress | 508 | * @param completed current progress |
590 | */ | 509 | */ |
591 | static struct DownloadEntry * | 510 | static struct DownloadEntry * |
592 | setup_download (struct DownloadEntry *de, | 511 | setup_download (struct DownloadEntry *de, struct DownloadEntry *pde, |
593 | struct DownloadEntry *pde, | 512 | struct SearchResult *sr, struct GNUNET_FS_DownloadContext *dc, |
594 | struct SearchResult *sr, | 513 | const struct GNUNET_FS_Uri *uri, |
595 | struct GNUNET_FS_DownloadContext *dc, | 514 | const struct GNUNET_CONTAINER_MetaData *meta, uint64_t size, |
596 | const struct GNUNET_FS_Uri *uri, | 515 | uint64_t completed) |
597 | const struct GNUNET_CONTAINER_MetaData *meta, | ||
598 | uint64_t size, | ||
599 | uint64_t completed) | ||
600 | { | 516 | { |
601 | GtkTreeIter iter; | 517 | GtkTreeIter iter; |
602 | GtkTreePath *path; | 518 | GtkTreePath *path; |
603 | 519 | ||
604 | if (de == NULL) | 520 | if (de == NULL) |
605 | { | 521 | { |
606 | de = GNUNET_malloc (sizeof (struct DownloadEntry)); | 522 | de = GNUNET_malloc (sizeof (struct DownloadEntry)); |
607 | GNUNET_assert (sr->download == NULL); | 523 | GNUNET_assert (sr->download == NULL); |
608 | sr->download = de; | 524 | sr->download = de; |
609 | de->sr = sr; | 525 | de->sr = sr; |
610 | de->dc = dc; | 526 | de->dc = dc; |
611 | de->uri = GNUNET_FS_uri_dup (uri); | 527 | de->uri = GNUNET_FS_uri_dup (uri); |
612 | } | 528 | } |
613 | de->pde = pde; | 529 | de->pde = pde; |
614 | if ( (meta != NULL) && | 530 | if ((meta != NULL) && (de->meta == NULL)) |
615 | (de->meta == NULL) ) | ||
616 | de->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); | 531 | de->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); |
617 | if (sr != NULL) | 532 | if (sr != NULL) |
618 | { | 533 | { |
619 | de->rr = gtk_tree_row_reference_copy (sr->rr); | 534 | de->rr = gtk_tree_row_reference_copy (sr->rr); |
620 | de->ts = sr->tab->ts; | 535 | de->ts = sr->tab->ts; |
621 | de->tab = sr->tab; | 536 | de->tab = sr->tab; |
622 | } | 537 | } |
623 | else if (de->rr == NULL) | 538 | else if (de->rr == NULL) |
624 | { | 539 | { |
625 | de->tab = GNUNET_GTK_add_to_uri_tab (&iter, | 540 | de->tab = GNUNET_GTK_add_to_uri_tab (&iter, NULL, meta, uri); |
626 | NULL, | 541 | de->ts = de->tab->ts; |
627 | meta, | 542 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (de->ts), &iter); |
628 | uri); | 543 | de->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (de->ts), path); |
629 | de->ts = de->tab->ts; | 544 | gtk_tree_path_free (path); |
630 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (de->ts), | 545 | } |
631 | &iter); | ||
632 | de->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (de->ts), | ||
633 | path); | ||
634 | gtk_tree_path_free (path); | ||
635 | } | ||
636 | path = gtk_tree_row_reference_get_path (de->rr); | 546 | path = gtk_tree_row_reference_get_path (de->rr); |
637 | if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (de->ts), | 547 | if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (de->ts), &iter, path)) |
638 | &iter, path)) | 548 | { |
639 | { | 549 | GNUNET_break (0); |
640 | GNUNET_break (0); | 550 | gtk_tree_path_free (path); |
641 | gtk_tree_path_free (path); | 551 | return de; |
642 | return de; | 552 | } |
643 | } | ||
644 | gtk_tree_path_free (path); | 553 | gtk_tree_path_free (path); |
645 | gtk_tree_store_set (de->ts, &iter, | 554 | gtk_tree_store_set (de->ts, &iter, 4, |
646 | 4, (guint) ((size > 0) ? (100 * completed / size) : 100) /* progress */, | 555 | (guint) ((size > |
647 | 8, "blue" /* status colour: pending */, | 556 | 0) ? (100 * completed / |
648 | -1); | 557 | size) : 100) /* progress */ , |
558 | 8, "blue" /* status colour: pending */ , | ||
559 | -1); | ||
649 | return de; | 560 | return de; |
650 | } | 561 | } |
651 | 562 | ||
@@ -655,10 +566,8 @@ setup_download (struct DownloadEntry *de, | |||
655 | * "save as" window. | 566 | * "save as" window. |
656 | */ | 567 | */ |
657 | static void | 568 | static void |
658 | start_download (GtkTreeView *tree_view, | 569 | start_download (GtkTreeView * tree_view, GtkTreePath * path, |
659 | GtkTreePath *path, | 570 | GtkTreeViewColumn * column, gpointer user_data) |
660 | GtkTreeViewColumn *column, | ||
661 | gpointer user_data) | ||
662 | { | 571 | { |
663 | struct SearchTab *tab = user_data; | 572 | struct SearchTab *tab = user_data; |
664 | GtkTreeModel *tm; | 573 | GtkTreeModel *tm; |
@@ -672,16 +581,11 @@ start_download (GtkTreeView *tree_view, | |||
672 | GNUNET_assert (tab != NULL); | 581 | GNUNET_assert (tab != NULL); |
673 | tm = gtk_tree_view_get_model (tree_view); | 582 | tm = gtk_tree_view_get_model (tree_view); |
674 | if (TRUE != gtk_tree_model_get_iter (tm, &iter, path)) | 583 | if (TRUE != gtk_tree_model_get_iter (tm, &iter, path)) |
675 | { | 584 | { |
676 | GNUNET_break (0); | 585 | GNUNET_break (0); |
677 | return; | 586 | return; |
678 | } | 587 | } |
679 | gtk_tree_model_get (tm, &iter, | 588 | gtk_tree_model_get (tm, &iter, 0, &meta, 1, &uri, 9, &sr, 10, &mime, -1); |
680 | 0, &meta, | ||
681 | 1, &uri, | ||
682 | 9, &sr, | ||
683 | 10, &mime, | ||
684 | -1); | ||
685 | dlc = GNUNET_malloc (sizeof (struct DownloadContext)); | 589 | dlc = GNUNET_malloc (sizeof (struct DownloadContext)); |
686 | dlc->uri = GNUNET_FS_uri_dup (uri); | 590 | dlc->uri = GNUNET_FS_uri_dup (uri); |
687 | dlc->mime = (NULL != mime) ? GNUNET_strdup (mime) : NULL; | 591 | dlc->mime = (NULL != mime) ? GNUNET_strdup (mime) : NULL; |
@@ -710,23 +614,22 @@ static struct SearchTab *current_context_search_tab; | |||
710 | * Download was selected in the current search context menu. | 614 | * Download was selected in the current search context menu. |
711 | */ | 615 | */ |
712 | static void | 616 | static void |
713 | start_download_ctx_menu (gpointer user_data, | 617 | start_download_ctx_menu (gpointer user_data, guint unused, GtkWidget * widget) |
714 | guint unused, | ||
715 | GtkWidget *widget) | ||
716 | { | 618 | { |
717 | GtkTreePath *path; | 619 | GtkTreePath *path; |
718 | GtkTreeView *tv; | 620 | GtkTreeView *tv; |
719 | 621 | ||
720 | if (current_context_row_reference == NULL) | 622 | if (current_context_row_reference == NULL) |
721 | { | 623 | { |
722 | GNUNET_break (0); | 624 | GNUNET_break (0); |
723 | return; | 625 | return; |
724 | } | 626 | } |
725 | path = gtk_tree_row_reference_get_path (current_context_row_reference); | 627 | path = gtk_tree_row_reference_get_path (current_context_row_reference); |
726 | gtk_tree_row_reference_free (current_context_row_reference); | 628 | gtk_tree_row_reference_free (current_context_row_reference); |
727 | current_context_row_reference = NULL; | 629 | current_context_row_reference = NULL; |
728 | tv = GTK_TREE_VIEW (gtk_builder_get_object (current_context_search_tab->builder, | 630 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
729 | "_search_result_frame")); | 631 | (current_context_search_tab->builder, |
632 | "_search_result_frame")); | ||
730 | start_download (tv, path, NULL, current_context_search_tab); | 633 | start_download (tv, path, NULL, current_context_search_tab); |
731 | gtk_tree_path_free (path); | 634 | gtk_tree_path_free (path); |
732 | current_context_search_tab = NULL; | 635 | current_context_search_tab = NULL; |
@@ -737,15 +640,12 @@ start_download_ctx_menu (gpointer user_data, | |||
737 | * Download was selected in the current search context menu. | 640 | * Download was selected in the current search context menu. |
738 | */ | 641 | */ |
739 | static void | 642 | static void |
740 | abort_download_ctx_menu (gpointer user_data, | 643 | abort_download_ctx_menu (gpointer user_data, guint unused, GtkWidget * widget) |
741 | guint unused, | ||
742 | GtkWidget *widget) | ||
743 | { | 644 | { |
744 | struct DownloadEntry *de = user_data; | 645 | struct DownloadEntry *de = user_data; |
745 | 646 | ||
746 | GNUNET_assert (de->dc != NULL); | 647 | GNUNET_assert (de->dc != NULL); |
747 | GNUNET_FS_download_stop (de->dc, | 648 | GNUNET_FS_download_stop (de->dc, GNUNET_YES); |
748 | GNUNET_YES); | ||
749 | current_context_search_tab = NULL; | 649 | current_context_search_tab = NULL; |
750 | } | 650 | } |
751 | 651 | ||
@@ -754,9 +654,8 @@ abort_download_ctx_menu (gpointer user_data, | |||
754 | * Copy current URI to clipboard. | 654 | * Copy current URI to clipboard. |
755 | */ | 655 | */ |
756 | static void | 656 | static void |
757 | copy_uri_to_clipboard_ctx_menu (gpointer user_data, | 657 | copy_uri_to_clipboard_ctx_menu (gpointer user_data, guint unused, |
758 | guint unused, | 658 | GtkWidget * widget) |
759 | GtkWidget *widget) | ||
760 | { | 659 | { |
761 | GtkTreePath *path; | 660 | GtkTreePath *path; |
762 | GtkTreeView *tv; | 661 | GtkTreeView *tv; |
@@ -767,36 +666,34 @@ copy_uri_to_clipboard_ctx_menu (gpointer user_data, | |||
767 | GtkClipboard *cb; | 666 | GtkClipboard *cb; |
768 | 667 | ||
769 | if (current_context_row_reference == NULL) | 668 | if (current_context_row_reference == NULL) |
770 | { | 669 | { |
771 | GNUNET_break (0); | 670 | GNUNET_break (0); |
772 | return; | 671 | return; |
773 | } | 672 | } |
774 | path = gtk_tree_row_reference_get_path (current_context_row_reference); | 673 | path = gtk_tree_row_reference_get_path (current_context_row_reference); |
775 | gtk_tree_row_reference_free (current_context_row_reference); | 674 | gtk_tree_row_reference_free (current_context_row_reference); |
776 | current_context_row_reference = NULL; | 675 | current_context_row_reference = NULL; |
777 | tv = GTK_TREE_VIEW (gtk_builder_get_object (current_context_search_tab->builder, | 676 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
778 | "_search_result_frame")); | 677 | (current_context_search_tab->builder, |
678 | "_search_result_frame")); | ||
779 | tm = gtk_tree_view_get_model (tv); | 679 | tm = gtk_tree_view_get_model (tv); |
780 | if (TRUE != gtk_tree_model_get_iter (tm, &iter, path)) | 680 | if (TRUE != gtk_tree_model_get_iter (tm, &iter, path)) |
781 | { | 681 | { |
782 | GNUNET_break (0); | 682 | GNUNET_break (0); |
783 | gtk_tree_path_free (path); | 683 | gtk_tree_path_free (path); |
784 | return; | 684 | return; |
785 | } | 685 | } |
786 | gtk_tree_model_get (tm, &iter, | 686 | gtk_tree_model_get (tm, &iter, 1, &uri, -1); |
787 | 1, &uri, -1); | ||
788 | gtk_tree_path_free (path); | 687 | gtk_tree_path_free (path); |
789 | current_context_search_tab = NULL; | 688 | current_context_search_tab = NULL; |
790 | if (uri == NULL) | 689 | if (uri == NULL) |
791 | { | 690 | { |
792 | GNUNET_break (0); | 691 | GNUNET_break (0); |
793 | return; | 692 | return; |
794 | } | 693 | } |
795 | uris = GNUNET_FS_uri_to_string (uri); | 694 | uris = GNUNET_FS_uri_to_string (uri); |
796 | cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); | 695 | cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); |
797 | gtk_clipboard_set_text (cb, | 696 | gtk_clipboard_set_text (cb, uris, -1); |
798 | uris, | ||
799 | -1); | ||
800 | gtk_clipboard_store (cb); | 697 | gtk_clipboard_store (cb); |
801 | GNUNET_free (uris); | 698 | GNUNET_free (uris); |
802 | } | 699 | } |
@@ -806,10 +703,8 @@ copy_uri_to_clipboard_ctx_menu (gpointer user_data, | |||
806 | * We got a right-click on the search result list. Display the context | 703 | * We got a right-click on the search result list. Display the context |
807 | * menu. | 704 | * menu. |
808 | */ | 705 | */ |
809 | static int | 706 | static int |
810 | search_list_on_menu(GtkWidget *widget, | 707 | search_list_on_menu (GtkWidget * widget, GdkEvent * event, gpointer user_data) |
811 | GdkEvent *event, | ||
812 | gpointer user_data) | ||
813 | { | 708 | { |
814 | GdkEventButton *event_button; | 709 | GdkEventButton *event_button; |
815 | struct SearchTab *tab = user_data; | 710 | struct SearchTab *tab = user_data; |
@@ -820,91 +715,79 @@ search_list_on_menu(GtkWidget *widget, | |||
820 | GtkTreeModel *tm; | 715 | GtkTreeModel *tm; |
821 | GtkTreeIter iter; | 716 | GtkTreeIter iter; |
822 | struct SearchResult *sr; | 717 | struct SearchResult *sr; |
823 | 718 | ||
824 | tv = GTK_TREE_VIEW (widget); | 719 | tv = GTK_TREE_VIEW (widget); |
825 | if (event->type == GDK_BUTTON_PRESS) | 720 | if (event->type == GDK_BUTTON_PRESS) |
721 | { | ||
722 | event_button = (GdkEventButton *) event; | ||
723 | if (event_button->button == 3) | ||
826 | { | 724 | { |
827 | event_button = (GdkEventButton *) event; | 725 | current_context_search_tab = tab; |
828 | if (event_button->button == 3) | 726 | if (current_context_row_reference != NULL) |
829 | { | 727 | { |
830 | current_context_search_tab = tab; | 728 | gtk_tree_row_reference_free (current_context_row_reference); |
831 | if (current_context_row_reference != NULL) | 729 | current_context_row_reference = NULL; |
832 | { | 730 | } |
833 | gtk_tree_row_reference_free (current_context_row_reference); | 731 | path = NULL; |
834 | current_context_row_reference = NULL; | 732 | if (FALSE == |
835 | } | 733 | gtk_tree_view_get_path_at_pos (tv, event_button->x, event_button->y, |
836 | path = NULL; | 734 | &path, NULL, NULL, NULL)) |
837 | if (FALSE == gtk_tree_view_get_path_at_pos (tv, | 735 | { |
838 | event_button->x, | 736 | /* nothing selected */ |
839 | event_button->y, | 737 | current_context_search_tab = NULL; |
840 | &path, NULL, NULL, NULL)) | 738 | return FALSE; |
841 | { | 739 | } |
842 | /* nothing selected */ | 740 | tm = gtk_tree_view_get_model (tv); |
843 | current_context_search_tab = NULL; | 741 | gtk_tree_model_get_iter (tm, &iter, path); |
844 | return FALSE; | 742 | gtk_tree_model_get (tm, &iter, 9, &sr, -1); |
845 | } | 743 | current_context_row_reference = gtk_tree_row_reference_new (tm, path); |
846 | tm = gtk_tree_view_get_model (tv); | 744 | gtk_tree_path_free (path); |
847 | gtk_tree_model_get_iter (tm, &iter, path); | 745 | |
848 | gtk_tree_model_get (tm, &iter, | 746 | /* |
849 | 9, &sr, | 747 | * FIXME: have additional options, depending on status: |
850 | -1); | 748 | * - view full meta data (in new window) |
851 | current_context_row_reference = gtk_tree_row_reference_new (tm, | 749 | * - copy URI to clipboard |
852 | path); | 750 | * - start recursive download |
853 | gtk_tree_path_free (path); | 751 | * - abort active download (!) |
854 | 752 | * => need to know download status before creating menu! | |
855 | /* | 753 | */ |
856 | FIXME: have additional options, depending on status: | 754 | menu = GTK_MENU (gtk_menu_new ()); |
857 | - view full meta data (in new window) | 755 | if (sr->download == NULL) |
858 | - copy URI to clipboard | 756 | { |
859 | - start recursive download | 757 | child = gtk_menu_item_new_with_label (_("_Download")); |
860 | - abort active download (!) | 758 | g_signal_connect (child, "activate", |
861 | => need to know download status before creating menu! | 759 | G_CALLBACK (start_download_ctx_menu), NULL); |
862 | */ | 760 | gtk_label_set_use_underline (GTK_LABEL |
863 | menu = GTK_MENU (gtk_menu_new ()); | 761 | (gtk_bin_get_child (GTK_BIN (child))), |
864 | if (sr->download == NULL) | 762 | TRUE); |
865 | { | 763 | gtk_widget_show (child); |
866 | child = gtk_menu_item_new_with_label (_("_Download")); | 764 | } |
867 | g_signal_connect (child, | 765 | else |
868 | "activate", | 766 | { |
869 | G_CALLBACK (start_download_ctx_menu), | 767 | child = gtk_menu_item_new_with_label (_("_Abort download")); |
870 | NULL); | 768 | g_signal_connect (child, "activate", |
871 | gtk_label_set_use_underline (GTK_LABEL | 769 | G_CALLBACK (abort_download_ctx_menu), sr->download); |
872 | (gtk_bin_get_child (GTK_BIN (child))), | 770 | gtk_label_set_use_underline (GTK_LABEL |
873 | TRUE); | 771 | (gtk_bin_get_child (GTK_BIN (child))), |
874 | gtk_widget_show (child); | 772 | TRUE); |
875 | } | 773 | gtk_widget_show (child); |
876 | else | 774 | |
877 | { | 775 | } |
878 | child = gtk_menu_item_new_with_label (_("_Abort download")); | 776 | |
879 | g_signal_connect (child, | 777 | child = gtk_menu_item_new_with_label (_("_Copy URI to Clipboard")); |
880 | "activate", | 778 | g_signal_connect (child, "activate", |
881 | G_CALLBACK (abort_download_ctx_menu), | 779 | G_CALLBACK (copy_uri_to_clipboard_ctx_menu), NULL); |
882 | sr->download); | 780 | gtk_label_set_use_underline (GTK_LABEL |
883 | gtk_label_set_use_underline (GTK_LABEL | 781 | (gtk_bin_get_child (GTK_BIN (child))), TRUE); |
884 | (gtk_bin_get_child (GTK_BIN (child))), | 782 | gtk_widget_show (child); |
885 | TRUE); | 783 | |
886 | gtk_widget_show (child); | 784 | |
887 | 785 | ||
888 | } | 786 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); |
889 | 787 | gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event_button->button, | |
890 | child = gtk_menu_item_new_with_label (_("_Copy URI to Clipboard")); | 788 | event_button->time); |
891 | g_signal_connect (child, | ||
892 | "activate", | ||
893 | G_CALLBACK (copy_uri_to_clipboard_ctx_menu), | ||
894 | NULL); | ||
895 | gtk_label_set_use_underline (GTK_LABEL | ||
896 | (gtk_bin_get_child (GTK_BIN (child))), | ||
897 | TRUE); | ||
898 | gtk_widget_show (child); | ||
899 | |||
900 | |||
901 | |||
902 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); | ||
903 | gtk_menu_popup (menu, NULL, NULL, NULL, NULL, | ||
904 | event_button->button, | ||
905 | event_button->time); | ||
906 | } | ||
907 | } | 789 | } |
790 | } | ||
908 | return FALSE; | 791 | return FALSE; |
909 | } | 792 | } |
910 | 793 | ||
@@ -914,8 +797,7 @@ search_list_on_menu(GtkWidget *widget, | |||
914 | * areas. | 797 | * areas. |
915 | */ | 798 | */ |
916 | static void | 799 | static void |
917 | update_meta_data_views (GtkTreeView *tv, | 800 | update_meta_data_views (GtkTreeView * tv, gpointer user_data) |
918 | gpointer user_data) | ||
919 | { | 801 | { |
920 | struct SearchTab *tab = user_data; | 802 | struct SearchTab *tab = user_data; |
921 | GtkImage *image; | 803 | GtkImage *image; |
@@ -927,36 +809,33 @@ update_meta_data_views (GtkTreeView *tv, | |||
927 | GdkPixbuf *pixbuf; | 809 | GdkPixbuf *pixbuf; |
928 | 810 | ||
929 | GNUNET_assert (tab->query_txt != NULL); | 811 | GNUNET_assert (tab->query_txt != NULL); |
930 | image = GTK_IMAGE (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_preview_image")); | 812 | image = |
931 | ms = GTK_LIST_STORE (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_meta_data_list_store")); | 813 | GTK_IMAGE (GNUNET_FS_GTK_get_main_window_object |
814 | ("GNUNET_GTK_main_window_preview_image")); | ||
815 | ms = GTK_LIST_STORE (GNUNET_FS_GTK_get_main_window_object | ||
816 | ("GNUNET_GTK_meta_data_list_store")); | ||
932 | 817 | ||
933 | sel = gtk_tree_view_get_selection (tv); | 818 | sel = gtk_tree_view_get_selection (tv); |
934 | gtk_list_store_clear (ms); | 819 | gtk_list_store_clear (ms); |
935 | if (TRUE != gtk_tree_selection_get_selected (sel, | 820 | if (TRUE != gtk_tree_selection_get_selected (sel, &model, &iter)) |
936 | &model, | 821 | { |
937 | &iter)) | 822 | gtk_image_clear (image); |
938 | { | 823 | return; |
939 | gtk_image_clear (image); | 824 | } |
940 | return; | ||
941 | } | ||
942 | meta = NULL; | 825 | meta = NULL; |
943 | pixbuf = NULL; | 826 | pixbuf = NULL; |
944 | gtk_tree_model_get (model, | 827 | gtk_tree_model_get (model, &iter, 0, &meta, 3, &pixbuf, -1); |
945 | &iter, | ||
946 | 0, &meta, | ||
947 | 3, &pixbuf, | ||
948 | -1); | ||
949 | if (pixbuf != NULL) | 828 | if (pixbuf != NULL) |
950 | { | 829 | { |
951 | gtk_image_set_from_pixbuf (image, pixbuf); | 830 | gtk_image_set_from_pixbuf (image, pixbuf); |
952 | g_object_unref (G_OBJECT (pixbuf)); | 831 | g_object_unref (G_OBJECT (pixbuf)); |
953 | } | 832 | } |
954 | if (meta != NULL) | 833 | if (meta != NULL) |
955 | { | 834 | { |
956 | GNUNET_CONTAINER_meta_data_iterate (meta, | 835 | GNUNET_CONTAINER_meta_data_iterate (meta, |
957 | &GNUNET_FS_GTK_add_meta_data_to_list_store, | 836 | &GNUNET_FS_GTK_add_meta_data_to_list_store, |
958 | ms); | 837 | ms); |
959 | } | 838 | } |
960 | } | 839 | } |
961 | 840 | ||
962 | 841 | ||
@@ -967,22 +846,16 @@ static void | |||
967 | update_search_label (struct SearchTab *tab) | 846 | update_search_label (struct SearchTab *tab) |
968 | { | 847 | { |
969 | char *name; | 848 | char *name; |
970 | 849 | ||
971 | while (tab->parent != NULL) | 850 | while (tab->parent != NULL) |
972 | tab = tab->parent->tab; | 851 | tab = tab->parent->tab; |
973 | if (tab->num_results > 0) | 852 | if (tab->num_results > 0) |
974 | GNUNET_asprintf (&name, | 853 | GNUNET_asprintf (&name, "%.*s%s (%u)", 20, tab->query_txt, |
975 | "%.*s%s (%u)", | 854 | strlen (tab->query_txt) > 20 ? "..." : "", |
976 | 20, | 855 | tab->num_results); |
977 | tab->query_txt, | ||
978 | strlen (tab->query_txt) > 20 ? "..." : "", | ||
979 | tab->num_results); | ||
980 | else | 856 | else |
981 | GNUNET_asprintf (&name, | 857 | GNUNET_asprintf (&name, "%.*s%s", 20, tab->query_txt, |
982 | "%.*s%s", | 858 | strlen (tab->query_txt) > 20 ? "..." : ""); |
983 | 20, | ||
984 | tab->query_txt, | ||
985 | strlen (tab->query_txt) > 20 ? "..." : ""); | ||
986 | gtk_label_set_text (tab->label, name); | 859 | gtk_label_set_text (tab->label, name); |
987 | GNUNET_free (name); | 860 | GNUNET_free (name); |
988 | } | 861 | } |
@@ -997,15 +870,17 @@ close_search_tab (struct SearchTab *tab) | |||
997 | GtkNotebook *notebook; | 870 | GtkNotebook *notebook; |
998 | int index; | 871 | int index; |
999 | int i; | 872 | int i; |
1000 | 873 | ||
1001 | if (tab->parent != NULL) | 874 | if (tab->parent != NULL) |
1002 | { | 875 | { |
1003 | /* not a top-level search, do not close tab here! */ | 876 | /* not a top-level search, do not close tab here! */ |
1004 | GNUNET_free (tab); | 877 | GNUNET_free (tab); |
1005 | return; | 878 | return; |
1006 | } | 879 | } |
1007 | 880 | ||
1008 | notebook = GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_notebook")); | 881 | notebook = |
882 | GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object | ||
883 | ("GNUNET_GTK_main_window_notebook")); | ||
1009 | index = -1; | 884 | index = -1; |
1010 | for (i = gtk_notebook_get_n_pages (notebook) - 1; i >= 0; i--) | 885 | for (i = gtk_notebook_get_n_pages (notebook) - 1; i >= 0; i--) |
1011 | if (tab->frame == gtk_notebook_get_nth_page (notebook, i)) | 886 | if (tab->frame == gtk_notebook_get_nth_page (notebook, i)) |
@@ -1013,9 +888,7 @@ close_search_tab (struct SearchTab *tab) | |||
1013 | gtk_notebook_remove_page (notebook, index); | 888 | gtk_notebook_remove_page (notebook, index); |
1014 | g_object_unref (tab->builder); | 889 | g_object_unref (tab->builder); |
1015 | GNUNET_free (tab->query_txt); | 890 | GNUNET_free (tab->query_txt); |
1016 | GNUNET_CONTAINER_DLL_remove (search_tab_head, | 891 | GNUNET_CONTAINER_DLL_remove (search_tab_head, search_tab_tail, tab); |
1017 | search_tab_tail, | ||
1018 | tab); | ||
1019 | GNUNET_free (tab); | 892 | GNUNET_free (tab); |
1020 | } | 893 | } |
1021 | 894 | ||
@@ -1025,11 +898,10 @@ close_search_tab (struct SearchTab *tab) | |||
1025 | */ | 898 | */ |
1026 | static struct PublishEntry * | 899 | static struct PublishEntry * |
1027 | handle_publish_completed (struct PublishEntry *ent, | 900 | handle_publish_completed (struct PublishEntry *ent, |
1028 | const struct GNUNET_FS_Uri *uri) | 901 | const struct GNUNET_FS_Uri *uri) |
1029 | { | 902 | { |
1030 | ent->uri = GNUNET_FS_uri_dup (uri); | 903 | ent->uri = GNUNET_FS_uri_dup (uri); |
1031 | return change_publish_colour (ent, | 904 | return change_publish_colour (ent, "green"); |
1032 | "green"); | ||
1033 | } | 905 | } |
1034 | 906 | ||
1035 | 907 | ||
@@ -1038,12 +910,10 @@ handle_publish_completed (struct PublishEntry *ent, | |||
1038 | * Handle error. | 910 | * Handle error. |
1039 | */ | 911 | */ |
1040 | static struct PublishEntry * | 912 | static struct PublishEntry * |
1041 | handle_publish_error (struct PublishEntry *ent, | 913 | handle_publish_error (struct PublishEntry *ent, const char *emsg) |
1042 | const char *emsg) | ||
1043 | { | 914 | { |
1044 | GNUNET_break (0); | 915 | GNUNET_break (0); |
1045 | return change_publish_colour (ent, | 916 | return change_publish_colour (ent, "red"); |
1046 | "red"); | ||
1047 | } | 917 | } |
1048 | 918 | ||
1049 | 919 | ||
@@ -1059,30 +929,30 @@ close_publish_tab (struct PublishEntry *ent) | |||
1059 | int i; | 929 | int i; |
1060 | 930 | ||
1061 | if (ent == NULL) | 931 | if (ent == NULL) |
1062 | { | 932 | { |
1063 | GNUNET_break (0); | 933 | GNUNET_break (0); |
1064 | return; | 934 | return; |
1065 | } | 935 | } |
1066 | gtk_tree_row_reference_free (ent->rr); | 936 | gtk_tree_row_reference_free (ent->rr); |
1067 | if (GNUNET_YES != ent->is_top) | 937 | if (GNUNET_YES != ent->is_top) |
1068 | { | 938 | { |
1069 | GNUNET_free (ent); | 939 | GNUNET_free (ent); |
1070 | return; | 940 | return; |
1071 | } | 941 | } |
1072 | tab = ent->tab; | 942 | tab = ent->tab; |
1073 | if (ent->uri != NULL) | 943 | if (ent->uri != NULL) |
1074 | GNUNET_FS_uri_destroy (ent->uri); | 944 | GNUNET_FS_uri_destroy (ent->uri); |
1075 | GNUNET_free (ent); | 945 | GNUNET_free (ent); |
1076 | notebook = GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_notebook")); | 946 | notebook = |
947 | GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object | ||
948 | ("GNUNET_GTK_main_window_notebook")); | ||
1077 | index = -1; | 949 | index = -1; |
1078 | for (i = gtk_notebook_get_n_pages (notebook) - 1; i >= 0; i--) | 950 | for (i = gtk_notebook_get_n_pages (notebook) - 1; i >= 0; i--) |
1079 | if (tab->frame == gtk_notebook_get_nth_page (notebook, i)) | 951 | if (tab->frame == gtk_notebook_get_nth_page (notebook, i)) |
1080 | index = i; | 952 | index = i; |
1081 | gtk_notebook_remove_page (notebook, index); | 953 | gtk_notebook_remove_page (notebook, index); |
1082 | g_object_unref (tab->builder); | 954 | g_object_unref (tab->builder); |
1083 | GNUNET_CONTAINER_DLL_remove (publish_tab_head, | 955 | GNUNET_CONTAINER_DLL_remove (publish_tab_head, publish_tab_tail, tab); |
1084 | publish_tab_tail, | ||
1085 | tab); | ||
1086 | GNUNET_free (tab); | 956 | GNUNET_free (tab); |
1087 | } | 957 | } |
1088 | 958 | ||
@@ -1091,15 +961,15 @@ close_publish_tab (struct PublishEntry *ent) | |||
1091 | * Tell FS to stop a search. | 961 | * Tell FS to stop a search. |
1092 | */ | 962 | */ |
1093 | static void | 963 | static void |
1094 | stop_search (GtkButton *button, | 964 | stop_search (GtkButton * button, gpointer user_data) |
1095 | gpointer user_data) | ||
1096 | { | 965 | { |
1097 | struct SearchTab *tab = user_data; | 966 | struct SearchTab *tab = user_data; |
967 | |||
1098 | if (tab->sc != NULL) | 968 | if (tab->sc != NULL) |
1099 | { | 969 | { |
1100 | GNUNET_FS_search_stop (tab->sc); | 970 | GNUNET_FS_search_stop (tab->sc); |
1101 | tab->sc = NULL; | 971 | tab->sc = NULL; |
1102 | } | 972 | } |
1103 | } | 973 | } |
1104 | 974 | ||
1105 | 975 | ||
@@ -1111,8 +981,7 @@ stop_search (GtkButton *button, | |||
1111 | * the tab should be closed. | 981 | * the tab should be closed. |
1112 | */ | 982 | */ |
1113 | static void | 983 | static void |
1114 | clear_downloads (GtkButton *button, | 984 | clear_downloads (GtkButton * button, gpointer user_data) |
1115 | gpointer user_data) | ||
1116 | { | 985 | { |
1117 | struct SearchTab *tab = user_data; | 986 | struct SearchTab *tab = user_data; |
1118 | struct SearchResult *sr; | 987 | struct SearchResult *sr; |
@@ -1123,15 +992,11 @@ clear_downloads (GtkButton *button, | |||
1123 | if (TRUE != gtk_tree_model_get_iter_first (tm, &iter)) | 992 | if (TRUE != gtk_tree_model_get_iter_first (tm, &iter)) |
1124 | return; | 993 | return; |
1125 | do | 994 | do |
1126 | { | 995 | { |
1127 | gtk_tree_model_get (tm, &iter, | 996 | gtk_tree_model_get (tm, &iter, 9, &sr, -1); |
1128 | 9, &sr, | 997 | if ((sr->download != NULL) && (sr->download->is_done == GNUNET_YES)) |
1129 | -1); | 998 | GNUNET_FS_download_stop (sr->download->dc, GNUNET_YES); |
1130 | if ( (sr->download != NULL) && | 999 | } |
1131 | (sr->download->is_done == GNUNET_YES) ) | ||
1132 | GNUNET_FS_download_stop (sr->download->dc, | ||
1133 | GNUNET_YES); | ||
1134 | } | ||
1135 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | 1000 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); |
1136 | } | 1001 | } |
1137 | 1002 | ||
@@ -1141,16 +1006,16 @@ clear_downloads (GtkButton *button, | |||
1141 | * Tell FS to pause a search. | 1006 | * Tell FS to pause a search. |
1142 | */ | 1007 | */ |
1143 | static void | 1008 | static void |
1144 | pause_search (GtkButton *button, | 1009 | pause_search (GtkButton * button, gpointer user_data) |
1145 | gpointer user_data) | ||
1146 | { | 1010 | { |
1147 | struct SearchTab *tab = user_data; | 1011 | struct SearchTab *tab = user_data; |
1012 | |||
1148 | if (tab->sc != NULL) | 1013 | if (tab->sc != NULL) |
1149 | { | 1014 | { |
1150 | GNUNET_FS_search_pause (tab->sc); | 1015 | GNUNET_FS_search_pause (tab->sc); |
1151 | gtk_widget_show (tab->play_button); | 1016 | gtk_widget_show (tab->play_button); |
1152 | gtk_widget_hide (tab->pause_button); | 1017 | gtk_widget_hide (tab->pause_button); |
1153 | } | 1018 | } |
1154 | } | 1019 | } |
1155 | 1020 | ||
1156 | 1021 | ||
@@ -1158,16 +1023,16 @@ pause_search (GtkButton *button, | |||
1158 | * Tell FS to resume a search. | 1023 | * Tell FS to resume a search. |
1159 | */ | 1024 | */ |
1160 | static void | 1025 | static void |
1161 | continue_search (GtkButton *button, | 1026 | continue_search (GtkButton * button, gpointer user_data) |
1162 | gpointer user_data) | ||
1163 | { | 1027 | { |
1164 | struct SearchTab *tab = user_data; | 1028 | struct SearchTab *tab = user_data; |
1029 | |||
1165 | if (tab->sc != NULL) | 1030 | if (tab->sc != NULL) |
1166 | { | 1031 | { |
1167 | GNUNET_FS_search_continue (tab->sc); | 1032 | GNUNET_FS_search_continue (tab->sc); |
1168 | gtk_widget_show (tab->pause_button); | 1033 | gtk_widget_show (tab->pause_button); |
1169 | gtk_widget_hide (tab->play_button); | 1034 | gtk_widget_hide (tab->play_button); |
1170 | } | 1035 | } |
1171 | } | 1036 | } |
1172 | 1037 | ||
1173 | 1038 | ||
@@ -1180,7 +1045,7 @@ continue_search (GtkButton *button, | |||
1180 | */ | 1045 | */ |
1181 | static struct SearchTab * | 1046 | static struct SearchTab * |
1182 | setup_search (struct GNUNET_FS_SearchContext *sc, | 1047 | setup_search (struct GNUNET_FS_SearchContext *sc, |
1183 | const struct GNUNET_FS_Uri *query) | 1048 | const struct GNUNET_FS_Uri *query) |
1184 | { | 1049 | { |
1185 | struct SearchTab *tab; | 1050 | struct SearchTab *tab; |
1186 | GtkTreeView *tv; | 1051 | GtkTreeView *tv; |
@@ -1189,86 +1054,87 @@ setup_search (struct GNUNET_FS_SearchContext *sc, | |||
1189 | gint pages; | 1054 | gint pages; |
1190 | 1055 | ||
1191 | tab = GNUNET_malloc (sizeof (struct SearchTab)); | 1056 | tab = GNUNET_malloc (sizeof (struct SearchTab)); |
1192 | GNUNET_CONTAINER_DLL_insert (search_tab_head, | 1057 | GNUNET_CONTAINER_DLL_insert (search_tab_head, search_tab_tail, tab); |
1193 | search_tab_tail, | ||
1194 | tab); | ||
1195 | tab->sc = sc; | 1058 | tab->sc = sc; |
1196 | if (query == NULL) | 1059 | if (query == NULL) |
1197 | { | 1060 | { |
1198 | tab->query_txt = GNUNET_strdup ("*"); | 1061 | tab->query_txt = GNUNET_strdup ("*"); |
1199 | } | 1062 | } |
1200 | else | 1063 | else |
1201 | { | 1064 | { |
1202 | if (GNUNET_FS_uri_test_ksk (query)) | 1065 | if (GNUNET_FS_uri_test_ksk (query)) |
1203 | tab->query_txt = GNUNET_FS_uri_ksk_to_string_fancy (query); | 1066 | tab->query_txt = GNUNET_FS_uri_ksk_to_string_fancy (query); |
1204 | else | 1067 | else |
1205 | tab->query_txt = GNUNET_FS_uri_to_string (query); | 1068 | tab->query_txt = GNUNET_FS_uri_to_string (query); |
1206 | } | 1069 | } |
1207 | tab->builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_search_tab.glade"); | 1070 | tab->builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_search_tab.glade"); |
1208 | tab->ts = GTK_TREE_STORE (gtk_builder_get_object (tab->builder, | 1071 | tab->ts = |
1209 | "GNUNET_GTK_file_sharing_result_tree_store")); | 1072 | GTK_TREE_STORE (gtk_builder_get_object |
1073 | (tab->builder, | ||
1074 | "GNUNET_GTK_file_sharing_result_tree_store")); | ||
1210 | /* load frame */ | 1075 | /* load frame */ |
1211 | sf = GTK_WINDOW (gtk_builder_get_object (tab->builder, | 1076 | sf = GTK_WINDOW (gtk_builder_get_object |
1212 | "_search_result_frame_window")); | 1077 | (tab->builder, "_search_result_frame_window")); |
1213 | tab->frame = gtk_bin_get_child (GTK_BIN (sf)); | 1078 | tab->frame = gtk_bin_get_child (GTK_BIN (sf)); |
1214 | gtk_widget_ref (tab->frame); | 1079 | gtk_widget_ref (tab->frame); |
1215 | gtk_container_remove (GTK_CONTAINER (sf), tab->frame); | 1080 | gtk_container_remove (GTK_CONTAINER (sf), tab->frame); |
1216 | gtk_widget_destroy (GTK_WIDGET (sf)); | 1081 | gtk_widget_destroy (GTK_WIDGET (sf)); |
1217 | 1082 | ||
1218 | /* load tab_label */ | 1083 | /* load tab_label */ |
1219 | sf = GTK_WINDOW (gtk_builder_get_object (tab->builder, | 1084 | sf = GTK_WINDOW (gtk_builder_get_object |
1220 | "_search_result_label_window")); | 1085 | (tab->builder, "_search_result_label_window")); |
1221 | tab->tab_label = gtk_bin_get_child (GTK_BIN (sf)); | 1086 | tab->tab_label = gtk_bin_get_child (GTK_BIN (sf)); |
1222 | gtk_widget_ref (tab->tab_label); | 1087 | gtk_widget_ref (tab->tab_label); |
1223 | gtk_container_remove (GTK_CONTAINER (sf), tab->tab_label); | 1088 | gtk_container_remove (GTK_CONTAINER (sf), tab->tab_label); |
1224 | gtk_widget_destroy (GTK_WIDGET (sf)); | 1089 | gtk_widget_destroy (GTK_WIDGET (sf)); |
1225 | 1090 | ||
1226 | /* get refs to widgets */ | 1091 | /* get refs to widgets */ |
1227 | tab->label = GTK_LABEL (gtk_builder_get_object (tab->builder, | 1092 | tab->label = |
1228 | "_search_result_label_window_label")); | 1093 | GTK_LABEL (gtk_builder_get_object |
1229 | 1094 | (tab->builder, "_search_result_label_window_label")); | |
1230 | tab->close_button = GTK_WIDGET (gtk_builder_get_object (tab->builder, | 1095 | |
1231 | "_search_result_label_close_button")); | 1096 | tab->close_button = |
1232 | g_signal_connect(G_OBJECT(tab->close_button), "clicked", | 1097 | GTK_WIDGET (gtk_builder_get_object |
1233 | G_CALLBACK(stop_search), tab); | 1098 | (tab->builder, "_search_result_label_close_button")); |
1234 | tab->clear_button = GTK_WIDGET (gtk_builder_get_object (tab->builder, | 1099 | g_signal_connect (G_OBJECT (tab->close_button), "clicked", |
1235 | "_search_result_label_clear_button")); | 1100 | G_CALLBACK (stop_search), tab); |
1236 | g_signal_connect(G_OBJECT(tab->clear_button), "clicked", | 1101 | tab->clear_button = |
1237 | G_CALLBACK(clear_downloads), tab); | 1102 | GTK_WIDGET (gtk_builder_get_object |
1238 | tab->play_button = GTK_WIDGET (gtk_builder_get_object (tab->builder, | 1103 | (tab->builder, "_search_result_label_clear_button")); |
1239 | "_search_result_label_play_button")); | 1104 | g_signal_connect (G_OBJECT (tab->clear_button), "clicked", |
1240 | g_signal_connect(G_OBJECT(tab->play_button), "clicked", | 1105 | G_CALLBACK (clear_downloads), tab); |
1241 | G_CALLBACK(continue_search), tab); | 1106 | tab->play_button = |
1242 | tab->pause_button = GTK_WIDGET (gtk_builder_get_object (tab->builder, | 1107 | GTK_WIDGET (gtk_builder_get_object |
1243 | "_search_result_label_pause_button")); | 1108 | (tab->builder, "_search_result_label_play_button")); |
1244 | g_signal_connect(G_OBJECT(tab->pause_button), "clicked", | 1109 | g_signal_connect (G_OBJECT (tab->play_button), "clicked", |
1245 | G_CALLBACK(pause_search), tab); | 1110 | G_CALLBACK (continue_search), tab); |
1111 | tab->pause_button = | ||
1112 | GTK_WIDGET (gtk_builder_get_object | ||
1113 | (tab->builder, "_search_result_label_pause_button")); | ||
1114 | g_signal_connect (G_OBJECT (tab->pause_button), "clicked", | ||
1115 | G_CALLBACK (pause_search), tab); | ||
1246 | /* patch text */ | 1116 | /* patch text */ |
1247 | update_search_label (tab); | 1117 | update_search_label (tab); |
1248 | 1118 | ||
1249 | /* add signal handlers */ | 1119 | /* add signal handlers */ |
1250 | tv = GTK_TREE_VIEW (gtk_builder_get_object (tab->builder, | 1120 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1251 | "_search_result_frame")); | 1121 | (tab->builder, "_search_result_frame")); |
1252 | g_signal_connect(G_OBJECT(tv), "row-activated", | 1122 | g_signal_connect (G_OBJECT (tv), "row-activated", G_CALLBACK (start_download), |
1253 | G_CALLBACK(start_download), tab); | 1123 | tab); |
1254 | g_signal_connect(G_OBJECT(tv), "cursor-changed", | 1124 | g_signal_connect (G_OBJECT (tv), "cursor-changed", |
1255 | G_CALLBACK(update_meta_data_views), tab); | 1125 | G_CALLBACK (update_meta_data_views), tab); |
1256 | g_signal_connect (G_OBJECT(tv), | 1126 | g_signal_connect (G_OBJECT (tv), "button_press_event", |
1257 | "button_press_event", | 1127 | G_CALLBACK (search_list_on_menu), tab); |
1258 | G_CALLBACK(search_list_on_menu), | 1128 | |
1259 | tab); | ||
1260 | |||
1261 | 1129 | ||
1262 | /* make visible */ | 1130 | /* make visible */ |
1263 | notebook = GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_notebook")); | 1131 | notebook = |
1132 | GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object | ||
1133 | ("GNUNET_GTK_main_window_notebook")); | ||
1264 | pages = gtk_notebook_get_n_pages (notebook); | 1134 | pages = gtk_notebook_get_n_pages (notebook); |
1265 | gtk_notebook_insert_page (notebook, | 1135 | gtk_notebook_insert_page (notebook, tab->frame, tab->tab_label, pages - 1); |
1266 | tab->frame, | 1136 | gtk_notebook_set_current_page (notebook, pages - 1); |
1267 | tab->tab_label, | 1137 | gtk_widget_show (GTK_WIDGET (notebook)); |
1268 | pages - 1); | ||
1269 | gtk_notebook_set_current_page (notebook, | ||
1270 | pages - 1); | ||
1271 | gtk_widget_show (GTK_WIDGET (notebook)); | ||
1272 | return tab; | 1138 | return tab; |
1273 | } | 1139 | } |
1274 | 1140 | ||
@@ -1282,7 +1148,7 @@ setup_search (struct GNUNET_FS_SearchContext *sc, | |||
1282 | */ | 1148 | */ |
1283 | static struct SearchTab * | 1149 | static struct SearchTab * |
1284 | setup_inner_search (struct GNUNET_FS_SearchContext *sc, | 1150 | setup_inner_search (struct GNUNET_FS_SearchContext *sc, |
1285 | struct SearchResult *parent) | 1151 | struct SearchResult *parent) |
1286 | { | 1152 | { |
1287 | struct SearchTab *ret; | 1153 | struct SearchTab *ret; |
1288 | 1154 | ||
@@ -1316,13 +1182,12 @@ setup_inner_search (struct GNUNET_FS_SearchContext *sc, | |||
1316 | * @return entry for the search result | 1182 | * @return entry for the search result |
1317 | */ | 1183 | */ |
1318 | struct SearchResult * | 1184 | struct SearchResult * |
1319 | GNUNET_GTK_add_search_result (struct SearchTab *tab, | 1185 | GNUNET_GTK_add_search_result (struct SearchTab *tab, GtkTreeIter * iter, |
1320 | GtkTreeIter *iter, | 1186 | GtkTreeRowReference * parent_rr, |
1321 | GtkTreeRowReference *parent_rr, | 1187 | const struct GNUNET_FS_Uri *uri, |
1322 | const struct GNUNET_FS_Uri *uri, | 1188 | const struct GNUNET_CONTAINER_MetaData *meta, |
1323 | const struct GNUNET_CONTAINER_MetaData *meta, | 1189 | struct GNUNET_FS_SearchResult *result, |
1324 | struct GNUNET_FS_SearchResult *result, | 1190 | uint32_t applicability_rank) |
1325 | uint32_t applicability_rank) | ||
1326 | { | 1191 | { |
1327 | struct SearchResult *sr; | 1192 | struct SearchResult *sr; |
1328 | GtkTreePath *tp; | 1193 | GtkTreePath *tp; |
@@ -1334,45 +1199,46 @@ GNUNET_GTK_add_search_result (struct SearchTab *tab, | |||
1334 | GtkTreeIter *pitr; | 1199 | GtkTreeIter *pitr; |
1335 | GtkTreeIter pmem; | 1200 | GtkTreeIter pmem; |
1336 | GtkTreePath *path; | 1201 | GtkTreePath *path; |
1337 | GtkTreeModel *tm; | 1202 | GtkTreeModel *tm; |
1338 | GtkTreeStore *ts; | 1203 | GtkTreeStore *ts; |
1339 | uint64_t fsize; | 1204 | uint64_t fsize; |
1340 | 1205 | ||
1341 | if ( (uri != NULL) && | 1206 | if ((uri != NULL) && (!GNUNET_FS_uri_test_loc (uri)) && |
1342 | (!GNUNET_FS_uri_test_loc (uri)) && | 1207 | (!GNUNET_FS_uri_test_chk (uri))) |
1343 | (!GNUNET_FS_uri_test_chk (uri)) ) | 1208 | { |
1344 | { | 1209 | fsize = 0; |
1345 | fsize = 0; | 1210 | mime = GNUNET_strdup ("GNUnet namespace"); |
1346 | mime = GNUNET_strdup ("GNUnet namespace"); | 1211 | status_colour = "lightgreen"; |
1347 | status_colour = "lightgreen"; | 1212 | } |
1348 | } | ||
1349 | else if (uri != NULL) | 1213 | else if (uri != NULL) |
1350 | { | 1214 | { |
1351 | fsize = GNUNET_FS_uri_chk_get_file_size (uri); | 1215 | fsize = GNUNET_FS_uri_chk_get_file_size (uri); |
1352 | mime = GNUNET_CONTAINER_meta_data_get_first_by_types (meta, | 1216 | mime = |
1353 | EXTRACTOR_METATYPE_MIMETYPE, | 1217 | GNUNET_CONTAINER_meta_data_get_first_by_types (meta, |
1354 | EXTRACTOR_METATYPE_FORMAT, | 1218 | EXTRACTOR_METATYPE_MIMETYPE, |
1355 | -1); | 1219 | EXTRACTOR_METATYPE_FORMAT, |
1356 | status_colour = "white"; | 1220 | -1); |
1357 | } | 1221 | status_colour = "white"; |
1222 | } | ||
1358 | else | 1223 | else |
1359 | { | 1224 | { |
1360 | fsize = 0; | 1225 | fsize = 0; |
1361 | status_colour = "gray"; | 1226 | status_colour = "gray"; |
1362 | mime = NULL; | 1227 | mime = NULL; |
1363 | } | 1228 | } |
1364 | desc = GNUNET_CONTAINER_meta_data_get_first_by_types (meta, | 1229 | desc = |
1365 | EXTRACTOR_METATYPE_PACKAGE_NAME, | 1230 | GNUNET_CONTAINER_meta_data_get_first_by_types (meta, |
1366 | EXTRACTOR_METATYPE_TITLE, | 1231 | EXTRACTOR_METATYPE_PACKAGE_NAME, |
1367 | EXTRACTOR_METATYPE_BOOK_TITLE, | 1232 | EXTRACTOR_METATYPE_TITLE, |
1368 | EXTRACTOR_METATYPE_FILENAME, | 1233 | EXTRACTOR_METATYPE_BOOK_TITLE, |
1369 | EXTRACTOR_METATYPE_DESCRIPTION, | 1234 | EXTRACTOR_METATYPE_FILENAME, |
1370 | EXTRACTOR_METATYPE_SUMMARY, | 1235 | EXTRACTOR_METATYPE_DESCRIPTION, |
1371 | EXTRACTOR_METATYPE_ALBUM, | 1236 | EXTRACTOR_METATYPE_SUMMARY, |
1372 | EXTRACTOR_METATYPE_COMMENT, | 1237 | EXTRACTOR_METATYPE_ALBUM, |
1373 | EXTRACTOR_METATYPE_SUBJECT, | 1238 | EXTRACTOR_METATYPE_COMMENT, |
1374 | EXTRACTOR_METATYPE_KEYWORDS, | 1239 | EXTRACTOR_METATYPE_SUBJECT, |
1375 | -1); | 1240 | EXTRACTOR_METATYPE_KEYWORDS, |
1241 | -1); | ||
1376 | if (desc == NULL) | 1242 | if (desc == NULL) |
1377 | desc = GNUNET_strdup (_("no description supplied")); | 1243 | desc = GNUNET_strdup (_("no description supplied")); |
1378 | if (uri == NULL) | 1244 | if (uri == NULL) |
@@ -1385,85 +1251,76 @@ GNUNET_GTK_add_search_result (struct SearchTab *tab, | |||
1385 | sr->result = result; | 1251 | sr->result = result; |
1386 | sr->tab = tab; | 1252 | sr->tab = tab; |
1387 | if (parent_rr != NULL) | 1253 | if (parent_rr != NULL) |
1254 | { | ||
1255 | /* get piter from parent */ | ||
1256 | path = gtk_tree_row_reference_get_path (parent_rr); | ||
1257 | tm = gtk_tree_row_reference_get_model (parent_rr); | ||
1258 | if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (tm), &pmem, path)) | ||
1388 | { | 1259 | { |
1389 | /* get piter from parent */ | 1260 | GNUNET_break (0); |
1390 | path = gtk_tree_row_reference_get_path (parent_rr); | 1261 | gtk_tree_path_free (path); |
1391 | tm = gtk_tree_row_reference_get_model (parent_rr); | 1262 | /* desperate measure: make top-level entry */ |
1392 | if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (tm), | ||
1393 | &pmem, path)) | ||
1394 | { | ||
1395 | GNUNET_break (0); | ||
1396 | gtk_tree_path_free (path); | ||
1397 | /* desperate measure: make top-level entry */ | ||
1398 | pitr = NULL; | ||
1399 | } | ||
1400 | else | ||
1401 | { | ||
1402 | pitr = &pmem; | ||
1403 | } | ||
1404 | ts = GTK_TREE_STORE (tm); | ||
1405 | } | ||
1406 | else | ||
1407 | { | ||
1408 | /* top-level result */ | ||
1409 | pitr = NULL; | 1263 | pitr = NULL; |
1410 | ts = tab->ts; | ||
1411 | } | 1264 | } |
1412 | gtk_tree_store_insert_with_values (ts, | 1265 | else |
1413 | iter, | ||
1414 | pitr, | ||
1415 | G_MAXINT, | ||
1416 | 0, GNUNET_CONTAINER_meta_data_duplicate (meta), | ||
1417 | 1, (uri == NULL) ? NULL : GNUNET_FS_uri_dup (uri), | ||
1418 | 2, (uri == NULL) ? 0 : fsize, | ||
1419 | 3, pixbuf /* preview */, | ||
1420 | 4, 0 /* percent progress */, | ||
1421 | 5, 0 /* percent availability */, | ||
1422 | 6, desc /* filename/description */, | ||
1423 | 7, uris, | ||
1424 | 8, status_colour, | ||
1425 | 9, sr, | ||
1426 | 10, mime, | ||
1427 | 11, applicability_rank, | ||
1428 | 12, 0 /* avail-cert */, | ||
1429 | 13, 0 /* avail-rank */, | ||
1430 | -1); | ||
1431 | if (tab != NULL) | ||
1432 | { | 1266 | { |
1433 | while (tab->parent != NULL) | 1267 | pitr = &pmem; |
1434 | tab = tab->parent->tab; | ||
1435 | tab->num_results++; | ||
1436 | } | 1268 | } |
1269 | ts = GTK_TREE_STORE (tm); | ||
1270 | } | ||
1271 | else | ||
1272 | { | ||
1273 | /* top-level result */ | ||
1274 | pitr = NULL; | ||
1275 | ts = tab->ts; | ||
1276 | } | ||
1277 | gtk_tree_store_insert_with_values (ts, iter, pitr, G_MAXINT, 0, | ||
1278 | GNUNET_CONTAINER_meta_data_duplicate | ||
1279 | (meta), 1, | ||
1280 | (uri == | ||
1281 | NULL) ? NULL : GNUNET_FS_uri_dup (uri), 2, | ||
1282 | (uri == NULL) ? 0 : fsize, 3, | ||
1283 | pixbuf /* preview */ , | ||
1284 | 4, 0 /* percent progress */ , | ||
1285 | 5, 0 /* percent availability */ , | ||
1286 | 6, desc /* filename/description */ , | ||
1287 | 7, uris, 8, status_colour, 9, sr, 10, mime, | ||
1288 | 11, applicability_rank, 12, | ||
1289 | 0 /* avail-cert */ , | ||
1290 | 13, 0 /* avail-rank */ , | ||
1291 | -1); | ||
1292 | if (tab != NULL) | ||
1293 | { | ||
1294 | while (tab->parent != NULL) | ||
1295 | tab = tab->parent->tab; | ||
1296 | tab->num_results++; | ||
1297 | } | ||
1437 | if (pixbuf != NULL) | 1298 | if (pixbuf != NULL) |
1438 | g_object_unref (pixbuf); | 1299 | g_object_unref (pixbuf); |
1439 | GNUNET_free (uris); | 1300 | GNUNET_free (uris); |
1440 | GNUNET_free (desc); | 1301 | GNUNET_free (desc); |
1441 | GNUNET_free_non_null (mime); | 1302 | GNUNET_free_non_null (mime); |
1442 | tp = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), | 1303 | tp = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), iter); |
1443 | iter); | 1304 | sr->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts), tp); |
1444 | sr->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts), | ||
1445 | tp); | ||
1446 | gtk_tree_path_free (tp); | 1305 | gtk_tree_path_free (tp); |
1447 | return sr; | 1306 | return sr; |
1448 | } | 1307 | } |
1449 | 1308 | ||
1450 | 1309 | ||
1451 | static struct SearchResult * | 1310 | static struct SearchResult * |
1452 | process_search_result (void *cls, | 1311 | process_search_result (void *cls, struct SearchResult *parent, |
1453 | struct SearchResult *parent, | 1312 | const struct GNUNET_FS_Uri *uri, |
1454 | const struct GNUNET_FS_Uri *uri, | 1313 | const struct GNUNET_CONTAINER_MetaData *meta, |
1455 | const struct GNUNET_CONTAINER_MetaData *meta, | 1314 | struct GNUNET_FS_SearchResult *result, |
1456 | struct GNUNET_FS_SearchResult *result, | 1315 | uint32_t applicability_rank) |
1457 | uint32_t applicability_rank) | ||
1458 | { | 1316 | { |
1459 | struct SearchTab *tab = cls; | 1317 | struct SearchTab *tab = cls; |
1460 | struct SearchResult *sr; | 1318 | struct SearchResult *sr; |
1461 | GtkTreeIter iter; | 1319 | GtkTreeIter iter; |
1462 | 1320 | ||
1463 | sr = GNUNET_GTK_add_search_result (tab, &iter, | 1321 | sr = GNUNET_GTK_add_search_result (tab, &iter, |
1464 | (parent != NULL) ? parent->rr : NULL, | 1322 | (parent != NULL) ? parent->rr : NULL, uri, |
1465 | uri, | 1323 | meta, result, applicability_rank); |
1466 | meta, result, applicability_rank); | ||
1467 | update_search_label (tab); | 1324 | update_search_label (tab); |
1468 | return sr; | 1325 | return sr; |
1469 | } | 1326 | } |
@@ -1480,10 +1337,9 @@ process_search_result (void *cls, | |||
1480 | * @return NULL on error, otherwise tree store matching iter | 1337 | * @return NULL on error, otherwise tree store matching iter |
1481 | */ | 1338 | */ |
1482 | struct SearchTab * | 1339 | struct SearchTab * |
1483 | GNUNET_GTK_add_to_uri_tab (GtkTreeIter *iter, | 1340 | GNUNET_GTK_add_to_uri_tab (GtkTreeIter * iter, struct SearchResult **srp, |
1484 | struct SearchResult **srp, | 1341 | const struct GNUNET_CONTAINER_MetaData *meta, |
1485 | const struct GNUNET_CONTAINER_MetaData *meta, | 1342 | const struct GNUNET_FS_Uri *uri) |
1486 | const struct GNUNET_FS_Uri *uri) | ||
1487 | { | 1343 | { |
1488 | struct SearchTab *utab; | 1344 | struct SearchTab *utab; |
1489 | struct SearchResult *sr; | 1345 | struct SearchResult *sr; |
@@ -1492,37 +1348,32 @@ GNUNET_GTK_add_to_uri_tab (GtkTreeIter *iter, | |||
1492 | 1348 | ||
1493 | utab = search_tab_head; | 1349 | utab = search_tab_head; |
1494 | while (utab != NULL) | 1350 | while (utab != NULL) |
1495 | { | 1351 | { |
1496 | if (utab->sc == NULL) | 1352 | if (utab->sc == NULL) |
1497 | break; | 1353 | break; |
1498 | utab = utab->next; | 1354 | utab = utab->next; |
1499 | } | 1355 | } |
1500 | if (utab == NULL) | 1356 | if (utab == NULL) |
1501 | { | 1357 | { |
1502 | utab = setup_search (NULL, NULL); | 1358 | utab = setup_search (NULL, NULL); |
1503 | gtk_widget_set_visible (utab->close_button, | 1359 | gtk_widget_set_visible (utab->close_button, FALSE); |
1504 | FALSE); | 1360 | gtk_widget_set_visible (utab->pause_button, FALSE); |
1505 | gtk_widget_set_visible (utab->pause_button, | 1361 | } |
1506 | FALSE); | ||
1507 | } | ||
1508 | else | 1362 | else |
1509 | { | 1363 | { |
1510 | /* make 'utab' the current page */ | 1364 | /* make 'utab' the current page */ |
1511 | notebook = GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_notebook")); | 1365 | notebook = |
1512 | for (page=0;page<gtk_notebook_get_n_pages (notebook);page++) | 1366 | GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object |
1513 | if (utab->frame == | 1367 | ("GNUNET_GTK_main_window_notebook")); |
1514 | gtk_notebook_get_nth_page (notebook, | 1368 | for (page = 0; page < gtk_notebook_get_n_pages (notebook); page++) |
1515 | page)) | 1369 | if (utab->frame == gtk_notebook_get_nth_page (notebook, page)) |
1516 | { | 1370 | { |
1517 | gtk_notebook_set_current_page (notebook, | 1371 | gtk_notebook_set_current_page (notebook, page); |
1518 | page); | 1372 | break; |
1519 | break; | 1373 | } |
1520 | } | 1374 | } |
1521 | } | 1375 | sr = GNUNET_GTK_add_search_result (utab, iter, NULL, uri, meta, NULL, 0); |
1522 | sr = GNUNET_GTK_add_search_result (utab, iter, | 1376 | |
1523 | NULL, uri, meta, | ||
1524 | NULL, 0); | ||
1525 | |||
1526 | if (NULL != srp) | 1377 | if (NULL != srp) |
1527 | *srp = sr; | 1378 | *srp = sr; |
1528 | return utab; | 1379 | return utab; |
@@ -1530,8 +1381,7 @@ GNUNET_GTK_add_to_uri_tab (GtkTreeIter *iter, | |||
1530 | 1381 | ||
1531 | 1382 | ||
1532 | static struct SearchTab * | 1383 | static struct SearchTab * |
1533 | handle_search_error (struct SearchTab *sr, | 1384 | handle_search_error (struct SearchTab *sr, const char *emsg) |
1534 | const char *emsg) | ||
1535 | { | 1385 | { |
1536 | /* FIXME: implement error handler */ | 1386 | /* FIXME: implement error handler */ |
1537 | GNUNET_break (0); | 1387 | GNUNET_break (0); |
@@ -1541,10 +1391,10 @@ handle_search_error (struct SearchTab *sr, | |||
1541 | 1391 | ||
1542 | static struct SearchResult * | 1392 | static struct SearchResult * |
1543 | update_search_result (struct SearchResult *sr, | 1393 | update_search_result (struct SearchResult *sr, |
1544 | const struct GNUNET_CONTAINER_MetaData *meta, | 1394 | const struct GNUNET_CONTAINER_MetaData *meta, |
1545 | int32_t availability_rank, | 1395 | int32_t availability_rank, |
1546 | uint32_t availability_certainty, | 1396 | uint32_t availability_certainty, |
1547 | uint32_t applicability_rank) | 1397 | uint32_t applicability_rank) |
1548 | { | 1398 | { |
1549 | GtkTreeIter iter; | 1399 | GtkTreeIter iter; |
1550 | struct GNUNET_CONTAINER_MetaData *ometa; | 1400 | struct GNUNET_CONTAINER_MetaData *ometa; |
@@ -1561,67 +1411,64 @@ update_search_result (struct SearchResult *sr, | |||
1561 | 1411 | ||
1562 | if (sr == NULL) | 1412 | if (sr == NULL) |
1563 | return NULL; | 1413 | return NULL; |
1564 | desc = GNUNET_CONTAINER_meta_data_get_first_by_types (meta, | 1414 | desc = |
1565 | EXTRACTOR_METATYPE_PACKAGE_NAME, | 1415 | GNUNET_CONTAINER_meta_data_get_first_by_types (meta, |
1566 | EXTRACTOR_METATYPE_TITLE, | 1416 | EXTRACTOR_METATYPE_PACKAGE_NAME, |
1567 | EXTRACTOR_METATYPE_BOOK_TITLE, | 1417 | EXTRACTOR_METATYPE_TITLE, |
1568 | EXTRACTOR_METATYPE_FILENAME, | 1418 | EXTRACTOR_METATYPE_BOOK_TITLE, |
1569 | EXTRACTOR_METATYPE_DESCRIPTION, | 1419 | EXTRACTOR_METATYPE_FILENAME, |
1570 | EXTRACTOR_METATYPE_SUMMARY, | 1420 | EXTRACTOR_METATYPE_DESCRIPTION, |
1571 | EXTRACTOR_METATYPE_ALBUM, | 1421 | EXTRACTOR_METATYPE_SUMMARY, |
1572 | EXTRACTOR_METATYPE_COMMENT, | 1422 | EXTRACTOR_METATYPE_ALBUM, |
1573 | EXTRACTOR_METATYPE_SUBJECT, | 1423 | EXTRACTOR_METATYPE_COMMENT, |
1574 | EXTRACTOR_METATYPE_KEYWORDS, | 1424 | EXTRACTOR_METATYPE_SUBJECT, |
1575 | -1); | 1425 | EXTRACTOR_METATYPE_KEYWORDS, |
1426 | -1); | ||
1576 | if (desc == NULL) | 1427 | if (desc == NULL) |
1577 | desc = GNUNET_strdup (_("no description supplied")); | 1428 | desc = GNUNET_strdup (_("no description supplied")); |
1578 | mime = GNUNET_CONTAINER_meta_data_get_first_by_types (meta, | 1429 | mime = |
1579 | EXTRACTOR_METATYPE_MIMETYPE, | 1430 | GNUNET_CONTAINER_meta_data_get_first_by_types (meta, |
1580 | EXTRACTOR_METATYPE_FORMAT, | 1431 | EXTRACTOR_METATYPE_MIMETYPE, |
1581 | -1); | 1432 | EXTRACTOR_METATYPE_FORMAT, |
1433 | -1); | ||
1582 | pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta); | 1434 | pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta); |
1583 | tp = gtk_tree_row_reference_get_path (sr->rr); | 1435 | tp = gtk_tree_row_reference_get_path (sr->rr); |
1584 | tm = gtk_tree_row_reference_get_model (sr->rr); | 1436 | tm = gtk_tree_row_reference_get_model (sr->rr); |
1585 | ts = GTK_TREE_STORE (tm); | 1437 | ts = GTK_TREE_STORE (tm); |
1586 | gtk_tree_model_get_iter (tm, &iter, tp); | 1438 | gtk_tree_model_get_iter (tm, &iter, tp); |
1587 | gtk_tree_path_free (tp); | 1439 | gtk_tree_path_free (tp); |
1588 | gtk_tree_model_get (tm, | 1440 | gtk_tree_model_get (tm, &iter, 0, &ometa, -1); |
1589 | &iter, | ||
1590 | 0, &ometa, | ||
1591 | -1); | ||
1592 | if (meta != NULL) | 1441 | if (meta != NULL) |
1593 | GNUNET_CONTAINER_meta_data_destroy (ometa); | 1442 | GNUNET_CONTAINER_meta_data_destroy (ometa); |
1594 | if (availability_certainty > 0) | 1443 | if (availability_certainty > 0) |
1595 | percent_avail = (availability_certainty + availability_rank) * 50 / availability_certainty; | 1444 | percent_avail = |
1445 | (availability_certainty + | ||
1446 | availability_rank) * 50 / availability_certainty; | ||
1596 | else | 1447 | else |
1597 | percent_avail = 0; | 1448 | percent_avail = 0; |
1598 | gtk_tree_store_set (ts, | 1449 | gtk_tree_store_set (ts, &iter, 0, GNUNET_CONTAINER_meta_data_duplicate (meta), |
1599 | &iter, | 1450 | 3, pixbuf /* preview */ , |
1600 | 0, GNUNET_CONTAINER_meta_data_duplicate (meta), | 1451 | 5, (guint) percent_avail /* percent availability */ , |
1601 | 3, pixbuf /* preview */, | 1452 | 6, desc /* filename/description */ , |
1602 | 5, (guint) percent_avail /* percent availability */, | 1453 | 10, mime, 11, (guint) applicability_rank, 12, |
1603 | 6, desc /* filename/description */, | 1454 | (guint) availability_certainty, 13, |
1604 | 10, mime, | 1455 | (gint) availability_rank, -1); |
1605 | 11, (guint) applicability_rank, | ||
1606 | 12, (guint) availability_certainty, | ||
1607 | 13, (gint) availability_rank, | ||
1608 | -1); | ||
1609 | if (pixbuf != NULL) | 1456 | if (pixbuf != NULL) |
1610 | g_object_unref (pixbuf); | 1457 | g_object_unref (pixbuf); |
1611 | GNUNET_free (desc); | 1458 | GNUNET_free (desc); |
1612 | GNUNET_free_non_null (mime); | 1459 | GNUNET_free_non_null (mime); |
1613 | 1460 | ||
1614 | notebook = GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_notebook")); | 1461 | notebook = |
1462 | GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object | ||
1463 | ("GNUNET_GTK_main_window_notebook")); | ||
1615 | page = gtk_notebook_get_current_page (notebook); | 1464 | page = gtk_notebook_get_current_page (notebook); |
1616 | if (gtk_notebook_get_nth_page (notebook, | 1465 | if (gtk_notebook_get_nth_page (notebook, page) == sr->tab->frame) |
1617 | page) == sr->tab->frame) | 1466 | { |
1618 | { | 1467 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1619 | tv = GTK_TREE_VIEW (gtk_builder_get_object (sr->tab->builder, | 1468 | (sr->tab->builder, "_search_result_frame")); |
1620 | "_search_result_frame")); | ||
1621 | 1469 | ||
1622 | update_meta_data_views (tv, | 1470 | update_meta_data_views (tv, sr->tab); |
1623 | sr->tab); | 1471 | } |
1624 | } | ||
1625 | return sr; | 1472 | return sr; |
1626 | } | 1473 | } |
1627 | 1474 | ||
@@ -1636,26 +1483,21 @@ free_search_result (struct SearchResult *sr) | |||
1636 | struct GNUNET_CONTAINER_MetaData *meta; | 1483 | struct GNUNET_CONTAINER_MetaData *meta; |
1637 | 1484 | ||
1638 | if (sr == NULL) | 1485 | if (sr == NULL) |
1639 | { | 1486 | { |
1640 | GNUNET_break (0); | 1487 | GNUNET_break (0); |
1641 | return; | 1488 | return; |
1642 | } | 1489 | } |
1643 | tp = gtk_tree_row_reference_get_path (sr->rr); | 1490 | tp = gtk_tree_row_reference_get_path (sr->rr); |
1644 | tm = gtk_tree_row_reference_get_model (sr->rr); | 1491 | tm = gtk_tree_row_reference_get_model (sr->rr); |
1645 | gtk_tree_model_get_iter (tm, &iter, tp); | 1492 | gtk_tree_model_get_iter (tm, &iter, tp); |
1646 | gtk_tree_path_free (tp); | 1493 | gtk_tree_path_free (tp); |
1647 | gtk_tree_model_get (tm, | 1494 | gtk_tree_model_get (tm, &iter, 0, &meta, 1, &uri, -1); |
1648 | &iter, | ||
1649 | 0, &meta, | ||
1650 | 1, &uri, | ||
1651 | -1); | ||
1652 | if (uri != NULL) | 1495 | if (uri != NULL) |
1653 | GNUNET_FS_uri_destroy (uri); | 1496 | GNUNET_FS_uri_destroy (uri); |
1654 | if (meta != NULL) | 1497 | if (meta != NULL) |
1655 | GNUNET_CONTAINER_meta_data_destroy (meta); | 1498 | GNUNET_CONTAINER_meta_data_destroy (meta); |
1656 | gtk_tree_row_reference_free (sr->rr); | 1499 | gtk_tree_row_reference_free (sr->rr); |
1657 | gtk_tree_store_remove (GTK_TREE_STORE (tm), | 1500 | gtk_tree_store_remove (GTK_TREE_STORE (tm), &iter); |
1658 | &iter); | ||
1659 | GNUNET_free (sr); | 1501 | GNUNET_free (sr); |
1660 | } | 1502 | } |
1661 | 1503 | ||
@@ -1664,25 +1506,22 @@ free_search_result (struct SearchResult *sr) | |||
1664 | * Tell FS to stop publishing. | 1506 | * Tell FS to stop publishing. |
1665 | */ | 1507 | */ |
1666 | static void | 1508 | static void |
1667 | stop_publishing (GtkButton *button, | 1509 | stop_publishing (GtkButton * button, gpointer user_data) |
1668 | gpointer user_data) | ||
1669 | { | 1510 | { |
1670 | struct PublishTab *tab = user_data; | 1511 | struct PublishTab *tab = user_data; |
1671 | struct GNUNET_FS_PublishContext *pc; | 1512 | struct GNUNET_FS_PublishContext *pc; |
1672 | 1513 | ||
1673 | if (NULL != (pc = tab->pc)) | 1514 | if (NULL != (pc = tab->pc)) |
1674 | { | 1515 | { |
1675 | tab->pc = NULL; | 1516 | tab->pc = NULL; |
1676 | GNUNET_FS_publish_stop (pc); | 1517 | GNUNET_FS_publish_stop (pc); |
1677 | } | 1518 | } |
1678 | } | 1519 | } |
1679 | 1520 | ||
1680 | 1521 | ||
1681 | static struct PublishEntry * | 1522 | static struct PublishEntry * |
1682 | setup_publish (struct GNUNET_FS_PublishContext *pc, | 1523 | setup_publish (struct GNUNET_FS_PublishContext *pc, const char *fn, |
1683 | const char *fn, | 1524 | uint64_t fsize, struct PublishEntry *parent) |
1684 | uint64_t fsize, | ||
1685 | struct PublishEntry *parent) | ||
1686 | { | 1525 | { |
1687 | struct PublishTab *tab; | 1526 | struct PublishTab *tab; |
1688 | struct PublishEntry *ent; | 1527 | struct PublishEntry *ent; |
@@ -1699,79 +1538,74 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, | |||
1699 | char *size_fancy; | 1538 | char *size_fancy; |
1700 | 1539 | ||
1701 | if (NULL == parent) | 1540 | if (NULL == parent) |
1702 | { | 1541 | { |
1703 | /* create new tab */ | 1542 | /* create new tab */ |
1704 | tab = GNUNET_malloc (sizeof (struct PublishTab)); | 1543 | tab = GNUNET_malloc (sizeof (struct PublishTab)); |
1705 | tab->pc = pc; | 1544 | tab->pc = pc; |
1706 | GNUNET_CONTAINER_DLL_insert (publish_tab_head, | 1545 | GNUNET_CONTAINER_DLL_insert (publish_tab_head, publish_tab_tail, tab); |
1707 | publish_tab_tail, | 1546 | tab->builder = |
1708 | tab); | 1547 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_tab.glade"); |
1709 | tab->builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_tab.glade"); | 1548 | df = GTK_WINDOW (gtk_builder_get_object |
1710 | df = GTK_WINDOW (gtk_builder_get_object (tab->builder, | 1549 | (tab->builder, "_publish_frame_window")); |
1711 | "_publish_frame_window")); | 1550 | tab->frame = gtk_bin_get_child (GTK_BIN (df)); |
1712 | tab->frame = gtk_bin_get_child (GTK_BIN (df)); | 1551 | gtk_widget_ref (tab->frame); |
1713 | gtk_widget_ref (tab->frame); | 1552 | gtk_container_remove (GTK_CONTAINER (df), tab->frame); |
1714 | gtk_container_remove (GTK_CONTAINER (df), tab->frame); | 1553 | gtk_widget_destroy (GTK_WIDGET (df)); |
1715 | gtk_widget_destroy (GTK_WIDGET (df)); | 1554 | |
1716 | 1555 | /* load tab_label */ | |
1717 | /* load tab_label */ | 1556 | df = GTK_WINDOW (gtk_builder_get_object |
1718 | df = GTK_WINDOW (gtk_builder_get_object (tab->builder, | 1557 | (tab->builder, "_publish_label_window")); |
1719 | "_publish_label_window")); | 1558 | tab_label = gtk_bin_get_child (GTK_BIN (df)); |
1720 | tab_label = gtk_bin_get_child (GTK_BIN (df)); | 1559 | gtk_widget_ref (tab_label); |
1721 | gtk_widget_ref (tab_label); | 1560 | gtk_container_remove (GTK_CONTAINER (df), tab_label); |
1722 | gtk_container_remove (GTK_CONTAINER (df), tab_label); | 1561 | gtk_widget_destroy (GTK_WIDGET (df)); |
1723 | gtk_widget_destroy (GTK_WIDGET (df)); | 1562 | |
1724 | 1563 | /* get refs to widgets */ | |
1725 | /* get refs to widgets */ | 1564 | fn_label = |
1726 | fn_label = GTK_LABEL (gtk_builder_get_object (tab->builder, | 1565 | GTK_LABEL (gtk_builder_get_object |
1727 | "_publish_label_window_label")); | 1566 | (tab->builder, "_publish_label_window_label")); |
1728 | gtk_label_set_text (fn_label, fn); | 1567 | gtk_label_set_text (fn_label, fn); |
1729 | close_button = GTK_WIDGET (gtk_builder_get_object (tab->builder, | 1568 | close_button = |
1730 | "_publish_label_close_button")); | 1569 | GTK_WIDGET (gtk_builder_get_object |
1731 | g_signal_connect(G_OBJECT(close_button), "clicked", | 1570 | (tab->builder, "_publish_label_close_button")); |
1732 | G_CALLBACK(stop_publishing), tab); | 1571 | g_signal_connect (G_OBJECT (close_button), "clicked", |
1733 | /* make visible */ | 1572 | G_CALLBACK (stop_publishing), tab); |
1734 | notebook = GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_notebook")); | 1573 | /* make visible */ |
1735 | pages = gtk_notebook_get_n_pages (notebook); | 1574 | notebook = |
1736 | gtk_notebook_insert_page (notebook, | 1575 | GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object |
1737 | tab->frame, | 1576 | ("GNUNET_GTK_main_window_notebook")); |
1738 | tab_label, | 1577 | pages = gtk_notebook_get_n_pages (notebook); |
1739 | pages - 1); | 1578 | gtk_notebook_insert_page (notebook, tab->frame, tab_label, pages - 1); |
1740 | gtk_widget_show (GTK_WIDGET (notebook)); | 1579 | gtk_widget_show (GTK_WIDGET (notebook)); |
1741 | tab->ts = GTK_TREE_STORE (gtk_builder_get_object (tab->builder, | 1580 | tab->ts = |
1742 | "_publish_frame_tree_store")); | 1581 | GTK_TREE_STORE (gtk_builder_get_object |
1743 | pitrptr = NULL; | 1582 | (tab->builder, "_publish_frame_tree_store")); |
1744 | } | 1583 | pitrptr = NULL; |
1584 | } | ||
1745 | else | 1585 | else |
1586 | { | ||
1587 | /* create new iter from parent */ | ||
1588 | tab = parent->tab; | ||
1589 | path = gtk_tree_row_reference_get_path (parent->rr); | ||
1590 | if (TRUE != | ||
1591 | gtk_tree_model_get_iter (GTK_TREE_MODEL (tab->ts), &piter, path)) | ||
1746 | { | 1592 | { |
1747 | /* create new iter from parent */ | 1593 | GNUNET_break (0); |
1748 | tab = parent->tab; | 1594 | return NULL; |
1749 | path = gtk_tree_row_reference_get_path (parent->rr); | ||
1750 | if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (tab->ts), | ||
1751 | &piter, path)) | ||
1752 | { | ||
1753 | GNUNET_break (0); | ||
1754 | return NULL; | ||
1755 | } | ||
1756 | pitrptr = &piter; | ||
1757 | } | 1595 | } |
1596 | pitrptr = &piter; | ||
1597 | } | ||
1758 | size_fancy = GNUNET_STRINGS_byte_size_fancy (fsize); | 1598 | size_fancy = GNUNET_STRINGS_byte_size_fancy (fsize); |
1759 | gtk_tree_store_insert_with_values (tab->ts, | 1599 | gtk_tree_store_insert_with_values (tab->ts, &iter, pitrptr, G_MAXINT, 0, fn, |
1760 | &iter, | 1600 | 1, size_fancy, 2, "white", 3, |
1761 | pitrptr, | 1601 | (guint) 0 /* progress */ , |
1762 | G_MAXINT, | 1602 | -1); |
1763 | 0, fn, | ||
1764 | 1, size_fancy, | ||
1765 | 2, "white", | ||
1766 | 3, (guint) 0 /* progress */, | ||
1767 | -1); | ||
1768 | GNUNET_free (size_fancy); | 1603 | GNUNET_free (size_fancy); |
1769 | ent = GNUNET_malloc (sizeof (struct PublishEntry)); | 1604 | ent = GNUNET_malloc (sizeof (struct PublishEntry)); |
1770 | ent->is_top = (parent == NULL) ? GNUNET_YES : GNUNET_NO; | 1605 | ent->is_top = (parent == NULL) ? GNUNET_YES : GNUNET_NO; |
1771 | ent->tab = tab; | 1606 | ent->tab = tab; |
1772 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (tab->ts), &iter); | 1607 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (tab->ts), &iter); |
1773 | ent->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (tab->ts), | 1608 | ent->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (tab->ts), path); |
1774 | path); | ||
1775 | gtk_tree_path_free (path); | 1609 | gtk_tree_path_free (path); |
1776 | ent->pc = pc; | 1610 | ent->pc = pc; |
1777 | return ent; | 1611 | return ent; |
@@ -1793,194 +1627,203 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, | |||
1793 | * will be passed to future callbacks in the respective | 1627 | * will be passed to future callbacks in the respective |
1794 | * field in the GNUNET_FS_ProgressInfo struct. | 1628 | * field in the GNUNET_FS_ProgressInfo struct. |
1795 | */ | 1629 | */ |
1796 | void* | 1630 | void * |
1797 | GNUNET_GTK_fs_event_handler (void *cls, | 1631 | GNUNET_GTK_fs_event_handler (void *cls, |
1798 | const struct GNUNET_FS_ProgressInfo *info) | 1632 | const struct GNUNET_FS_ProgressInfo *info) |
1799 | { | 1633 | { |
1800 | void *ret; | 1634 | void *ret; |
1801 | 1635 | ||
1802 | switch (info->status) | 1636 | switch (info->status) |
1803 | { | 1637 | { |
1804 | case GNUNET_FS_STATUS_PUBLISH_START: | 1638 | case GNUNET_FS_STATUS_PUBLISH_START: |
1805 | return setup_publish (info->value.publish.pc, | 1639 | return setup_publish (info->value.publish.pc, info->value.publish.filename, |
1806 | info->value.publish.filename, | 1640 | info->value.publish.size, info->value.publish.pctx); |
1807 | info->value.publish.size, | 1641 | case GNUNET_FS_STATUS_PUBLISH_RESUME: |
1808 | info->value.publish.pctx); | 1642 | ret = |
1809 | case GNUNET_FS_STATUS_PUBLISH_RESUME: | 1643 | setup_publish (info->value.publish.pc, info->value.publish.filename, |
1810 | ret = setup_publish (info->value.publish.pc, | 1644 | info->value.publish.size, info->value.publish.pctx); |
1811 | info->value.publish.filename, | 1645 | if (ret == NULL) |
1812 | info->value.publish.size, | ||
1813 | info->value.publish.pctx); | ||
1814 | if (ret == NULL) | ||
1815 | return ret; | ||
1816 | if (info->value.publish.specifics.resume.message != NULL) | ||
1817 | { | ||
1818 | ret = handle_publish_error (ret, | ||
1819 | info->value.publish.specifics.resume.message); | ||
1820 | } | ||
1821 | else if (info->value.publish.specifics.resume.chk_uri != NULL) | ||
1822 | { | ||
1823 | ret = handle_publish_completed (ret, | ||
1824 | info->value.publish.specifics.resume.chk_uri); | ||
1825 | } | ||
1826 | return ret; | ||
1827 | case GNUNET_FS_STATUS_PUBLISH_SUSPEND: | ||
1828 | close_publish_tab (info->value.publish.cctx); | ||
1829 | return NULL; | ||
1830 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: | ||
1831 | return mark_publish_progress (info->value.publish.cctx, | ||
1832 | info->value.publish.size, | ||
1833 | info->value.publish.completed); | ||
1834 | case GNUNET_FS_STATUS_PUBLISH_ERROR: | ||
1835 | return handle_publish_error (info->value.publish.cctx, | ||
1836 | info->value.publish.specifics.error.message); | ||
1837 | case GNUNET_FS_STATUS_PUBLISH_COMPLETED: | ||
1838 | return handle_publish_completed (info->value.publish.cctx, | ||
1839 | info->value.publish.specifics.completed.chk_uri); | ||
1840 | case GNUNET_FS_STATUS_PUBLISH_STOPPED: | ||
1841 | close_publish_tab (info->value.publish.cctx); | ||
1842 | return NULL; | ||
1843 | case GNUNET_FS_STATUS_DOWNLOAD_START: | ||
1844 | return setup_download (info->value.download.cctx, | ||
1845 | info->value.download.pctx, | ||
1846 | info->value.download.sctx, | ||
1847 | info->value.download.dc, | ||
1848 | info->value.download.uri, | ||
1849 | info->value.download.specifics.start.meta, | ||
1850 | info->value.download.size, | ||
1851 | info->value.download.completed); | ||
1852 | case GNUNET_FS_STATUS_DOWNLOAD_RESUME: | ||
1853 | ret = setup_download (info->value.download.cctx, | ||
1854 | info->value.download.pctx, | ||
1855 | info->value.download.sctx, | ||
1856 | info->value.download.dc, | ||
1857 | info->value.download.uri, | ||
1858 | info->value.download.specifics.resume.meta, | ||
1859 | info->value.download.size, | ||
1860 | info->value.download.completed); | ||
1861 | if (info->value.download.specifics.resume.message != NULL) | ||
1862 | { | ||
1863 | ret = mark_download_error (ret, | ||
1864 | info->value.download.specifics.resume.message); | ||
1865 | } | ||
1866 | return ret; | 1646 | return ret; |
1867 | case GNUNET_FS_STATUS_DOWNLOAD_SUSPEND: | 1647 | if (info->value.publish.specifics.resume.message != NULL) |
1868 | stop_download (info->value.download.cctx, GNUNET_YES); | 1648 | { |
1869 | return NULL; | 1649 | ret = |
1870 | case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: | 1650 | handle_publish_error (ret, |
1871 | return mark_download_progress (info->value.download.cctx, | 1651 | info->value.publish.specifics.resume.message); |
1872 | info->value.download.size, | ||
1873 | info->value.download.completed, | ||
1874 | info->value.download.specifics.progress.data, | ||
1875 | info->value.download.specifics.progress.offset, | ||
1876 | info->value.download.specifics.progress.data_len, | ||
1877 | info->value.download.specifics.progress.depth); | ||
1878 | case GNUNET_FS_STATUS_DOWNLOAD_ERROR: | ||
1879 | return mark_download_error (info->value.download.cctx, | ||
1880 | info->value.download.specifics.error.message); | ||
1881 | case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: | ||
1882 | return mark_download_completed (info->value.download.cctx, | ||
1883 | info->value.download.size, | ||
1884 | info->value.download.filename); | ||
1885 | case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: | ||
1886 | stop_download (info->value.download.cctx, GNUNET_NO); | ||
1887 | return NULL; | ||
1888 | case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: | ||
1889 | return change_download_colour (info->value.download.cctx, | ||
1890 | "yellow"); | ||
1891 | case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE: | ||
1892 | return change_download_colour (info->value.download.cctx, | ||
1893 | "blue"); | ||
1894 | case GNUNET_FS_STATUS_DOWNLOAD_LOST_PARENT: | ||
1895 | return download_lost_parent (info->value.download.cctx, | ||
1896 | info->value.download.size, | ||
1897 | info->value.download.completed, | ||
1898 | info->value.download.is_active); | ||
1899 | case GNUNET_FS_STATUS_SEARCH_START: | ||
1900 | if (info->value.search.pctx != NULL) | ||
1901 | return setup_inner_search (info->value.search.sc, | ||
1902 | info->value.search.pctx); | ||
1903 | return setup_search (info->value.search.sc, | ||
1904 | info->value.search.query); | ||
1905 | case GNUNET_FS_STATUS_SEARCH_RESUME: | ||
1906 | ret = setup_search (info->value.search.sc, | ||
1907 | info->value.search.query); | ||
1908 | if (info->value.search.specifics.resume.message) | ||
1909 | ret = handle_search_error (ret, | ||
1910 | info->value.search.specifics.resume.message); | ||
1911 | return ret; | ||
1912 | case GNUNET_FS_STATUS_SEARCH_RESUME_RESULT: | ||
1913 | ret = process_search_result (info->value.search.cctx, | ||
1914 | info->value.search.pctx, | ||
1915 | info->value.search.specifics.resume_result.uri, | ||
1916 | info->value.search.specifics.resume_result.meta, | ||
1917 | info->value.search.specifics.resume_result.result, | ||
1918 | info->value.search.specifics.resume_result.applicability_rank); | ||
1919 | return update_search_result (ret, | ||
1920 | info->value.search.specifics.resume_result.meta, | ||
1921 | info->value.search.specifics.resume_result.applicability_rank, | ||
1922 | info->value.search.specifics.resume_result.availability_certainty, | ||
1923 | info->value.search.specifics.resume_result.availability_rank); | ||
1924 | case GNUNET_FS_STATUS_SEARCH_SUSPEND: | ||
1925 | close_search_tab (info->value.search.cctx); | ||
1926 | return NULL; | ||
1927 | case GNUNET_FS_STATUS_SEARCH_RESULT: | ||
1928 | return process_search_result (info->value.search.cctx, | ||
1929 | info->value.search.pctx, | ||
1930 | info->value.search.specifics.result.uri, | ||
1931 | info->value.search.specifics.result.meta, | ||
1932 | info->value.search.specifics.result.result, | ||
1933 | info->value.search.specifics.result.applicability_rank); | ||
1934 | case GNUNET_FS_STATUS_SEARCH_RESULT_NAMESPACE: | ||
1935 | GNUNET_break (0); | ||
1936 | break; | ||
1937 | case GNUNET_FS_STATUS_SEARCH_UPDATE: | ||
1938 | return update_search_result (info->value.search.specifics.update.cctx, | ||
1939 | info->value.search.specifics.update.meta, | ||
1940 | info->value.search.specifics.update.applicability_rank, | ||
1941 | info->value.search.specifics.update.availability_certainty, | ||
1942 | info->value.search.specifics.update.availability_rank); | ||
1943 | case GNUNET_FS_STATUS_SEARCH_ERROR: | ||
1944 | return handle_search_error (info->value.search.cctx, | ||
1945 | info->value.search.specifics.error.message); | ||
1946 | case GNUNET_FS_STATUS_SEARCH_PAUSED: | ||
1947 | return info->value.search.cctx; | ||
1948 | case GNUNET_FS_STATUS_SEARCH_CONTINUED: | ||
1949 | return info->value.search.cctx; | ||
1950 | case GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED: | ||
1951 | free_search_result (info->value.search.specifics.result_suspend.cctx); | ||
1952 | return NULL; | ||
1953 | case GNUNET_FS_STATUS_SEARCH_RESULT_SUSPEND: | ||
1954 | free_search_result (info->value.search.specifics.result_suspend.cctx); | ||
1955 | return NULL; | ||
1956 | case GNUNET_FS_STATUS_SEARCH_STOPPED: | ||
1957 | close_search_tab (info->value.search.cctx); | ||
1958 | return NULL; | ||
1959 | case GNUNET_FS_STATUS_UNINDEX_START: | ||
1960 | GNUNET_break (0); | ||
1961 | break; | ||
1962 | case GNUNET_FS_STATUS_UNINDEX_RESUME: | ||
1963 | GNUNET_break (0); | ||
1964 | break; | ||
1965 | case GNUNET_FS_STATUS_UNINDEX_SUSPEND: | ||
1966 | GNUNET_break (0); | ||
1967 | break; | ||
1968 | case GNUNET_FS_STATUS_UNINDEX_PROGRESS: | ||
1969 | GNUNET_break (0); | ||
1970 | break; | ||
1971 | case GNUNET_FS_STATUS_UNINDEX_ERROR: | ||
1972 | GNUNET_break (0); | ||
1973 | break; | ||
1974 | case GNUNET_FS_STATUS_UNINDEX_COMPLETED: | ||
1975 | GNUNET_break (0); | ||
1976 | break; | ||
1977 | case GNUNET_FS_STATUS_UNINDEX_STOPPED: | ||
1978 | GNUNET_break (0); | ||
1979 | break; | ||
1980 | default: | ||
1981 | GNUNET_break (0); | ||
1982 | break; | ||
1983 | } | 1652 | } |
1653 | else if (info->value.publish.specifics.resume.chk_uri != NULL) | ||
1654 | { | ||
1655 | ret = | ||
1656 | handle_publish_completed (ret, | ||
1657 | info->value.publish.specifics. | ||
1658 | resume.chk_uri); | ||
1659 | } | ||
1660 | return ret; | ||
1661 | case GNUNET_FS_STATUS_PUBLISH_SUSPEND: | ||
1662 | close_publish_tab (info->value.publish.cctx); | ||
1663 | return NULL; | ||
1664 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: | ||
1665 | return mark_publish_progress (info->value.publish.cctx, | ||
1666 | info->value.publish.size, | ||
1667 | info->value.publish.completed); | ||
1668 | case GNUNET_FS_STATUS_PUBLISH_ERROR: | ||
1669 | return handle_publish_error (info->value.publish.cctx, | ||
1670 | info->value.publish.specifics.error.message); | ||
1671 | case GNUNET_FS_STATUS_PUBLISH_COMPLETED: | ||
1672 | return handle_publish_completed (info->value.publish.cctx, | ||
1673 | info->value.publish.specifics. | ||
1674 | completed.chk_uri); | ||
1675 | case GNUNET_FS_STATUS_PUBLISH_STOPPED: | ||
1676 | close_publish_tab (info->value.publish.cctx); | ||
1677 | return NULL; | ||
1678 | case GNUNET_FS_STATUS_DOWNLOAD_START: | ||
1679 | return setup_download (info->value.download.cctx, info->value.download.pctx, | ||
1680 | info->value.download.sctx, info->value.download.dc, | ||
1681 | info->value.download.uri, | ||
1682 | info->value.download.specifics.start.meta, | ||
1683 | info->value.download.size, | ||
1684 | info->value.download.completed); | ||
1685 | case GNUNET_FS_STATUS_DOWNLOAD_RESUME: | ||
1686 | ret = | ||
1687 | setup_download (info->value.download.cctx, info->value.download.pctx, | ||
1688 | info->value.download.sctx, info->value.download.dc, | ||
1689 | info->value.download.uri, | ||
1690 | info->value.download.specifics.resume.meta, | ||
1691 | info->value.download.size, | ||
1692 | info->value.download.completed); | ||
1693 | if (info->value.download.specifics.resume.message != NULL) | ||
1694 | { | ||
1695 | ret = | ||
1696 | mark_download_error (ret, | ||
1697 | info->value.download.specifics.resume.message); | ||
1698 | } | ||
1699 | return ret; | ||
1700 | case GNUNET_FS_STATUS_DOWNLOAD_SUSPEND: | ||
1701 | stop_download (info->value.download.cctx, GNUNET_YES); | ||
1702 | return NULL; | ||
1703 | case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: | ||
1704 | return mark_download_progress (info->value.download.cctx, | ||
1705 | info->value.download.size, | ||
1706 | info->value.download.completed, | ||
1707 | info->value.download.specifics.progress.data, | ||
1708 | info->value.download.specifics. | ||
1709 | progress.offset, | ||
1710 | info->value.download.specifics. | ||
1711 | progress.data_len, | ||
1712 | info->value.download.specifics. | ||
1713 | progress.depth); | ||
1714 | case GNUNET_FS_STATUS_DOWNLOAD_ERROR: | ||
1715 | return mark_download_error (info->value.download.cctx, | ||
1716 | info->value.download.specifics.error.message); | ||
1717 | case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: | ||
1718 | return mark_download_completed (info->value.download.cctx, | ||
1719 | info->value.download.size, | ||
1720 | info->value.download.filename); | ||
1721 | case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: | ||
1722 | stop_download (info->value.download.cctx, GNUNET_NO); | ||
1723 | return NULL; | ||
1724 | case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: | ||
1725 | return change_download_colour (info->value.download.cctx, "yellow"); | ||
1726 | case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE: | ||
1727 | return change_download_colour (info->value.download.cctx, "blue"); | ||
1728 | case GNUNET_FS_STATUS_DOWNLOAD_LOST_PARENT: | ||
1729 | return download_lost_parent (info->value.download.cctx, | ||
1730 | info->value.download.size, | ||
1731 | info->value.download.completed, | ||
1732 | info->value.download.is_active); | ||
1733 | case GNUNET_FS_STATUS_SEARCH_START: | ||
1734 | if (info->value.search.pctx != NULL) | ||
1735 | return setup_inner_search (info->value.search.sc, | ||
1736 | info->value.search.pctx); | ||
1737 | return setup_search (info->value.search.sc, info->value.search.query); | ||
1738 | case GNUNET_FS_STATUS_SEARCH_RESUME: | ||
1739 | ret = setup_search (info->value.search.sc, info->value.search.query); | ||
1740 | if (info->value.search.specifics.resume.message) | ||
1741 | ret = | ||
1742 | handle_search_error (ret, | ||
1743 | info->value.search.specifics.resume.message); | ||
1744 | return ret; | ||
1745 | case GNUNET_FS_STATUS_SEARCH_RESUME_RESULT: | ||
1746 | ret = | ||
1747 | process_search_result (info->value.search.cctx, info->value.search.pctx, | ||
1748 | info->value.search.specifics.resume_result.uri, | ||
1749 | info->value.search.specifics.resume_result.meta, | ||
1750 | info->value.search.specifics. | ||
1751 | resume_result.result, | ||
1752 | info->value.search.specifics. | ||
1753 | resume_result.applicability_rank); | ||
1754 | return update_search_result (ret, | ||
1755 | info->value.search.specifics. | ||
1756 | resume_result.meta, | ||
1757 | info->value.search.specifics. | ||
1758 | resume_result.applicability_rank, | ||
1759 | info->value.search.specifics. | ||
1760 | resume_result.availability_certainty, | ||
1761 | info->value.search.specifics. | ||
1762 | resume_result.availability_rank); | ||
1763 | case GNUNET_FS_STATUS_SEARCH_SUSPEND: | ||
1764 | close_search_tab (info->value.search.cctx); | ||
1765 | return NULL; | ||
1766 | case GNUNET_FS_STATUS_SEARCH_RESULT: | ||
1767 | return process_search_result (info->value.search.cctx, | ||
1768 | info->value.search.pctx, | ||
1769 | info->value.search.specifics.result.uri, | ||
1770 | info->value.search.specifics.result.meta, | ||
1771 | info->value.search.specifics.result.result, | ||
1772 | info->value.search.specifics. | ||
1773 | result.applicability_rank); | ||
1774 | case GNUNET_FS_STATUS_SEARCH_RESULT_NAMESPACE: | ||
1775 | GNUNET_break (0); | ||
1776 | break; | ||
1777 | case GNUNET_FS_STATUS_SEARCH_UPDATE: | ||
1778 | return update_search_result (info->value.search.specifics.update.cctx, | ||
1779 | info->value.search.specifics.update.meta, | ||
1780 | info->value.search.specifics. | ||
1781 | update.applicability_rank, | ||
1782 | info->value.search.specifics. | ||
1783 | update.availability_certainty, | ||
1784 | info->value.search.specifics. | ||
1785 | update.availability_rank); | ||
1786 | case GNUNET_FS_STATUS_SEARCH_ERROR: | ||
1787 | return handle_search_error (info->value.search.cctx, | ||
1788 | info->value.search.specifics.error.message); | ||
1789 | case GNUNET_FS_STATUS_SEARCH_PAUSED: | ||
1790 | return info->value.search.cctx; | ||
1791 | case GNUNET_FS_STATUS_SEARCH_CONTINUED: | ||
1792 | return info->value.search.cctx; | ||
1793 | case GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED: | ||
1794 | free_search_result (info->value.search.specifics.result_suspend.cctx); | ||
1795 | return NULL; | ||
1796 | case GNUNET_FS_STATUS_SEARCH_RESULT_SUSPEND: | ||
1797 | free_search_result (info->value.search.specifics.result_suspend.cctx); | ||
1798 | return NULL; | ||
1799 | case GNUNET_FS_STATUS_SEARCH_STOPPED: | ||
1800 | close_search_tab (info->value.search.cctx); | ||
1801 | return NULL; | ||
1802 | case GNUNET_FS_STATUS_UNINDEX_START: | ||
1803 | GNUNET_break (0); | ||
1804 | break; | ||
1805 | case GNUNET_FS_STATUS_UNINDEX_RESUME: | ||
1806 | GNUNET_break (0); | ||
1807 | break; | ||
1808 | case GNUNET_FS_STATUS_UNINDEX_SUSPEND: | ||
1809 | GNUNET_break (0); | ||
1810 | break; | ||
1811 | case GNUNET_FS_STATUS_UNINDEX_PROGRESS: | ||
1812 | GNUNET_break (0); | ||
1813 | break; | ||
1814 | case GNUNET_FS_STATUS_UNINDEX_ERROR: | ||
1815 | GNUNET_break (0); | ||
1816 | break; | ||
1817 | case GNUNET_FS_STATUS_UNINDEX_COMPLETED: | ||
1818 | GNUNET_break (0); | ||
1819 | break; | ||
1820 | case GNUNET_FS_STATUS_UNINDEX_STOPPED: | ||
1821 | GNUNET_break (0); | ||
1822 | break; | ||
1823 | default: | ||
1824 | GNUNET_break (0); | ||
1825 | break; | ||
1826 | } | ||
1984 | return NULL; | 1827 | return NULL; |
1985 | } | 1828 | } |
1986 | 1829 | ||
@@ -1990,8 +1833,8 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
1990 | * metadata views. | 1833 | * metadata views. |
1991 | */ | 1834 | */ |
1992 | void | 1835 | void |
1993 | GNUNET_GTK_main_window_notebook_switch_page_cb (GtkWidget * dummy, | 1836 | GNUNET_GTK_main_window_notebook_switch_page_cb (GtkWidget * dummy, |
1994 | gpointer data) | 1837 | gpointer data) |
1995 | { | 1838 | { |
1996 | GtkNotebook *notebook; | 1839 | GtkNotebook *notebook; |
1997 | gint page; | 1840 | gint page; |
@@ -2001,24 +1844,29 @@ GNUNET_GTK_main_window_notebook_switch_page_cb (GtkWidget * dummy, | |||
2001 | GtkListStore *ms; | 1844 | GtkListStore *ms; |
2002 | GtkTreeView *tv; | 1845 | GtkTreeView *tv; |
2003 | 1846 | ||
2004 | notebook = GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_notebook")); | 1847 | notebook = |
1848 | GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object | ||
1849 | ("GNUNET_GTK_main_window_notebook")); | ||
2005 | page = gtk_notebook_get_current_page (notebook); | 1850 | page = gtk_notebook_get_current_page (notebook); |
2006 | w = gtk_notebook_get_nth_page (notebook, page); | 1851 | w = gtk_notebook_get_nth_page (notebook, page); |
2007 | tab = search_tab_head; | 1852 | tab = search_tab_head; |
2008 | while (tab != NULL) | 1853 | while (tab != NULL) |
1854 | { | ||
1855 | if (tab->frame == w) | ||
2009 | { | 1856 | { |
2010 | if (tab->frame == w) | 1857 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
2011 | { | 1858 | (tab->builder, "_search_result_frame")); |
2012 | tv = GTK_TREE_VIEW (gtk_builder_get_object (tab->builder, | 1859 | update_meta_data_views (tv, tab); |
2013 | "_search_result_frame")); | 1860 | return; |
2014 | update_meta_data_views (tv, tab); | ||
2015 | return; | ||
2016 | } | ||
2017 | tab = tab->next; | ||
2018 | } | 1861 | } |
2019 | image = GTK_IMAGE (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_preview_image")); | 1862 | tab = tab->next; |
1863 | } | ||
1864 | image = | ||
1865 | GTK_IMAGE (GNUNET_FS_GTK_get_main_window_object | ||
1866 | ("GNUNET_GTK_main_window_preview_image")); | ||
2020 | gtk_image_clear (image); | 1867 | gtk_image_clear (image); |
2021 | ms = GTK_LIST_STORE (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_meta_data_list_store")); | 1868 | ms = GTK_LIST_STORE (GNUNET_FS_GTK_get_main_window_object |
1869 | ("GNUNET_GTK_meta_data_list_store")); | ||
2022 | gtk_list_store_clear (ms); | 1870 | gtk_list_store_clear (ms); |
2023 | } | 1871 | } |
2024 | 1872 | ||
diff --git a/src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c b/src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c index 0a157a42..1875204b 100644 --- a/src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c +++ b/src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c | |||
@@ -44,31 +44,28 @@ GNUNET_GTK_advertise_pseudonym_keyword_list_normalize_button_clicked_cb () | |||
44 | char *nvalue; | 44 | char *nvalue; |
45 | char *emsg; | 45 | char *emsg; |
46 | 46 | ||
47 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 47 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
48 | "GNUNET_GTK_advertise_pseudonym_keyword_list_tree_view")); | 48 | (builder, |
49 | "GNUNET_GTK_advertise_pseudonym_keyword_list_tree_view")); | ||
49 | sel = gtk_tree_view_get_selection (tv); | 50 | sel = gtk_tree_view_get_selection (tv); |
50 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) | 51 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
51 | { | 52 | { |
52 | GNUNET_break (0); | 53 | GNUNET_break (0); |
53 | return; | 54 | return; |
54 | } | 55 | } |
55 | gtk_tree_model_get (tm, &iter, | 56 | gtk_tree_model_get (tm, &iter, 0, &value, -1); |
56 | 0, &value, | ||
57 | -1); | ||
58 | emsg = NULL; | 57 | emsg = NULL; |
59 | uri = GNUNET_FS_uri_ksk_create (value, &emsg); | 58 | uri = GNUNET_FS_uri_ksk_create (value, &emsg); |
60 | if (uri == NULL) | 59 | if (uri == NULL) |
61 | { | 60 | { |
62 | GNUNET_break (0); | 61 | GNUNET_break (0); |
63 | GNUNET_free (emsg); | 62 | GNUNET_free (emsg); |
64 | g_free (value); | 63 | g_free (value); |
65 | return; | 64 | return; |
66 | } | 65 | } |
67 | nuri = GNUNET_FS_uri_ksk_canonicalize (uri); | 66 | nuri = GNUNET_FS_uri_ksk_canonicalize (uri); |
68 | nvalue = GNUNET_FS_uri_ksk_to_string_fancy (nuri); | 67 | nvalue = GNUNET_FS_uri_ksk_to_string_fancy (nuri); |
69 | gtk_list_store_set (GTK_LIST_STORE (tm), &iter, | 68 | gtk_list_store_set (GTK_LIST_STORE (tm), &iter, 0, nvalue, -1); |
70 | 0, nvalue, | ||
71 | -1); | ||
72 | GNUNET_FS_uri_destroy (nuri); | 69 | GNUNET_FS_uri_destroy (nuri); |
73 | GNUNET_FS_uri_destroy (uri); | 70 | GNUNET_FS_uri_destroy (uri); |
74 | GNUNET_free (nvalue); | 71 | GNUNET_free (nvalue); |
@@ -87,22 +84,22 @@ GNUNET_GTK_advertise_pseudonym_keyword_list_del_button_clicked_cb () | |||
87 | GtkTreeModel *tm; | 84 | GtkTreeModel *tm; |
88 | GtkTreeIter iter; | 85 | GtkTreeIter iter; |
89 | 86 | ||
90 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 87 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
91 | "GNUNET_GTK_advertise_pseudonym_keyword_list_tree_view")); | 88 | (builder, |
89 | "GNUNET_GTK_advertise_pseudonym_keyword_list_tree_view")); | ||
92 | sel = gtk_tree_view_get_selection (tv); | 90 | sel = gtk_tree_view_get_selection (tv); |
93 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) | 91 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
94 | { | 92 | { |
95 | GNUNET_break (0); | 93 | GNUNET_break (0); |
96 | return; | 94 | return; |
97 | } | 95 | } |
98 | gtk_list_store_remove (GTK_LIST_STORE (tm), | 96 | gtk_list_store_remove (GTK_LIST_STORE (tm), &iter); |
99 | &iter); | ||
100 | } | 97 | } |
101 | 98 | ||
102 | 99 | ||
103 | /** | 100 | /** |
104 | * Add keyword from entry line to keyword list. | 101 | * Add keyword from entry line to keyword list. |
105 | */ | 102 | */ |
106 | void | 103 | void |
107 | GNUNET_GTK_advertise_pseudonym_keyword_list_add_button_clicked_cb () | 104 | GNUNET_GTK_advertise_pseudonym_keyword_list_add_button_clicked_cb () |
108 | { | 105 | { |
@@ -111,10 +108,11 @@ GNUNET_GTK_advertise_pseudonym_keyword_list_add_button_clicked_cb () | |||
111 | GtkListStore *ls; | 108 | GtkListStore *ls; |
112 | GtkTreeIter iter; | 109 | GtkTreeIter iter; |
113 | 110 | ||
114 | ls = GTK_LIST_STORE (gtk_builder_get_object (builder, | 111 | ls = GTK_LIST_STORE (gtk_builder_get_object |
115 | "GNUNET_GTK_keyword_list_store")); | 112 | (builder, "GNUNET_GTK_keyword_list_store")); |
116 | entry = GTK_ENTRY (gtk_builder_get_object (builder, | 113 | entry = |
117 | "GNUNET_GTK_advertise_pseudonym_keyword_entry")); | 114 | GTK_ENTRY (gtk_builder_get_object |
115 | (builder, "GNUNET_GTK_advertise_pseudonym_keyword_entry")); | ||
118 | keyword = gtk_entry_get_text (entry); | 116 | keyword = gtk_entry_get_text (entry); |
119 | if (strlen (keyword) > 0) | 117 | if (strlen (keyword) > 0) |
120 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, 0, keyword, -1); | 118 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, 0, keyword, -1); |
@@ -132,33 +130,37 @@ GNUNET_GTK_advertise_pseudonym_keyword_entry_changed_cb () | |||
132 | GtkEntry *entry; | 130 | GtkEntry *entry; |
133 | GtkWidget *button; | 131 | GtkWidget *button; |
134 | 132 | ||
135 | button = GTK_WIDGET (gtk_builder_get_object (builder, | 133 | button = |
136 | "GNUNET_GTK_advertise_pseudonym_keyword_list_add_button")); | 134 | GTK_WIDGET (gtk_builder_get_object |
137 | entry = GTK_ENTRY (gtk_builder_get_object (builder, | 135 | (builder, |
138 | "GNUNET_GTK_advertise_pseudonym_keyword_entry")); | 136 | "GNUNET_GTK_advertise_pseudonym_keyword_list_add_button")); |
137 | entry = | ||
138 | GTK_ENTRY (gtk_builder_get_object | ||
139 | (builder, "GNUNET_GTK_advertise_pseudonym_keyword_entry")); | ||
139 | keyword = gtk_entry_get_text (entry); | 140 | keyword = gtk_entry_get_text (entry); |
140 | gtk_widget_set_sensitive (button, | 141 | gtk_widget_set_sensitive (button, (strlen (keyword) > 0) ? TRUE : FALSE); |
141 | (strlen (keyword) > 0) ? TRUE : FALSE); | ||
142 | } | 142 | } |
143 | 143 | ||
144 | /** | 144 | /** |
145 | * Update sensitivity of metadata delete button. | 145 | * Update sensitivity of metadata delete button. |
146 | */ | 146 | */ |
147 | static void | 147 | static void |
148 | metadata_selection_changed_cb (GtkTreeSelection *ts, | 148 | metadata_selection_changed_cb (GtkTreeSelection * ts, gpointer user_data) |
149 | gpointer user_data) | ||
150 | { | 149 | { |
151 | GtkTreeView *tv; | 150 | GtkTreeView *tv; |
152 | GtkTreeSelection *sel; | 151 | GtkTreeSelection *sel; |
153 | GtkWidget *button; | 152 | GtkWidget *button; |
154 | 153 | ||
155 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 154 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
156 | "GNUNET_GTK_advertise_pseudonym_metadata_tree_view")); | 155 | (builder, |
156 | "GNUNET_GTK_advertise_pseudonym_metadata_tree_view")); | ||
157 | sel = gtk_tree_view_get_selection (tv); | 157 | sel = gtk_tree_view_get_selection (tv); |
158 | button = GTK_WIDGET (gtk_builder_get_object (builder, | 158 | button = |
159 | "GNUNET_GTK_advertise_pseudonym_metadata_delete_button")); | 159 | GTK_WIDGET (gtk_builder_get_object |
160 | (builder, | ||
161 | "GNUNET_GTK_advertise_pseudonym_metadata_delete_button")); | ||
160 | gtk_widget_set_sensitive (button, | 162 | gtk_widget_set_sensitive (button, |
161 | gtk_tree_selection_get_selected (sel, NULL, NULL)); | 163 | gtk_tree_selection_get_selected (sel, NULL, NULL)); |
162 | } | 164 | } |
163 | 165 | ||
164 | 166 | ||
@@ -166,25 +168,29 @@ metadata_selection_changed_cb (GtkTreeSelection *ts, | |||
166 | * Update sensitivity of keyword delete and normalize button. | 168 | * Update sensitivity of keyword delete and normalize button. |
167 | */ | 169 | */ |
168 | static void | 170 | static void |
169 | keyword_selection_changed_cb (GtkTreeSelection *ts, | 171 | keyword_selection_changed_cb (GtkTreeSelection * ts, gpointer user_data) |
170 | gpointer user_data) | ||
171 | { | 172 | { |
172 | GtkTreeView *tv; | 173 | GtkTreeView *tv; |
173 | GtkTreeSelection *sel; | 174 | GtkTreeSelection *sel; |
174 | GtkWidget *button; | 175 | GtkWidget *button; |
175 | 176 | ||
176 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 177 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
177 | "GNUNET_GTK_advertise_pseudonym_keyword_list_tree_view")); | 178 | (builder, |
179 | "GNUNET_GTK_advertise_pseudonym_keyword_list_tree_view")); | ||
178 | sel = gtk_tree_view_get_selection (tv); | 180 | sel = gtk_tree_view_get_selection (tv); |
179 | button = GTK_WIDGET (gtk_builder_get_object (builder, | 181 | button = |
180 | "GNUNET_GTK_advertise_pseudonym_keyword_list_del_button")); | 182 | GTK_WIDGET (gtk_builder_get_object |
183 | (builder, | ||
184 | "GNUNET_GTK_advertise_pseudonym_keyword_list_del_button")); | ||
181 | 185 | ||
182 | gtk_widget_set_sensitive (button, | 186 | gtk_widget_set_sensitive (button, |
183 | gtk_tree_selection_get_selected (sel, NULL, NULL)); | 187 | gtk_tree_selection_get_selected (sel, NULL, NULL)); |
184 | button = GTK_WIDGET (gtk_builder_get_object (builder, | 188 | button = |
185 | "GNUNET_GTK_advertise_pseudonym_keyword_list_normalize_button")); | 189 | GTK_WIDGET (gtk_builder_get_object |
190 | (builder, | ||
191 | "GNUNET_GTK_advertise_pseudonym_keyword_list_normalize_button")); | ||
186 | gtk_widget_set_sensitive (button, | 192 | gtk_widget_set_sensitive (button, |
187 | gtk_tree_selection_get_selected (sel, NULL, NULL)); | 193 | gtk_tree_selection_get_selected (sel, NULL, NULL)); |
188 | } | 194 | } |
189 | 195 | ||
190 | 196 | ||
@@ -193,25 +199,31 @@ keyword_selection_changed_cb (GtkTreeSelection *ts, | |||
193 | */ | 199 | */ |
194 | void | 200 | void |
195 | GNUNET_GTK_advertise_pseudonym_metadata_value_entry_changed_cb () | 201 | GNUNET_GTK_advertise_pseudonym_metadata_value_entry_changed_cb () |
196 | { | 202 | { |
197 | GtkTreeView *tv; | 203 | GtkTreeView *tv; |
198 | GtkTreeSelection *sel; | 204 | GtkTreeSelection *sel; |
199 | const char *value; | 205 | const char *value; |
200 | GtkEntry *entry; | 206 | GtkEntry *entry; |
201 | GtkWidget *button; | 207 | GtkWidget *button; |
202 | 208 | ||
203 | entry = GTK_ENTRY (gtk_builder_get_object (builder, | 209 | entry = |
204 | "GNUNET_GTK_advertise_pseudonym_metadata_value_entry")); | 210 | GTK_ENTRY (gtk_builder_get_object |
211 | (builder, | ||
212 | "GNUNET_GTK_advertise_pseudonym_metadata_value_entry")); | ||
205 | value = gtk_entry_get_text (entry); | 213 | value = gtk_entry_get_text (entry); |
206 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 214 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
207 | "GNUNET_GTK_advertise_pseudonym_metadata_type_tree_view")); | 215 | (builder, |
216 | "GNUNET_GTK_advertise_pseudonym_metadata_type_tree_view")); | ||
208 | sel = gtk_tree_view_get_selection (tv); | 217 | sel = gtk_tree_view_get_selection (tv); |
209 | button = GTK_WIDGET (gtk_builder_get_object (builder, | 218 | button = |
210 | "GNUNET_GTK_advertise_pseudonym_metadata_add_button")); | 219 | GTK_WIDGET (gtk_builder_get_object |
220 | (builder, | ||
221 | "GNUNET_GTK_advertise_pseudonym_metadata_add_button")); | ||
211 | gtk_widget_set_sensitive (button, | 222 | gtk_widget_set_sensitive (button, |
212 | (strlen (value) > 0) | 223 | (strlen (value) > |
213 | ? gtk_tree_selection_get_selected (sel, NULL, NULL) | 224 | 0) ? gtk_tree_selection_get_selected (sel, NULL, |
214 | : FALSE); | 225 | NULL) : |
226 | FALSE); | ||
215 | } | 227 | } |
216 | 228 | ||
217 | 229 | ||
@@ -225,8 +237,7 @@ GNUNET_GTK_advertise_pseudonym_keyword_entry_activate_cb () | |||
225 | } | 237 | } |
226 | 238 | ||
227 | 239 | ||
228 | void | 240 | void GNUNET_GTK_advertise_pseudonym_metadata_preview_file_chooser_button_file_set_cb () |
229 | GNUNET_GTK_advertise_pseudonym_metadata_preview_file_chooser_button_file_set_cb () | ||
230 | { | 241 | { |
231 | GNUNET_break (0); | 242 | GNUNET_break (0); |
232 | } | 243 | } |
@@ -235,23 +246,23 @@ GNUNET_GTK_advertise_pseudonym_metadata_preview_file_chooser_button_file_set_cb | |||
235 | * Delete currently selected item from meta data list. | 246 | * Delete currently selected item from meta data list. |
236 | */ | 247 | */ |
237 | void | 248 | void |
238 | GNUNET_GTK_advertise_pseudonym_metadata_delete_button_clicked_cb() | 249 | GNUNET_GTK_advertise_pseudonym_metadata_delete_button_clicked_cb () |
239 | { | 250 | { |
240 | GtkTreeView *tv; | 251 | GtkTreeView *tv; |
241 | GtkTreeSelection *sel; | 252 | GtkTreeSelection *sel; |
242 | GtkTreeModel *tm; | 253 | GtkTreeModel *tm; |
243 | GtkTreeIter iter; | 254 | GtkTreeIter iter; |
244 | 255 | ||
245 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 256 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
246 | "GNUNET_GTK_advertise_pseudonym_metadata_tree_view")); | 257 | (builder, |
258 | "GNUNET_GTK_advertise_pseudonym_metadata_tree_view")); | ||
247 | sel = gtk_tree_view_get_selection (tv); | 259 | sel = gtk_tree_view_get_selection (tv); |
248 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) | 260 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
249 | { | 261 | { |
250 | GNUNET_break (0); | 262 | GNUNET_break (0); |
251 | return; | 263 | return; |
252 | } | 264 | } |
253 | gtk_list_store_remove (GTK_LIST_STORE (tm), | 265 | gtk_list_store_remove (GTK_LIST_STORE (tm), &iter); |
254 | &iter); | ||
255 | } | 266 | } |
256 | 267 | ||
257 | 268 | ||
@@ -274,69 +285,63 @@ GNUNET_GTK_advertise_pseudonym_metadata_add_button_clicked_cb () | |||
274 | size_t slen; | 285 | size_t slen; |
275 | char *pos; | 286 | char *pos; |
276 | 287 | ||
277 | entry = GTK_ENTRY (gtk_builder_get_object (builder, | 288 | entry = |
278 | "GNUNET_GTK_advertise_pseudonym_metadata_value_entry")); | 289 | GTK_ENTRY (gtk_builder_get_object |
290 | (builder, | ||
291 | "GNUNET_GTK_advertise_pseudonym_metadata_value_entry")); | ||
279 | value = gtk_entry_get_text (entry); | 292 | value = gtk_entry_get_text (entry); |
280 | if ((value == NULL) || (strlen (value) == 0)) | 293 | if ((value == NULL) || (strlen (value) == 0)) |
281 | { | 294 | { |
282 | GNUNET_break (0); | 295 | GNUNET_break (0); |
283 | return; | 296 | return; |
284 | } | 297 | } |
285 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 298 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
286 | "GNUNET_GTK_advertise_pseudonym_metadata_type_tree_view")); | 299 | (builder, |
300 | "GNUNET_GTK_advertise_pseudonym_metadata_type_tree_view")); | ||
287 | tm = gtk_tree_view_get_model (tv); | 301 | tm = gtk_tree_view_get_model (tv); |
288 | sel = gtk_tree_view_get_selection (tv); | 302 | sel = gtk_tree_view_get_selection (tv); |
289 | if (TRUE != gtk_tree_selection_get_selected (sel, | 303 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
290 | &tm, | 304 | { |
291 | &iter)) | 305 | GNUNET_break (0); |
306 | return; | ||
307 | } | ||
308 | gtk_tree_model_get (tm, &iter, 1, &type, -1); | ||
309 | ls = GTK_LIST_STORE (gtk_builder_get_object | ||
310 | (builder, "GNUNET_GTK_meta_data_list_store")); | ||
311 | if ((type == EXTRACTOR_METATYPE_FILENAME) && | ||
312 | (value[strlen (value) - 1] != '/')) | ||
313 | { | ||
314 | GNUNET_asprintf (&avalue, "%s/", value); | ||
315 | /* if user typed '\' instead of '/', change it! */ | ||
316 | slen = strlen (avalue); | ||
317 | while ((slen > 1) && (avalue[slen - 2] == '\\')) | ||
292 | { | 318 | { |
293 | GNUNET_break (0); | 319 | avalue[slen - 2] = '/'; |
294 | return; | 320 | avalue[slen - 1] = '\0'; |
321 | slen--; | ||
295 | } | 322 | } |
296 | gtk_tree_model_get (tm, | 323 | while (NULL != (pos = strstr (avalue, "\\"))) |
297 | &iter, | 324 | *pos = '/'; |
298 | 1, &type, -1); | 325 | /* remove '../' everywhere */ |
299 | ls = GTK_LIST_STORE (gtk_builder_get_object (builder, | 326 | while (NULL != (pos = strstr (avalue, "../"))) |
300 | "GNUNET_GTK_meta_data_list_store")); | ||
301 | if ( (type == EXTRACTOR_METATYPE_FILENAME) && | ||
302 | (value[strlen(value)-1] != '/') ) | ||
303 | { | ||
304 | GNUNET_asprintf (&avalue, | ||
305 | "%s/", | ||
306 | value); | ||
307 | /* if user typed '\' instead of '/', change it! */ | ||
308 | slen = strlen (avalue); | ||
309 | while ( (slen > 1) && | ||
310 | (avalue[slen-2] == '\\') ) | ||
311 | { | ||
312 | avalue[slen-2] = '/'; | ||
313 | avalue[slen-1] = '\0'; | ||
314 | slen--; | ||
315 | } | ||
316 | while (NULL != (pos = strstr (avalue, "\\"))) | ||
317 | *pos = '/'; | ||
318 | /* remove '../' everywhere */ | ||
319 | while (NULL != (pos = strstr (avalue, "../"))) | ||
320 | { | ||
321 | pos[0] = '_'; | ||
322 | pos[1] = '_'; | ||
323 | pos[2] = '_'; | ||
324 | } | ||
325 | ivalue = avalue; | ||
326 | } | ||
327 | else | ||
328 | { | 327 | { |
329 | ivalue = value; | 328 | pos[0] = '_'; |
330 | avalue = NULL; | 329 | pos[1] = '_'; |
330 | pos[2] = '_'; | ||
331 | } | 331 | } |
332 | 332 | ivalue = avalue; | |
333 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, | 333 | } |
334 | 0, type, | 334 | else |
335 | 1, (guint) EXTRACTOR_METAFORMAT_UTF8, | 335 | { |
336 | 2, EXTRACTOR_metatype_to_string (type), | 336 | ivalue = value; |
337 | 3, ivalue, | 337 | avalue = NULL; |
338 | -1); | 338 | } |
339 | GNUNET_free_non_null (avalue); | 339 | |
340 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, 0, type, 1, | ||
341 | (guint) EXTRACTOR_METAFORMAT_UTF8, 2, | ||
342 | EXTRACTOR_metatype_to_string (type), 3, | ||
343 | ivalue, -1); | ||
344 | GNUNET_free_non_null (avalue); | ||
340 | gtk_entry_set_text (GTK_ENTRY (entry), ""); | 345 | gtk_entry_set_text (GTK_ENTRY (entry), ""); |
341 | } | 346 | } |
342 | 347 | ||
@@ -351,33 +356,28 @@ GNUNET_GTK_advertise_pseudonym_metadata_add_button_clicked_cb () | |||
351 | * @param id hash identifier for the namespace | 356 | * @param id hash identifier for the namespace |
352 | */ | 357 | */ |
353 | static void | 358 | static void |
354 | add_to_list (void *cls, | 359 | add_to_list (void *cls, const char *name, const GNUNET_HashCode * id) |
355 | const char *name, | ||
356 | const GNUNET_HashCode *id) | ||
357 | { | 360 | { |
358 | GtkListStore *ls = cls; | 361 | GtkListStore *ls = cls; |
359 | GtkTreeIter iter; | 362 | GtkTreeIter iter; |
360 | 363 | ||
361 | gtk_list_store_insert_with_values (ls, | 364 | gtk_list_store_insert_with_values (ls, &iter, -1, 0, name, 1, |
362 | &iter, | 365 | GNUNET_FS_namespace_create |
363 | -1, | 366 | (GNUNET_FS_GTK_get_fs_handle (), name), |
364 | 0, name, | 367 | -1); |
365 | 1, GNUNET_FS_namespace_create (GNUNET_FS_GTK_get_fs_handle (), | 368 | |
366 | name), | ||
367 | -1); | ||
368 | |||
369 | } | 369 | } |
370 | 370 | ||
371 | 371 | ||
372 | static void | 372 | static void |
373 | selection_changed_cb (GtkTreeSelection *ts, | 373 | selection_changed_cb (GtkTreeSelection * ts, gpointer user_data) |
374 | gpointer user_data) | ||
375 | { | 374 | { |
376 | GtkTreeIter iter; | 375 | GtkTreeIter iter; |
377 | GtkWidget *ok_button; | 376 | GtkWidget *ok_button; |
378 | 377 | ||
379 | ok_button = GTK_WIDGET (gtk_builder_get_object (builder, | 378 | ok_button = |
380 | "GNUNET_GTK_select_pseudonym_ok_button")); | 379 | GTK_WIDGET (gtk_builder_get_object |
380 | (builder, "GNUNET_GTK_select_pseudonym_ok_button")); | ||
381 | if (TRUE == gtk_tree_selection_get_selected (ts, NULL, &iter)) | 381 | if (TRUE == gtk_tree_selection_get_selected (ts, NULL, &iter)) |
382 | gtk_widget_set_sensitive (ok_button, TRUE); | 382 | gtk_widget_set_sensitive (ok_button, TRUE); |
383 | else | 383 | else |
@@ -389,8 +389,8 @@ selection_changed_cb (GtkTreeSelection *ts, | |||
389 | * Advertise pseudonym selected. | 389 | * Advertise pseudonym selected. |
390 | */ | 390 | */ |
391 | void | 391 | void |
392 | GNUNET_GTK_main_menu_file_advertise_pseudonym_activate_cb (GtkWidget * dummy, | 392 | GNUNET_GTK_main_menu_file_advertise_pseudonym_activate_cb (GtkWidget * dummy, |
393 | gpointer data) | 393 | gpointer data) |
394 | { | 394 | { |
395 | GtkWidget *ad; | 395 | GtkWidget *ad; |
396 | struct GNUNET_FS_Namespace *ns; | 396 | struct GNUNET_FS_Namespace *ns; |
@@ -408,173 +408,165 @@ GNUNET_GTK_main_menu_file_advertise_pseudonym_activate_cb (GtkWidget * dummy, | |||
408 | struct GNUNET_CONTAINER_MetaData *nm; | 408 | struct GNUNET_CONTAINER_MetaData *nm; |
409 | const char *root; | 409 | const char *root; |
410 | char *value; | 410 | char *value; |
411 | guint ntype; | 411 | guint ntype; |
412 | guint nformat; | 412 | guint nformat; |
413 | guint type; | 413 | guint type; |
414 | guint max_type; | 414 | guint max_type; |
415 | 415 | ||
416 | builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_select_pseudonym_dialog.glade"); | 416 | builder = |
417 | GNUNET_GTK_get_new_builder | ||
418 | ("gnunet_fs_gtk_select_pseudonym_dialog.glade"); | ||
417 | if (builder == NULL) | 419 | if (builder == NULL) |
418 | { | 420 | { |
419 | GNUNET_break (0); | 421 | GNUNET_break (0); |
420 | return; | 422 | return; |
421 | } | 423 | } |
422 | ad = GTK_WIDGET (gtk_builder_get_object (builder, | 424 | ad = GTK_WIDGET (gtk_builder_get_object |
423 | "GNUNET_GTK_select_pseudonym_dialog")); | 425 | (builder, "GNUNET_GTK_select_pseudonym_dialog")); |
424 | ls = GTK_LIST_STORE (gtk_builder_get_object (builder, | 426 | ls = GTK_LIST_STORE (gtk_builder_get_object |
425 | "GNUNET_GTK_select_pseudonym_liststore")); | 427 | (builder, "GNUNET_GTK_select_pseudonym_liststore")); |
426 | GNUNET_FS_namespace_list (GNUNET_FS_GTK_get_fs_handle (), | 428 | GNUNET_FS_namespace_list (GNUNET_FS_GTK_get_fs_handle (), &add_to_list, ls); |
427 | &add_to_list, | 429 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
428 | ls); | 430 | (builder, "GNUNET_GTK_select_pseudonym_tree_view")); |
429 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | ||
430 | "GNUNET_GTK_select_pseudonym_tree_view")); | ||
431 | sel = gtk_tree_view_get_selection (tv); | 431 | sel = gtk_tree_view_get_selection (tv); |
432 | g_signal_connect(G_OBJECT(sel), "changed", | 432 | g_signal_connect (G_OBJECT (sel), "changed", |
433 | G_CALLBACK(selection_changed_cb), NULL); | 433 | G_CALLBACK (selection_changed_cb), NULL); |
434 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) | 434 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) |
435 | { | 435 | { |
436 | gtk_widget_destroy (ad); | 436 | gtk_widget_destroy (ad); |
437 | g_object_unref (G_OBJECT (builder)); | 437 | g_object_unref (G_OBJECT (builder)); |
438 | builder = NULL; | 438 | builder = NULL; |
439 | return; | 439 | return; |
440 | } | 440 | } |
441 | GNUNET_assert (TRUE == gtk_tree_selection_get_selected (sel, | 441 | GNUNET_assert (TRUE == gtk_tree_selection_get_selected (sel, &tm, &iter)); |
442 | &tm, | 442 | gtk_tree_model_get (tm, &iter, 1, &ns, -1); |
443 | &iter)); | ||
444 | gtk_tree_model_get (tm, | ||
445 | &iter, | ||
446 | 1, &ns, | ||
447 | -1); | ||
448 | /* free all namespaces from list store except "ns" */ | 443 | /* free all namespaces from list store except "ns" */ |
449 | if (TRUE == | 444 | if (TRUE == gtk_tree_model_get_iter_first (tm, &iter)) |
450 | gtk_tree_model_get_iter_first (tm, &iter)) | 445 | { |
446 | do | ||
451 | { | 447 | { |
452 | do | 448 | gtk_tree_model_get (tm, &iter, 1, &nso, -1); |
453 | { | 449 | if (ns != nso) |
454 | gtk_tree_model_get (tm, &iter, | 450 | GNUNET_FS_namespace_delete (nso, GNUNET_NO); |
455 | 1, &nso, | ||
456 | -1); | ||
457 | if (ns != nso) | ||
458 | GNUNET_FS_namespace_delete (nso, GNUNET_NO); | ||
459 | } | ||
460 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | ||
461 | } | 451 | } |
452 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | ||
453 | } | ||
462 | gtk_widget_destroy (ad); | 454 | gtk_widget_destroy (ad); |
463 | g_object_unref (G_OBJECT (builder)); | 455 | g_object_unref (G_OBJECT (builder)); |
464 | builder = NULL; | 456 | builder = NULL; |
465 | 457 | ||
466 | 458 | ||
467 | builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_advertise_pseudonym_dialog.glade"); | 459 | builder = |
460 | GNUNET_GTK_get_new_builder | ||
461 | ("gnunet_fs_gtk_advertise_pseudonym_dialog.glade"); | ||
468 | if (builder == NULL) | 462 | if (builder == NULL) |
469 | { | 463 | { |
470 | GNUNET_break (0); | 464 | GNUNET_break (0); |
471 | return; | 465 | return; |
472 | } | 466 | } |
473 | GNUNET_FS_GTK_setup_expiration_year_adjustment (builder); | 467 | GNUNET_FS_GTK_setup_expiration_year_adjustment (builder); |
474 | ad = GTK_WIDGET (gtk_builder_get_object (builder, | 468 | ad = GTK_WIDGET (gtk_builder_get_object |
475 | "GNUNET_GTK_advertise_pseudonym_dialog")); | 469 | (builder, "GNUNET_GTK_advertise_pseudonym_dialog")); |
476 | ls = GTK_LIST_STORE (gtk_builder_get_object (builder, | 470 | ls = GTK_LIST_STORE (gtk_builder_get_object |
477 | "GNUNET_GTK_metatype_list_store")); | 471 | (builder, "GNUNET_GTK_metatype_list_store")); |
478 | max_type = EXTRACTOR_metatype_get_max (); | 472 | max_type = EXTRACTOR_metatype_get_max (); |
479 | type = 1; | 473 | type = 1; |
480 | while (type < max_type - 1) | 474 | while (type < max_type - 1) |
481 | { | 475 | { |
482 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, | 476 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, 0, |
483 | 0, EXTRACTOR_metatype_to_string (type), | 477 | EXTRACTOR_metatype_to_string (type), 1, |
484 | 1, type, | 478 | type, 2, |
485 | 2, EXTRACTOR_metatype_to_description (type), | 479 | EXTRACTOR_metatype_to_description (type), |
486 | -1); | 480 | -1); |
487 | type++; | 481 | type++; |
488 | } | 482 | } |
489 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 483 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
490 | "GNUNET_GTK_advertise_pseudonym_metadata_type_tree_view")); | 484 | (builder, |
485 | "GNUNET_GTK_advertise_pseudonym_metadata_type_tree_view")); | ||
491 | sel = gtk_tree_view_get_selection (tv); | 486 | sel = gtk_tree_view_get_selection (tv); |
492 | g_signal_connect(G_OBJECT(sel), "changed", | 487 | g_signal_connect (G_OBJECT (sel), "changed", |
493 | G_CALLBACK(GNUNET_GTK_advertise_pseudonym_metadata_value_entry_changed_cb), NULL); | 488 | G_CALLBACK |
494 | 489 | (GNUNET_GTK_advertise_pseudonym_metadata_value_entry_changed_cb), | |
495 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 490 | NULL); |
496 | "GNUNET_GTK_advertise_pseudonym_metadata_tree_view")); | 491 | |
492 | tv = GTK_TREE_VIEW (gtk_builder_get_object | ||
493 | (builder, | ||
494 | "GNUNET_GTK_advertise_pseudonym_metadata_tree_view")); | ||
497 | sel = gtk_tree_view_get_selection (tv); | 495 | sel = gtk_tree_view_get_selection (tv); |
498 | g_signal_connect(G_OBJECT(sel), "changed", | 496 | g_signal_connect (G_OBJECT (sel), "changed", |
499 | G_CALLBACK(metadata_selection_changed_cb), NULL); | 497 | G_CALLBACK (metadata_selection_changed_cb), NULL); |
500 | 498 | ||
501 | tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 499 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
502 | "GNUNET_GTK_advertise_pseudonym_keyword_list_tree_view")); | 500 | (builder, |
501 | "GNUNET_GTK_advertise_pseudonym_keyword_list_tree_view")); | ||
503 | sel = gtk_tree_view_get_selection (tv); | 502 | sel = gtk_tree_view_get_selection (tv); |
504 | g_signal_connect(G_OBJECT(sel), "changed", | 503 | g_signal_connect (G_OBJECT (sel), "changed", |
505 | G_CALLBACK(keyword_selection_changed_cb), NULL); | 504 | G_CALLBACK (keyword_selection_changed_cb), NULL); |
506 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) | 505 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) |
507 | { | 506 | { |
508 | gtk_widget_destroy (ad); | 507 | gtk_widget_destroy (ad); |
509 | g_object_unref (G_OBJECT (builder)); | 508 | g_object_unref (G_OBJECT (builder)); |
510 | builder = NULL; | 509 | builder = NULL; |
511 | return; | 510 | return; |
512 | } | 511 | } |
513 | /* get keywords from list store */ | 512 | /* get keywords from list store */ |
514 | nxt = NULL; | 513 | nxt = NULL; |
515 | mrg = NULL; | 514 | mrg = NULL; |
516 | uri = NULL; | 515 | uri = NULL; |
517 | tm = GTK_TREE_MODEL (gtk_builder_get_object (builder, | 516 | tm = GTK_TREE_MODEL (gtk_builder_get_object |
518 | "GNUNET_GTK_keyword_list_store")); | 517 | (builder, "GNUNET_GTK_keyword_list_store")); |
519 | if (TRUE == | 518 | if (TRUE == gtk_tree_model_get_iter_first (tm, &iter)) |
520 | gtk_tree_model_get_iter_first (tm, &iter)) | 519 | { |
520 | do | ||
521 | { | 521 | { |
522 | do | 522 | gtk_tree_model_get (tm, &iter, 0, &value, -1); |
523 | { | 523 | nxt = GNUNET_FS_uri_ksk_create_from_args (1, (const char **) &value); |
524 | gtk_tree_model_get (tm, &iter, | 524 | mrg = GNUNET_FS_uri_ksk_merge (nxt, uri); |
525 | 0, &value, | 525 | GNUNET_FS_uri_destroy (nxt); |
526 | -1); | 526 | if (NULL != uri) |
527 | nxt = GNUNET_FS_uri_ksk_create_from_args (1, (const char**) &value); | 527 | GNUNET_FS_uri_destroy (uri); |
528 | mrg = GNUNET_FS_uri_ksk_merge (nxt, uri); | 528 | uri = mrg; |
529 | GNUNET_FS_uri_destroy (nxt); | 529 | g_free (value); |
530 | if (NULL != uri) | ||
531 | GNUNET_FS_uri_destroy (uri); | ||
532 | uri = mrg; | ||
533 | g_free (value); | ||
534 | } | ||
535 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | ||
536 | } | 530 | } |
531 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | ||
532 | } | ||
537 | /* get meta */ | 533 | /* get meta */ |
538 | nm = GNUNET_CONTAINER_meta_data_create (); | 534 | nm = GNUNET_CONTAINER_meta_data_create (); |
539 | tm = GTK_TREE_MODEL (gtk_builder_get_object (builder, | 535 | tm = GTK_TREE_MODEL (gtk_builder_get_object |
540 | "GNUNET_GTK_meta_data_list_store")); | 536 | (builder, "GNUNET_GTK_meta_data_list_store")); |
541 | if (TRUE == | 537 | if (TRUE == gtk_tree_model_get_iter_first (tm, &iter)) |
542 | gtk_tree_model_get_iter_first (tm, &iter)) | 538 | { |
539 | do | ||
543 | { | 540 | { |
544 | do | 541 | gtk_tree_model_get (tm, &iter, 0, &ntype, 1, &nformat, 3, &value, -1); |
545 | { | 542 | GNUNET_CONTAINER_meta_data_insert (nm, "<user>", ntype, nformat, |
546 | gtk_tree_model_get (tm, &iter, | 543 | "text/plain", value, |
547 | 0, &ntype, | 544 | strlen (value) + 1); |
548 | 1, &nformat, | 545 | g_free (value); |
549 | 3, &value, | ||
550 | -1); | ||
551 | GNUNET_CONTAINER_meta_data_insert (nm, | ||
552 | "<user>", | ||
553 | ntype, | ||
554 | nformat, | ||
555 | "text/plain", | ||
556 | value, | ||
557 | strlen (value)+1); | ||
558 | g_free (value); | ||
559 | } | ||
560 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | ||
561 | } | 546 | } |
562 | bo.anonymity_level = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 547 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); |
563 | "GNUNET_GTK_advertise_pseudonym_anonymity_spin_button"))); | 548 | } |
564 | bo.content_priority = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 549 | bo.anonymity_level = |
565 | "GNUNET_GTK_advertise_pseudonym_priority_spin_button"))); | 550 | gtk_spin_button_get_value (GTK_SPIN_BUTTON |
566 | sb = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 551 | (gtk_builder_get_object |
567 | "GNUNET_GTK_advertise_pseudonym_expiration_year_spin_button")); | 552 | (builder, |
553 | "GNUNET_GTK_advertise_pseudonym_anonymity_spin_button"))); | ||
554 | bo.content_priority = | ||
555 | gtk_spin_button_get_value (GTK_SPIN_BUTTON | ||
556 | (gtk_builder_get_object | ||
557 | (builder, | ||
558 | "GNUNET_GTK_advertise_pseudonym_priority_spin_button"))); | ||
559 | sb = GTK_SPIN_BUTTON (gtk_builder_get_object | ||
560 | (builder, | ||
561 | "GNUNET_GTK_advertise_pseudonym_expiration_year_spin_button")); | ||
568 | bo.expiration_time = GNUNET_FS_GTK_get_expiration_time (sb); | 562 | bo.expiration_time = GNUNET_FS_GTK_get_expiration_time (sb); |
569 | root = gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder, | 563 | root = |
570 | "GNUNET_GTK_advertise_pseudonym_root_entry"))); | 564 | gtk_entry_get_text (GTK_ENTRY |
571 | GNUNET_FS_namespace_advertise (GNUNET_FS_GTK_get_fs_handle (), | 565 | (gtk_builder_get_object |
572 | uri, | 566 | (builder, |
573 | ns, | 567 | "GNUNET_GTK_advertise_pseudonym_root_entry"))); |
574 | nm, | 568 | GNUNET_FS_namespace_advertise (GNUNET_FS_GTK_get_fs_handle (), uri, ns, nm, |
575 | &bo, | 569 | &bo, root, NULL, NULL); |
576 | root, | ||
577 | NULL, NULL); | ||
578 | GNUNET_FS_namespace_delete (ns, GNUNET_NO); | 570 | GNUNET_FS_namespace_delete (ns, GNUNET_NO); |
579 | GNUNET_CONTAINER_meta_data_destroy (nm); | 571 | GNUNET_CONTAINER_meta_data_destroy (nm); |
580 | if (NULL != uri) | 572 | if (NULL != uri) |
diff --git a/src/fs/gnunet-fs-gtk-main_window_create_pseudonym.c b/src/fs/gnunet-fs-gtk-main_window_create_pseudonym.c index e724d4dd..05094a12 100644 --- a/src/fs/gnunet-fs-gtk-main_window_create_pseudonym.c +++ b/src/fs/gnunet-fs-gtk-main_window_create_pseudonym.c | |||
@@ -29,33 +29,37 @@ | |||
29 | /** | 29 | /** |
30 | */ | 30 | */ |
31 | void | 31 | void |
32 | GNUNET_GTK_main_menu_create_pseudonym_activate_cb (GtkWidget * dummy, | 32 | GNUNET_GTK_main_menu_create_pseudonym_activate_cb (GtkWidget * dummy, |
33 | gpointer data) | 33 | gpointer data) |
34 | { | 34 | { |
35 | GtkWidget *ad; | 35 | GtkWidget *ad; |
36 | GtkBuilder *builder; | 36 | GtkBuilder *builder; |
37 | const char *name; | 37 | const char *name; |
38 | struct GNUNET_FS_Namespace *ns; | 38 | struct GNUNET_FS_Namespace *ns; |
39 | 39 | ||
40 | builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_create_namespace_dialog.glade"); | 40 | builder = |
41 | GNUNET_GTK_get_new_builder | ||
42 | ("gnunet_fs_gtk_create_namespace_dialog.glade"); | ||
41 | if (builder == NULL) | 43 | if (builder == NULL) |
42 | { | 44 | { |
43 | GNUNET_break (0); | 45 | GNUNET_break (0); |
44 | return; | 46 | return; |
45 | } | 47 | } |
46 | ad = GTK_WIDGET (gtk_builder_get_object (builder, | 48 | ad = GTK_WIDGET (gtk_builder_get_object |
47 | "GNUNET_GTK_create_namespace_dialog")); | 49 | (builder, "GNUNET_GTK_create_namespace_dialog")); |
48 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) | 50 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) |
49 | { | 51 | { |
50 | gtk_widget_destroy (ad); | 52 | gtk_widget_destroy (ad); |
51 | g_object_unref (G_OBJECT (builder)); | 53 | g_object_unref (G_OBJECT (builder)); |
52 | return; | 54 | return; |
53 | } | 55 | } |
54 | name = gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder, | 56 | name = |
55 | "GNUNET_GTK_create_namespace_name_entry"))); | 57 | gtk_entry_get_text (GTK_ENTRY |
58 | (gtk_builder_get_object | ||
59 | (builder, | ||
60 | "GNUNET_GTK_create_namespace_name_entry"))); | ||
56 | /* FIXME: show busy dialog while doing key creation */ | 61 | /* FIXME: show busy dialog while doing key creation */ |
57 | ns = GNUNET_FS_namespace_create (GNUNET_FS_GTK_get_fs_handle (), | 62 | ns = GNUNET_FS_namespace_create (GNUNET_FS_GTK_get_fs_handle (), name); |
58 | name); | ||
59 | GNUNET_FS_namespace_delete (ns, GNUNET_NO); | 63 | GNUNET_FS_namespace_delete (ns, GNUNET_NO); |
60 | gtk_widget_destroy (ad); | 64 | gtk_widget_destroy (ad); |
61 | g_object_unref (G_OBJECT (builder)); | 65 | g_object_unref (G_OBJECT (builder)); |
diff --git a/src/fs/gnunet-fs-gtk-main_window_file_download.c b/src/fs/gnunet-fs-gtk-main_window_file_download.c index dd68707a..19f78172 100644 --- a/src/fs/gnunet-fs-gtk-main_window_file_download.c +++ b/src/fs/gnunet-fs-gtk-main_window_file_download.c | |||
@@ -29,27 +29,31 @@ | |||
29 | static GtkBuilder *builder; | 29 | static GtkBuilder *builder; |
30 | 30 | ||
31 | void | 31 | void |
32 | GNUNET_GTK_open_url_dialog_url_entry_changed_cb (GtkEditable *editable, | 32 | GNUNET_GTK_open_url_dialog_url_entry_changed_cb (GtkEditable * editable, |
33 | gpointer user_data) | 33 | gpointer user_data) |
34 | { | 34 | { |
35 | struct GNUNET_FS_Uri *uri; | 35 | struct GNUNET_FS_Uri *uri; |
36 | char *perr; | 36 | char *perr; |
37 | const char *uris; | 37 | const char *uris; |
38 | 38 | ||
39 | perr = NULL; | 39 | perr = NULL; |
40 | uris = gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder, | 40 | uris = |
41 | "GNUNET_GTK_open_url_dialog_url_entry"))); | 41 | gtk_entry_get_text (GTK_ENTRY |
42 | (gtk_builder_get_object | ||
43 | (builder, "GNUNET_GTK_open_url_dialog_url_entry"))); | ||
42 | if (uris != NULL) | 44 | if (uris != NULL) |
43 | uri = GNUNET_FS_uri_parse (uris, &perr); | 45 | uri = GNUNET_FS_uri_parse (uris, &perr); |
44 | else | 46 | else |
45 | uri = NULL; | 47 | uri = NULL; |
46 | gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (builder, | 48 | gtk_widget_set_sensitive (GTK_WIDGET |
47 | "GNUNET_GTK_open_url_dialog_execute_button")), | 49 | (gtk_builder_get_object |
48 | (uri == NULL) ? FALSE : TRUE); | 50 | (builder, |
51 | "GNUNET_GTK_open_url_dialog_execute_button")), | ||
52 | (uri == NULL) ? FALSE : TRUE); | ||
49 | if (uri != NULL) | 53 | if (uri != NULL) |
50 | GNUNET_FS_uri_destroy (uri); | 54 | GNUNET_FS_uri_destroy (uri); |
51 | else | 55 | else |
52 | GNUNET_free_non_null (perr); | 56 | GNUNET_free_non_null (perr); |
53 | } | 57 | } |
54 | 58 | ||
55 | 59 | ||
@@ -57,8 +61,8 @@ GNUNET_GTK_open_url_dialog_url_entry_changed_cb (GtkEditable *editable, | |||
57 | * User selected "Open URI" in main window. | 61 | * User selected "Open URI" in main window. |
58 | */ | 62 | */ |
59 | void | 63 | void |
60 | GNUNET_GTK_main_menu_file_download_uri_activate_cb (GtkWidget * dummy, | 64 | GNUNET_GTK_main_menu_file_download_uri_activate_cb (GtkWidget * dummy, |
61 | gpointer data) | 65 | gpointer data) |
62 | { | 66 | { |
63 | GtkWidget *ad; | 67 | GtkWidget *ad; |
64 | const char *uris; | 68 | const char *uris; |
@@ -70,59 +74,58 @@ GNUNET_GTK_main_menu_file_download_uri_activate_cb (GtkWidget * dummy, | |||
70 | GNUNET_assert (builder == NULL); | 74 | GNUNET_assert (builder == NULL); |
71 | builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_open_url_dialog.glade"); | 75 | builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_open_url_dialog.glade"); |
72 | if (builder == NULL) | 76 | if (builder == NULL) |
73 | { | 77 | { |
74 | GNUNET_break (0); | 78 | GNUNET_break (0); |
75 | return; | 79 | return; |
76 | } | 80 | } |
77 | ad = GTK_WIDGET (gtk_builder_get_object (builder, | 81 | ad = GTK_WIDGET (gtk_builder_get_object |
78 | "GNUNET_GTK_open_url_dialog")); | 82 | (builder, "GNUNET_GTK_open_url_dialog")); |
79 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) | 83 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) |
80 | { | 84 | { |
81 | gtk_widget_destroy (ad); | 85 | gtk_widget_destroy (ad); |
82 | g_object_unref (G_OBJECT (builder)); | 86 | g_object_unref (G_OBJECT (builder)); |
83 | builder = NULL; | 87 | builder = NULL; |
84 | fprintf (stderr, | 88 | fprintf (stderr, "Dialog closed!\n"); |
85 | "Dialog closed!\n"); | 89 | return; |
86 | return; | 90 | } |
87 | } | 91 | uris = |
88 | uris = gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder, | 92 | gtk_entry_get_text (GTK_ENTRY |
89 | "GNUNET_GTK_open_url_dialog_url_entry"))); | 93 | (gtk_builder_get_object |
90 | anonymity = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 94 | (builder, "GNUNET_GTK_open_url_dialog_url_entry"))); |
91 | "GNUNET_GTK_open_url_dialog_anonymity_spin_button"))); | 95 | anonymity = |
96 | gtk_spin_button_get_value (GTK_SPIN_BUTTON | ||
97 | (gtk_builder_get_object | ||
98 | (builder, | ||
99 | "GNUNET_GTK_open_url_dialog_anonymity_spin_button"))); | ||
92 | uri = GNUNET_FS_uri_parse (uris, &perr); | 100 | uri = GNUNET_FS_uri_parse (uris, &perr); |
93 | gtk_widget_destroy (ad); | 101 | gtk_widget_destroy (ad); |
94 | g_object_unref (G_OBJECT (builder)); | 102 | g_object_unref (G_OBJECT (builder)); |
95 | builder = NULL; | 103 | builder = NULL; |
96 | if (uri == NULL) | 104 | if (uri == NULL) |
97 | { | 105 | { |
98 | GNUNET_free (perr); | 106 | GNUNET_free (perr); |
99 | /* Why was "execute" button sensitive!? */ | 107 | /* Why was "execute" button sensitive!? */ |
100 | GNUNET_break (0); | 108 | GNUNET_break (0); |
101 | return; | 109 | return; |
102 | } | 110 | } |
103 | if (GNUNET_FS_uri_test_sks (uri) || | 111 | if (GNUNET_FS_uri_test_sks (uri) || GNUNET_FS_uri_test_ksk (uri)) |
104 | GNUNET_FS_uri_test_ksk (uri)) | 112 | { |
105 | { | 113 | fprintf (stderr, "Starting search!\n"); |
106 | fprintf (stderr, | 114 | GNUNET_break (NULL != |
107 | "Starting search!\n"); | 115 | GNUNET_FS_search_start (GNUNET_FS_GTK_get_fs_handle (), uri, |
108 | GNUNET_break (NULL != | 116 | anonymity, |
109 | GNUNET_FS_search_start (GNUNET_FS_GTK_get_fs_handle (), | 117 | GNUNET_FS_SEARCH_OPTION_NONE, NULL)); |
110 | uri, | 118 | GNUNET_FS_uri_destroy (uri); |
111 | anonymity, | 119 | return; |
112 | GNUNET_FS_SEARCH_OPTION_NONE, | 120 | } |
113 | NULL)); | 121 | if (GNUNET_FS_uri_test_chk (uri) || GNUNET_FS_uri_test_loc (uri)) |
114 | GNUNET_FS_uri_destroy (uri); | 122 | { |
115 | return; | 123 | dc = GNUNET_malloc (sizeof (struct DownloadContext)); |
116 | } | 124 | dc->uri = uri; |
117 | if (GNUNET_FS_uri_test_chk (uri) || | 125 | dc->anonymity = anonymity; |
118 | GNUNET_FS_uri_test_loc (uri)) | 126 | GNUNET_FS_GTK_open_download_as_dialog (dc); |
119 | { | 127 | return; |
120 | dc = GNUNET_malloc (sizeof (struct DownloadContext)); | 128 | } |
121 | dc->uri = uri; | ||
122 | dc->anonymity = anonymity; | ||
123 | GNUNET_FS_GTK_open_download_as_dialog (dc); | ||
124 | return; | ||
125 | } | ||
126 | GNUNET_break (0); | 129 | GNUNET_break (0); |
127 | GNUNET_FS_uri_destroy (uri); | 130 | GNUNET_FS_uri_destroy (uri); |
128 | } | 131 | } |
diff --git a/src/fs/gnunet-fs-gtk-main_window_file_publish.c b/src/fs/gnunet-fs-gtk-main_window_file_publish.c index ee134dd5..0422c068 100644 --- a/src/fs/gnunet-fs-gtk-main_window_file_publish.c +++ b/src/fs/gnunet-fs-gtk-main_window_file_publish.c | |||
@@ -44,9 +44,7 @@ static GtkBuilder *master_builder; | |||
44 | * @return GNUNET_YES if they are equal | 44 | * @return GNUNET_YES if they are equal |
45 | */ | 45 | */ |
46 | static int | 46 | static int |
47 | gtk_tree_iter_equals (GtkTreeModel *tm, | 47 | gtk_tree_iter_equals (GtkTreeModel * tm, GtkTreeIter * i1, GtkTreeIter * i2) |
48 | GtkTreeIter *i1, | ||
49 | GtkTreeIter *i2) | ||
50 | { | 48 | { |
51 | GtkTreePath *p1; | 49 | GtkTreePath *p1; |
52 | GtkTreePath *p2; | 50 | GtkTreePath *p2; |
@@ -85,111 +83,119 @@ update_selectivity () | |||
85 | struct GNUNET_FS_FileInformation *fip; | 83 | struct GNUNET_FS_FileInformation *fip; |
86 | int ns_ok; | 84 | int ns_ok; |
87 | gchar *namespace_id; | 85 | gchar *namespace_id; |
88 | 86 | ||
89 | tm = GTK_TREE_MODEL (gtk_builder_get_object (master_builder, | 87 | tm = GTK_TREE_MODEL (gtk_builder_get_object |
90 | "GNUNET_GTK_file_sharing_publishing_tree_store")); | 88 | (master_builder, |
91 | tv = GTK_TREE_VIEW (gtk_builder_get_object (master_builder, | 89 | "GNUNET_GTK_file_sharing_publishing_tree_store")); |
92 | "GNUNET_GTK_master_publish_dialog_pseudonym_tree_view")); | 90 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
91 | (master_builder, | ||
92 | "GNUNET_GTK_master_publish_dialog_pseudonym_tree_view")); | ||
93 | sel = gtk_tree_view_get_selection (tv); | 93 | sel = gtk_tree_view_get_selection (tv); |
94 | ns_ok = GNUNET_YES; | 94 | ns_ok = GNUNET_YES; |
95 | if (TRUE == gtk_tree_selection_get_selected (sel, &ptm, &iter)) | 95 | if (TRUE == gtk_tree_selection_get_selected (sel, &ptm, &iter)) |
96 | { | 96 | { |
97 | gtk_tree_model_get (ptm, | 97 | gtk_tree_model_get (ptm, &iter, 2, &namespace_id, -1); |
98 | &iter, | 98 | if (namespace_id == NULL) |
99 | 2, &namespace_id, | 99 | ns_ok = GNUNET_NO; |
100 | -1); | 100 | else |
101 | if (namespace_id == NULL) | 101 | g_free (namespace_id); |
102 | ns_ok = GNUNET_NO; | 102 | } |
103 | else | 103 | up_button = |
104 | g_free (namespace_id); | 104 | GTK_WIDGET (gtk_builder_get_object |
105 | } | 105 | (master_builder, |
106 | up_button = GTK_WIDGET (gtk_builder_get_object (master_builder, | 106 | "GNUNET_GTK_master_publish_dialog_up_button")); |
107 | "GNUNET_GTK_master_publish_dialog_up_button")); | 107 | down_button = |
108 | down_button = GTK_WIDGET (gtk_builder_get_object (master_builder, | 108 | GTK_WIDGET (gtk_builder_get_object |
109 | "GNUNET_GTK_master_publish_dialog_down_button")); | 109 | (master_builder, |
110 | left_button = GTK_WIDGET (gtk_builder_get_object (master_builder, | 110 | "GNUNET_GTK_master_publish_dialog_down_button")); |
111 | "GNUNET_GTK_master_publish_dialog_left_button")); | 111 | left_button = |
112 | right_button = GTK_WIDGET (gtk_builder_get_object (master_builder, | 112 | GTK_WIDGET (gtk_builder_get_object |
113 | "GNUNET_GTK_master_publish_dialog_right_button")); | 113 | (master_builder, |
114 | delete_button = GTK_WIDGET (gtk_builder_get_object (master_builder, | 114 | "GNUNET_GTK_master_publish_dialog_left_button")); |
115 | "GNUNET_GTK_master_publish_dialog_delete_button")); | 115 | right_button = |
116 | edit_button = GTK_WIDGET (gtk_builder_get_object (master_builder, | 116 | GTK_WIDGET (gtk_builder_get_object |
117 | "GNUNET_GTK_master_publish_dialog_edit_button")); | 117 | (master_builder, |
118 | execute_button = GTK_WIDGET (gtk_builder_get_object (master_builder, | 118 | "GNUNET_GTK_master_publish_dialog_right_button")); |
119 | "GNUNET_GTK_master_publish_dialog_execute_button")); | 119 | delete_button = |
120 | tv = GTK_TREE_VIEW (gtk_builder_get_object (master_builder, | 120 | GTK_WIDGET (gtk_builder_get_object |
121 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 121 | (master_builder, |
122 | "GNUNET_GTK_master_publish_dialog_delete_button")); | ||
123 | edit_button = | ||
124 | GTK_WIDGET (gtk_builder_get_object | ||
125 | (master_builder, | ||
126 | "GNUNET_GTK_master_publish_dialog_edit_button")); | ||
127 | execute_button = | ||
128 | GTK_WIDGET (gtk_builder_get_object | ||
129 | (master_builder, | ||
130 | "GNUNET_GTK_master_publish_dialog_execute_button")); | ||
131 | tv = GTK_TREE_VIEW (gtk_builder_get_object | ||
132 | (master_builder, | ||
133 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | ||
122 | sel = gtk_tree_view_get_selection (tv); | 134 | sel = gtk_tree_view_get_selection (tv); |
123 | tm = gtk_tree_view_get_model (tv); | 135 | tm = gtk_tree_view_get_model (tv); |
124 | if ( (gtk_tree_model_get_iter_first (tm, &iter)) && | 136 | if ((gtk_tree_model_get_iter_first (tm, &iter)) && (ns_ok == GNUNET_YES)) |
125 | (ns_ok == GNUNET_YES) ) | ||
126 | gtk_widget_set_sensitive (execute_button, TRUE); | 137 | gtk_widget_set_sensitive (execute_button, TRUE); |
127 | else | 138 | else |
128 | gtk_widget_set_sensitive (execute_button, FALSE); | 139 | gtk_widget_set_sensitive (execute_button, FALSE); |
129 | if (TRUE != gtk_tree_selection_get_selected (sel, | 140 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
130 | &tm, | 141 | { |
131 | &iter)) | 142 | gtk_widget_set_sensitive (up_button, FALSE); |
132 | { | 143 | gtk_widget_set_sensitive (down_button, FALSE); |
133 | gtk_widget_set_sensitive (up_button, FALSE); | 144 | gtk_widget_set_sensitive (left_button, FALSE); |
134 | gtk_widget_set_sensitive (down_button, FALSE); | 145 | gtk_widget_set_sensitive (right_button, FALSE); |
135 | gtk_widget_set_sensitive (left_button, FALSE); | 146 | gtk_widget_set_sensitive (delete_button, FALSE); |
136 | gtk_widget_set_sensitive (right_button, FALSE); | 147 | gtk_widget_set_sensitive (edit_button, FALSE); |
137 | gtk_widget_set_sensitive (delete_button, FALSE); | 148 | return; |
138 | gtk_widget_set_sensitive (edit_button, FALSE); | 149 | } |
139 | return; | ||
140 | } | ||
141 | gtk_widget_set_sensitive (delete_button, TRUE); | 150 | gtk_widget_set_sensitive (delete_button, TRUE); |
142 | gtk_widget_set_sensitive (edit_button, TRUE); | 151 | gtk_widget_set_sensitive (edit_button, TRUE); |
143 | 152 | ||
144 | /* now figure out which move operations are currently legal */ | 153 | /* now figure out which move operations are currently legal */ |
145 | GNUNET_assert (TRUE == gtk_tree_selection_get_selected (sel, NULL, &iter)); | 154 | GNUNET_assert (TRUE == gtk_tree_selection_get_selected (sel, NULL, &iter)); |
146 | if (TRUE == gtk_tree_model_iter_next (tm, &iter)) | 155 | if (TRUE == gtk_tree_model_iter_next (tm, &iter)) |
147 | { | 156 | { |
148 | gtk_widget_set_sensitive (down_button, TRUE); | 157 | gtk_widget_set_sensitive (down_button, TRUE); |
149 | } | 158 | } |
150 | else | 159 | else |
151 | { | 160 | { |
152 | gtk_widget_set_sensitive (down_button, FALSE); | 161 | gtk_widget_set_sensitive (down_button, FALSE); |
153 | } | 162 | } |
154 | GNUNET_assert (TRUE == gtk_tree_selection_get_selected (sel, NULL, &iter)); | 163 | GNUNET_assert (TRUE == gtk_tree_selection_get_selected (sel, NULL, &iter)); |
155 | if (TRUE == gtk_tree_model_iter_parent (tm, &parent, &iter)) | 164 | if (TRUE == gtk_tree_model_iter_parent (tm, &parent, &iter)) |
156 | { | 165 | { |
157 | gtk_widget_set_sensitive (left_button, TRUE); | 166 | gtk_widget_set_sensitive (left_button, TRUE); |
158 | GNUNET_assert (TRUE == | 167 | GNUNET_assert (TRUE == gtk_tree_model_iter_children (tm, &pred, &parent)); |
159 | gtk_tree_model_iter_children (tm, &pred, &parent)); | 168 | } |
160 | } | ||
161 | else | 169 | else |
162 | { | 170 | { |
163 | gtk_widget_set_sensitive (left_button, FALSE); | 171 | gtk_widget_set_sensitive (left_button, FALSE); |
164 | GNUNET_assert (TRUE == | 172 | GNUNET_assert (TRUE == gtk_tree_model_get_iter_first (tm, &pred)); |
165 | gtk_tree_model_get_iter_first (tm, &pred)); | 173 | } |
166 | } | ||
167 | /* iterate over 'next' of pred to find out if our | 174 | /* iterate over 'next' of pred to find out if our |
168 | predecessor is a directory! */ | 175 | * predecessor is a directory! */ |
169 | is_dir = GNUNET_SYSERR; | 176 | is_dir = GNUNET_SYSERR; |
170 | while (GNUNET_YES != gtk_tree_iter_equals (tm, &pred, &iter)) | 177 | while (GNUNET_YES != gtk_tree_iter_equals (tm, &pred, &iter)) |
171 | { | 178 | { |
172 | gtk_tree_model_get (tm, &pred, | 179 | gtk_tree_model_get (tm, &pred, 5, &fip, -1); |
173 | 5, &fip, -1); | 180 | is_dir = GNUNET_FS_file_information_is_directory (fip); |
174 | is_dir = GNUNET_FS_file_information_is_directory (fip); | 181 | GNUNET_assert (TRUE == gtk_tree_model_iter_next (tm, &pred)); |
175 | GNUNET_assert (TRUE == gtk_tree_model_iter_next (tm, &pred)); | 182 | } |
176 | } | ||
177 | if (GNUNET_YES == is_dir) | 183 | if (GNUNET_YES == is_dir) |
178 | { | 184 | { |
179 | gtk_widget_set_sensitive (right_button, TRUE); | 185 | gtk_widget_set_sensitive (right_button, TRUE); |
180 | } | 186 | } |
181 | else | 187 | else |
182 | { | 188 | { |
183 | gtk_widget_set_sensitive (right_button, FALSE); | 189 | gtk_widget_set_sensitive (right_button, FALSE); |
184 | } | 190 | } |
185 | if (GNUNET_SYSERR != is_dir) | 191 | if (GNUNET_SYSERR != is_dir) |
186 | { | 192 | { |
187 | gtk_widget_set_sensitive (up_button, TRUE); | 193 | gtk_widget_set_sensitive (up_button, TRUE); |
188 | } | 194 | } |
189 | else | 195 | else |
190 | { | 196 | { |
191 | gtk_widget_set_sensitive (up_button, FALSE); | 197 | gtk_widget_set_sensitive (up_button, FALSE); |
192 | } | 198 | } |
193 | } | 199 | } |
194 | 200 | ||
195 | 201 | ||
@@ -202,10 +208,8 @@ update_selectivity () | |||
202 | * @param iter parent entry, or NULL for top-level addition | 208 | * @param iter parent entry, or NULL for top-level addition |
203 | */ | 209 | */ |
204 | static void | 210 | static void |
205 | add_file_at_iter (const char *filename, | 211 | add_file_at_iter (const char *filename, const struct GNUNET_FS_BlockOptions *bo, |
206 | const struct GNUNET_FS_BlockOptions *bo, | 212 | int do_index, GtkTreeIter * iter) |
207 | int do_index, | ||
208 | GtkTreeIter *iter) | ||
209 | { | 213 | { |
210 | struct GNUNET_FS_FileInformation *fi; | 214 | struct GNUNET_FS_FileInformation *fi; |
211 | GtkTreeRowReference *row_reference; | 215 | GtkTreeRowReference *row_reference; |
@@ -223,73 +227,53 @@ add_file_at_iter (const char *filename, | |||
223 | if (0 != STAT (filename, &sbuf)) | 227 | if (0 != STAT (filename, &sbuf)) |
224 | return; | 228 | return; |
225 | if (S_ISDIR (sbuf.st_mode)) | 229 | if (S_ISDIR (sbuf.st_mode)) |
226 | { | 230 | { |
227 | file_size = 0; | 231 | file_size = 0; |
228 | } | 232 | } |
229 | else | 233 | else |
234 | { | ||
235 | if (GNUNET_OK != GNUNET_DISK_file_size (filename, &file_size, GNUNET_YES)) | ||
230 | { | 236 | { |
231 | if (GNUNET_OK != | 237 | GNUNET_break (0); |
232 | GNUNET_DISK_file_size (filename, | 238 | return; |
233 | &file_size, | ||
234 | GNUNET_YES)) | ||
235 | { | ||
236 | GNUNET_break (0); | ||
237 | return; | ||
238 | } | ||
239 | } | 239 | } |
240 | ts = GTK_TREE_STORE (gtk_builder_get_object (master_builder, | 240 | } |
241 | "GNUNET_GTK_file_sharing_publishing_tree_store")); | 241 | ts = GTK_TREE_STORE (gtk_builder_get_object |
242 | (master_builder, | ||
243 | "GNUNET_GTK_file_sharing_publishing_tree_store")); | ||
242 | 244 | ||
243 | meta = GNUNET_CONTAINER_meta_data_create (); | 245 | meta = GNUNET_CONTAINER_meta_data_create (); |
244 | GNUNET_FS_meta_data_extract_from_file (meta, | 246 | GNUNET_FS_meta_data_extract_from_file (meta, filename, |
245 | filename, | 247 | GNUNET_FS_GTK_get_le_plugins ()); |
246 | GNUNET_FS_GTK_get_le_plugins()); | 248 | GNUNET_CONTAINER_meta_data_delete (meta, EXTRACTOR_METATYPE_FILENAME, NULL, |
247 | GNUNET_CONTAINER_meta_data_delete (meta, | 249 | 0); |
248 | EXTRACTOR_METATYPE_FILENAME, | ||
249 | NULL, 0); | ||
250 | short_fn = filename; | 250 | short_fn = filename; |
251 | while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR))) | 251 | while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR))) |
252 | short_fn = 1 + ss; | 252 | short_fn = 1 + ss; |
253 | GNUNET_CONTAINER_meta_data_insert (meta, | 253 | GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet-gtk>", |
254 | "<gnunet-gtk>", | 254 | EXTRACTOR_METATYPE_FILENAME, |
255 | EXTRACTOR_METATYPE_FILENAME, | 255 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", |
256 | EXTRACTOR_METAFORMAT_UTF8, | 256 | short_fn, strlen (short_fn) + 1); |
257 | "text/plain", | ||
258 | short_fn, | ||
259 | strlen(short_fn)+1); | ||
260 | ksk_uri = GNUNET_FS_uri_ksk_create_from_meta_data (meta); | 257 | ksk_uri = GNUNET_FS_uri_ksk_create_from_meta_data (meta); |
261 | gtk_tree_store_insert_before (ts, | 258 | gtk_tree_store_insert_before (ts, &pos, iter, NULL); |
262 | &pos, | 259 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), &pos); |
263 | iter, | 260 | row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts), path); |
264 | NULL); | ||
265 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), | ||
266 | &pos); | ||
267 | row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts), | ||
268 | path); | ||
269 | gtk_tree_path_free (path); | 261 | gtk_tree_path_free (path); |
270 | fi = GNUNET_FS_file_information_create_from_file (GNUNET_FS_GTK_get_fs_handle (), | 262 | fi = GNUNET_FS_file_information_create_from_file (GNUNET_FS_GTK_get_fs_handle |
271 | row_reference, | 263 | (), row_reference, filename, |
272 | filename, | 264 | ksk_uri, meta, do_index, |
273 | ksk_uri, | 265 | bo); |
274 | meta, | ||
275 | do_index, | ||
276 | bo); | ||
277 | GNUNET_CONTAINER_meta_data_destroy (meta); | 266 | GNUNET_CONTAINER_meta_data_destroy (meta); |
278 | GNUNET_FS_uri_destroy (ksk_uri); | 267 | GNUNET_FS_uri_destroy (ksk_uri); |
279 | if (S_ISDIR (sbuf.st_mode)) | 268 | if (S_ISDIR (sbuf.st_mode)) |
280 | file_size_fancy = GNUNET_strdup (MARKER_DIR_FILE_SIZE); | 269 | file_size_fancy = GNUNET_strdup (MARKER_DIR_FILE_SIZE); |
281 | else | 270 | else |
282 | file_size_fancy = GNUNET_STRINGS_byte_size_fancy (file_size); | 271 | file_size_fancy = GNUNET_STRINGS_byte_size_fancy (file_size); |
283 | gtk_tree_store_set (ts, &pos, | 272 | gtk_tree_store_set (ts, &pos, 0, file_size_fancy, 1, (gboolean) do_index, 2, |
284 | 0, file_size_fancy, | 273 | short_fn, 3, (guint) bo->anonymity_level, 4, |
285 | 1, (gboolean) do_index, | 274 | (guint) bo->content_priority, 5, fi, -1); |
286 | 2, short_fn, | ||
287 | 3, (guint) bo->anonymity_level, | ||
288 | 4, (guint) bo->content_priority, | ||
289 | 5, fi, | ||
290 | -1); | ||
291 | GNUNET_free (file_size_fancy); | 275 | GNUNET_free (file_size_fancy); |
292 | update_selectivity (); | 276 | update_selectivity (); |
293 | } | 277 | } |
294 | 278 | ||
295 | 279 | ||
@@ -303,10 +287,8 @@ add_file_at_iter (const char *filename, | |||
303 | * @param pos iterator to set to the location of the new element | 287 | * @param pos iterator to set to the location of the new element |
304 | */ | 288 | */ |
305 | static void | 289 | static void |
306 | create_dir_at_iter (const char *name, | 290 | create_dir_at_iter (const char *name, const struct GNUNET_FS_BlockOptions *bo, |
307 | const struct GNUNET_FS_BlockOptions *bo, | 291 | GtkTreeIter * iter, GtkTreeIter * pos) |
308 | GtkTreeIter *iter, | ||
309 | GtkTreeIter *pos) | ||
310 | { | 292 | { |
311 | struct GNUNET_FS_FileInformation *fi; | 293 | struct GNUNET_FS_FileInformation *fi; |
312 | GtkTreeRowReference *row_reference; | 294 | GtkTreeRowReference *row_reference; |
@@ -314,40 +296,25 @@ create_dir_at_iter (const char *name, | |||
314 | struct GNUNET_CONTAINER_MetaData *meta; | 296 | struct GNUNET_CONTAINER_MetaData *meta; |
315 | GtkTreeStore *ts; | 297 | GtkTreeStore *ts; |
316 | 298 | ||
317 | ts = GTK_TREE_STORE (gtk_builder_get_object (master_builder, | 299 | ts = GTK_TREE_STORE (gtk_builder_get_object |
318 | "GNUNET_GTK_file_sharing_publishing_tree_store")); | 300 | (master_builder, |
301 | "GNUNET_GTK_file_sharing_publishing_tree_store")); | ||
319 | meta = GNUNET_CONTAINER_meta_data_create (); | 302 | meta = GNUNET_CONTAINER_meta_data_create (); |
320 | GNUNET_FS_meta_data_make_directory (meta); | 303 | GNUNET_FS_meta_data_make_directory (meta); |
321 | GNUNET_CONTAINER_meta_data_insert (meta, | 304 | GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet-gtk>", |
322 | "<gnunet-gtk>", | 305 | EXTRACTOR_METATYPE_FILENAME, |
323 | EXTRACTOR_METATYPE_FILENAME, | 306 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", |
324 | EXTRACTOR_METAFORMAT_UTF8, | 307 | name, strlen (name) + 1); |
325 | "text/plain", | 308 | gtk_tree_store_insert_before (ts, pos, iter, NULL); |
326 | name, | 309 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), pos); |
327 | strlen(name)+1); | 310 | row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts), path); |
328 | gtk_tree_store_insert_before (ts, | ||
329 | pos, | ||
330 | iter, | ||
331 | NULL); | ||
332 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), | ||
333 | pos); | ||
334 | row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts), | ||
335 | path); | ||
336 | gtk_tree_path_free (path); | 311 | gtk_tree_path_free (path); |
337 | fi = GNUNET_FS_file_information_create_empty_directory (GNUNET_FS_GTK_get_fs_handle (), | 312 | fi = GNUNET_FS_file_information_create_empty_directory |
338 | row_reference, | 313 | (GNUNET_FS_GTK_get_fs_handle (), row_reference, NULL, meta, bo); |
339 | NULL, | ||
340 | meta, | ||
341 | bo); | ||
342 | GNUNET_CONTAINER_meta_data_destroy (meta); | 314 | GNUNET_CONTAINER_meta_data_destroy (meta); |
343 | gtk_tree_store_set (ts, pos, | 315 | gtk_tree_store_set (ts, pos, 0, MARKER_DIR_FILE_SIZE, 1, (gboolean) GNUNET_NO, |
344 | 0, MARKER_DIR_FILE_SIZE, | 316 | 2, name, 3, (guint) bo->anonymity_level, 4, |
345 | 1, (gboolean) GNUNET_NO, | 317 | (guint) bo->content_priority, 5, fi, -1); |
346 | 2, name, | ||
347 | 3, (guint) bo->anonymity_level, | ||
348 | 4, (guint) bo->content_priority, | ||
349 | 5, fi, | ||
350 | -1); | ||
351 | update_selectivity (); | 318 | update_selectivity (); |
352 | } | 319 | } |
353 | 320 | ||
@@ -393,7 +360,7 @@ struct MetaCounter | |||
393 | * Type of the value. | 360 | * Type of the value. |
394 | */ | 361 | */ |
395 | enum EXTRACTOR_MetaType type; | 362 | enum EXTRACTOR_MetaType type; |
396 | 363 | ||
397 | /** | 364 | /** |
398 | * Format of the value. | 365 | * Format of the value. |
399 | */ | 366 | */ |
@@ -478,13 +445,11 @@ struct AddDirContext | |||
478 | * @return 0 to continue extracting, 1 to abort | 445 | * @return 0 to continue extracting, 1 to abort |
479 | */ | 446 | */ |
480 | static int | 447 | static int |
481 | add_to_meta_counter (void *cls, | 448 | add_to_meta_counter (void *cls, const char *plugin_name, |
482 | const char *plugin_name, | 449 | enum EXTRACTOR_MetaType type, |
483 | enum EXTRACTOR_MetaType type, | 450 | enum EXTRACTOR_MetaFormat format, |
484 | enum EXTRACTOR_MetaFormat format, | 451 | const char *data_mime_type, const char *data, |
485 | const char *data_mime_type, | 452 | size_t data_len) |
486 | const char *data, | ||
487 | size_t data_len) | ||
488 | { | 453 | { |
489 | struct GNUNET_CONTAINER_MultiHashMap *mcm = cls; | 454 | struct GNUNET_CONTAINER_MultiHashMap *mcm = cls; |
490 | struct MetaCounter *cnt; | 455 | struct MetaCounter *cnt; |
@@ -492,44 +457,35 @@ add_to_meta_counter (void *cls, | |||
492 | size_t mlen; | 457 | size_t mlen; |
493 | size_t dlen; | 458 | size_t dlen; |
494 | 459 | ||
495 | if ( (format != EXTRACTOR_METAFORMAT_UTF8) && | 460 | if ((format != EXTRACTOR_METAFORMAT_UTF8) && |
496 | (format != EXTRACTOR_METAFORMAT_C_STRING) ) | 461 | (format != EXTRACTOR_METAFORMAT_C_STRING)) |
497 | return 0; | 462 | return 0; |
498 | dlen = strlen (data) + 1; | 463 | dlen = strlen (data) + 1; |
499 | GNUNET_CRYPTO_hash (data, | 464 | GNUNET_CRYPTO_hash (data, dlen - 1, &hc); |
500 | dlen - 1, | ||
501 | &hc); | ||
502 | cnt = GNUNET_CONTAINER_multihashmap_get (mcm, &hc); | 465 | cnt = GNUNET_CONTAINER_multihashmap_get (mcm, &hc); |
503 | if (cnt == NULL) | 466 | if (cnt == NULL) |
504 | { | 467 | { |
505 | mlen = strlen (data_mime_type) + 1; | 468 | mlen = strlen (data_mime_type) + 1; |
506 | cnt = GNUNET_malloc (sizeof (struct MetaCounter) + | 469 | cnt = GNUNET_malloc (sizeof (struct MetaCounter) + dlen + mlen); |
507 | dlen + mlen); | 470 | cnt->count = 1; |
508 | cnt->count = 1; | 471 | cnt->value = (const char *) &cnt[1]; |
509 | cnt->value = (const char *) &cnt[1]; | 472 | cnt->value_mimetype = &cnt->value[dlen]; |
510 | cnt->value_mimetype = &cnt->value[dlen]; | 473 | memcpy (&cnt[1], data, dlen); |
511 | memcpy (&cnt[1], | 474 | memcpy ((char *) cnt->value_mimetype, data_mime_type, mlen); |
512 | data, | 475 | cnt->type = type; |
513 | dlen); | 476 | cnt->format = format; |
514 | memcpy ((char*) cnt->value_mimetype, | 477 | GNUNET_CONTAINER_multihashmap_put (mcm, &hc, cnt, |
515 | data_mime_type, | 478 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
516 | mlen); | 479 | |
517 | cnt->type = type; | 480 | } |
518 | cnt->format = format; | ||
519 | GNUNET_CONTAINER_multihashmap_put (mcm, | ||
520 | &hc, | ||
521 | cnt, | ||
522 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | ||
523 | |||
524 | } | ||
525 | else | 481 | else |
526 | { | 482 | { |
527 | cnt->count++; | 483 | cnt->count++; |
528 | if (cnt->format == EXTRACTOR_METAFORMAT_C_STRING) | 484 | if (cnt->format == EXTRACTOR_METAFORMAT_C_STRING) |
529 | cnt->format = format; /* possibly improve to UTF8 */ | 485 | cnt->format = format; /* possibly improve to UTF8 */ |
530 | if (cnt->type == EXTRACTOR_METATYPE_UNKNOWN) | 486 | if (cnt->type == EXTRACTOR_METATYPE_UNKNOWN) |
531 | cnt->type = type; | 487 | cnt->type = type; |
532 | } | 488 | } |
533 | return 0; | 489 | return 0; |
534 | } | 490 | } |
535 | 491 | ||
@@ -542,8 +498,7 @@ add_to_meta_counter (void *cls, | |||
542 | * @param filename name of the file to process | 498 | * @param filename name of the file to process |
543 | */ | 499 | */ |
544 | static void | 500 | static void |
545 | extract_file (struct AddDirContext *adc, | 501 | extract_file (struct AddDirContext *adc, const char *filename) |
546 | const char *filename) | ||
547 | { | 502 | { |
548 | struct PublishData *pd; | 503 | struct PublishData *pd; |
549 | GNUNET_HashCode hc; | 504 | GNUNET_HashCode hc; |
@@ -553,38 +508,25 @@ extract_file (struct AddDirContext *adc, | |||
553 | adc->dir_entry_count++; | 508 | adc->dir_entry_count++; |
554 | pd = GNUNET_malloc (sizeof (struct PublishData)); | 509 | pd = GNUNET_malloc (sizeof (struct PublishData)); |
555 | pd->meta = GNUNET_CONTAINER_meta_data_create (); | 510 | pd->meta = GNUNET_CONTAINER_meta_data_create (); |
556 | GNUNET_FS_meta_data_extract_from_file (pd->meta, | 511 | GNUNET_FS_meta_data_extract_from_file (pd->meta, filename, |
557 | filename, | 512 | GNUNET_FS_GTK_get_le_plugins ()); |
558 | GNUNET_FS_GTK_get_le_plugins()); | 513 | GNUNET_CONTAINER_meta_data_delete (pd->meta, EXTRACTOR_METATYPE_FILENAME, |
559 | GNUNET_CONTAINER_meta_data_delete (pd->meta, | 514 | NULL, 0); |
560 | EXTRACTOR_METATYPE_FILENAME, | ||
561 | NULL, 0); | ||
562 | short_fn = filename; | 515 | short_fn = filename; |
563 | while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR))) | 516 | while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR))) |
564 | short_fn = 1 + ss; | 517 | short_fn = 1 + ss; |
565 | GNUNET_CONTAINER_meta_data_insert (pd->meta, | 518 | GNUNET_CONTAINER_meta_data_insert (pd->meta, "<gnunet-gtk>", |
566 | "<gnunet-gtk>", | 519 | EXTRACTOR_METATYPE_FILENAME, |
567 | EXTRACTOR_METATYPE_FILENAME, | 520 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", |
568 | EXTRACTOR_METAFORMAT_UTF8, | 521 | short_fn, strlen (short_fn) + 1); |
569 | "text/plain", | 522 | |
570 | short_fn, | 523 | |
571 | strlen(short_fn)+1); | 524 | gtk_tree_store_insert_before (adc->ts, &pd->iter, adc->parent, NULL); |
572 | 525 | GNUNET_CRYPTO_hash (filename, strlen (filename), &hc); | |
573 | 526 | GNUNET_CONTAINER_multihashmap_put (adc->metamap, &hc, pd, | |
574 | gtk_tree_store_insert_before (adc->ts, | 527 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
575 | &pd->iter, | 528 | GNUNET_CONTAINER_meta_data_iterate (pd->meta, &add_to_meta_counter, |
576 | adc->parent, | 529 | adc->metacounter); |
577 | NULL); | ||
578 | GNUNET_CRYPTO_hash (filename, | ||
579 | strlen (filename), | ||
580 | &hc); | ||
581 | GNUNET_CONTAINER_multihashmap_put (adc->metamap, | ||
582 | &hc, | ||
583 | pd, | ||
584 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | ||
585 | GNUNET_CONTAINER_meta_data_iterate (pd->meta, | ||
586 | &add_to_meta_counter, | ||
587 | adc->metacounter); | ||
588 | } | 530 | } |
589 | 531 | ||
590 | 532 | ||
@@ -597,12 +539,10 @@ extract_file (struct AddDirContext *adc, | |||
597 | * @return always GNUNET_OK | 539 | * @return always GNUNET_OK |
598 | */ | 540 | */ |
599 | static int | 541 | static int |
600 | remove_keyword (void *cls, | 542 | remove_keyword (void *cls, const char *keyword, int is_mandatory) |
601 | const char *keyword, | ||
602 | int is_mandatory) | ||
603 | { | 543 | { |
604 | struct GNUNET_FS_Uri *ksk = cls; | 544 | struct GNUNET_FS_Uri *ksk = cls; |
605 | 545 | ||
606 | GNUNET_FS_uri_ksk_remove_keyword (ksk, keyword); | 546 | GNUNET_FS_uri_ksk_remove_keyword (ksk, keyword); |
607 | return GNUNET_OK; | 547 | return GNUNET_OK; |
608 | } | 548 | } |
@@ -622,14 +562,11 @@ remove_keyword (void *cls, | |||
622 | * @param meta metadata for the file | 562 | * @param meta metadata for the file |
623 | */ | 563 | */ |
624 | static void | 564 | static void |
625 | add_entry_to_ts (GtkTreeStore *ts, | 565 | add_entry_to_ts (GtkTreeStore * ts, GtkTreeIter * iter, const char *filename, |
626 | GtkTreeIter *iter, | 566 | const struct GNUNET_FS_BlockOptions *bo, int do_index, |
627 | const char *filename, | 567 | struct GNUNET_CONTAINER_MetaData *md_no_ksk, |
628 | const struct GNUNET_FS_BlockOptions *bo, | 568 | struct GNUNET_CONTAINER_MetaData *meta) |
629 | int do_index, | 569 | { |
630 | struct GNUNET_CONTAINER_MetaData *md_no_ksk, | ||
631 | struct GNUNET_CONTAINER_MetaData *meta) | ||
632 | { | ||
633 | char *file_size_fancy; | 570 | char *file_size_fancy; |
634 | struct GNUNET_FS_FileInformation *fi; | 571 | struct GNUNET_FS_FileInformation *fi; |
635 | GtkTreeRowReference *row_reference; | 572 | GtkTreeRowReference *row_reference; |
@@ -644,59 +581,43 @@ add_entry_to_ts (GtkTreeStore *ts, | |||
644 | if (0 != STAT (filename, &sbuf)) | 581 | if (0 != STAT (filename, &sbuf)) |
645 | return; | 582 | return; |
646 | if (S_ISDIR (sbuf.st_mode)) | 583 | if (S_ISDIR (sbuf.st_mode)) |
647 | { | 584 | { |
648 | file_size = 0; | 585 | file_size = 0; |
649 | } | 586 | } |
650 | else | 587 | else |
588 | { | ||
589 | if (GNUNET_OK != GNUNET_DISK_file_size (filename, &file_size, GNUNET_YES)) | ||
651 | { | 590 | { |
652 | if (GNUNET_OK != | 591 | GNUNET_break (0); |
653 | GNUNET_DISK_file_size (filename, | 592 | return; |
654 | &file_size, | ||
655 | GNUNET_YES)) | ||
656 | { | ||
657 | GNUNET_break (0); | ||
658 | return; | ||
659 | } | ||
660 | } | 593 | } |
594 | } | ||
661 | ksk_uri = GNUNET_FS_uri_ksk_create_from_meta_data (meta); | 595 | ksk_uri = GNUNET_FS_uri_ksk_create_from_meta_data (meta); |
662 | kill_ksk = GNUNET_FS_uri_ksk_create_from_meta_data (md_no_ksk); | 596 | kill_ksk = GNUNET_FS_uri_ksk_create_from_meta_data (md_no_ksk); |
663 | if (kill_ksk != NULL) | 597 | if (kill_ksk != NULL) |
664 | { | 598 | { |
665 | GNUNET_FS_uri_ksk_get_keywords (kill_ksk, | 599 | GNUNET_FS_uri_ksk_get_keywords (kill_ksk, &remove_keyword, ksk_uri); |
666 | &remove_keyword, | 600 | GNUNET_FS_uri_destroy (kill_ksk); |
667 | ksk_uri); | 601 | } |
668 | GNUNET_FS_uri_destroy (kill_ksk); | 602 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), iter); |
669 | } | 603 | row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts), path); |
670 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), | ||
671 | iter); | ||
672 | row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts), | ||
673 | path); | ||
674 | gtk_tree_path_free (path); | 604 | gtk_tree_path_free (path); |
675 | if (S_ISDIR (sbuf.st_mode)) | 605 | if (S_ISDIR (sbuf.st_mode)) |
676 | { | 606 | { |
677 | GNUNET_CONTAINER_meta_data_delete (meta, | 607 | GNUNET_CONTAINER_meta_data_delete (meta, EXTRACTOR_METATYPE_MIMETYPE, NULL, |
678 | EXTRACTOR_METATYPE_MIMETYPE, | 608 | 0); |
679 | NULL, 0); | 609 | GNUNET_FS_meta_data_make_directory (meta); |
680 | GNUNET_FS_meta_data_make_directory (meta); | 610 | GNUNET_FS_uri_ksk_add_keyword (ksk_uri, GNUNET_FS_DIRECTORY_MIME, |
681 | GNUNET_FS_uri_ksk_add_keyword (ksk_uri, | 611 | GNUNET_NO); |
682 | GNUNET_FS_DIRECTORY_MIME, | 612 | fi = GNUNET_FS_file_information_create_empty_directory |
683 | GNUNET_NO); | 613 | (GNUNET_FS_GTK_get_fs_handle (), row_reference, ksk_uri, meta, bo); |
684 | fi = GNUNET_FS_file_information_create_empty_directory (GNUNET_FS_GTK_get_fs_handle (), | 614 | } |
685 | row_reference, | ||
686 | ksk_uri, | ||
687 | meta, | ||
688 | bo); | ||
689 | } | ||
690 | else | 615 | else |
691 | { | 616 | { |
692 | fi = GNUNET_FS_file_information_create_from_file (GNUNET_FS_GTK_get_fs_handle (), | 617 | fi = GNUNET_FS_file_information_create_from_file |
693 | row_reference, | 618 | (GNUNET_FS_GTK_get_fs_handle (), row_reference, filename, ksk_uri, meta, |
694 | filename, | 619 | do_index, bo); |
695 | ksk_uri, | 620 | } |
696 | meta, | ||
697 | do_index, | ||
698 | bo); | ||
699 | } | ||
700 | GNUNET_CONTAINER_meta_data_destroy (meta); | 621 | GNUNET_CONTAINER_meta_data_destroy (meta); |
701 | GNUNET_FS_uri_destroy (ksk_uri); | 622 | GNUNET_FS_uri_destroy (ksk_uri); |
702 | if (S_ISDIR (sbuf.st_mode)) | 623 | if (S_ISDIR (sbuf.st_mode)) |
@@ -706,14 +627,9 @@ add_entry_to_ts (GtkTreeStore *ts, | |||
706 | short_fn = filename; | 627 | short_fn = filename; |
707 | while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR))) | 628 | while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR))) |
708 | short_fn = 1 + ss; | 629 | short_fn = 1 + ss; |
709 | gtk_tree_store_set (ts, iter, | 630 | gtk_tree_store_set (ts, iter, 0, file_size_fancy, 1, (gboolean) do_index, 2, |
710 | 0, file_size_fancy, | 631 | short_fn, 3, (guint) bo->anonymity_level, 4, |
711 | 1, (gboolean) do_index, | 632 | (guint) bo->content_priority, 5, fi, -1); |
712 | 2, short_fn, | ||
713 | 3, (guint) bo->anonymity_level, | ||
714 | 4, (guint) bo->content_priority, | ||
715 | 5, fi, | ||
716 | -1); | ||
717 | GNUNET_free (file_size_fancy); | 633 | GNUNET_free (file_size_fancy); |
718 | } | 634 | } |
719 | 635 | ||
@@ -727,28 +643,17 @@ add_entry_to_ts (GtkTreeStore *ts, | |||
727 | * @param filename file or directory to scan | 643 | * @param filename file or directory to scan |
728 | */ | 644 | */ |
729 | static int | 645 | static int |
730 | publish_entry (void *cls, | 646 | publish_entry (void *cls, const char *filename) |
731 | const char *filename) | ||
732 | { | 647 | { |
733 | struct AddDirContext *adc = cls; | 648 | struct AddDirContext *adc = cls; |
734 | struct PublishData *pd; | 649 | struct PublishData *pd; |
735 | GNUNET_HashCode hc; | 650 | GNUNET_HashCode hc; |
736 | 651 | ||
737 | GNUNET_CRYPTO_hash (filename, | 652 | GNUNET_CRYPTO_hash (filename, strlen (filename), &hc); |
738 | strlen (filename), | 653 | pd = GNUNET_CONTAINER_multihashmap_get (adc->metamap, &hc); |
739 | &hc); | 654 | add_entry_to_ts (adc->ts, &pd->iter, filename, &adc->bo, adc->do_index, |
740 | pd = GNUNET_CONTAINER_multihashmap_get (adc->metamap, | 655 | adc->no_ksk, pd->meta); |
741 | &hc); | 656 | GNUNET_CONTAINER_multihashmap_remove (adc->metamap, &hc, pd); |
742 | add_entry_to_ts (adc->ts, | ||
743 | &pd->iter, | ||
744 | filename, | ||
745 | &adc->bo, | ||
746 | adc->do_index, | ||
747 | adc->no_ksk, | ||
748 | pd->meta); | ||
749 | GNUNET_CONTAINER_multihashmap_remove (adc->metamap, | ||
750 | &hc, | ||
751 | pd); | ||
752 | GNUNET_free (pd); | 657 | GNUNET_free (pd); |
753 | return GNUNET_OK; | 658 | return GNUNET_OK; |
754 | } | 659 | } |
@@ -778,23 +683,18 @@ struct MetaProcessContext | |||
778 | * | 683 | * |
779 | */ | 684 | */ |
780 | static int | 685 | static int |
781 | migrate_and_drop (void *cls, | 686 | migrate_and_drop (void *cls, const GNUNET_HashCode * key, void *value) |
782 | const GNUNET_HashCode *key, | ||
783 | void *value) | ||
784 | { | 687 | { |
785 | struct MetaProcessContext *mpc = cls; | 688 | struct MetaProcessContext *mpc = cls; |
786 | struct MetaCounter *counter = value; | 689 | struct MetaCounter *counter = value; |
787 | 690 | ||
788 | if (counter->count >= mpc->threshold) | 691 | if (counter->count >= mpc->threshold) |
789 | { | 692 | { |
790 | GNUNET_CONTAINER_meta_data_insert (mpc->md, | 693 | GNUNET_CONTAINER_meta_data_insert (mpc->md, "<gnunet-gtk>", counter->type, |
791 | "<gnunet-gtk>", | 694 | counter->format, counter->value_mimetype, |
792 | counter->type, | 695 | counter->value, |
793 | counter->format, | 696 | strlen (counter->value) + 1); |
794 | counter->value_mimetype, | 697 | } |
795 | counter->value, | ||
796 | strlen (counter->value)+1); | ||
797 | } | ||
798 | GNUNET_free (counter); | 698 | GNUNET_free (counter); |
799 | return GNUNET_YES; | 699 | return GNUNET_YES; |
800 | } | 700 | } |
@@ -814,10 +714,9 @@ process_metadata (struct AddDirContext *adc) | |||
814 | struct MetaProcessContext mpc; | 714 | struct MetaProcessContext mpc; |
815 | 715 | ||
816 | mpc.md = GNUNET_CONTAINER_meta_data_create (); | 716 | mpc.md = GNUNET_CONTAINER_meta_data_create (); |
817 | mpc.threshold = (adc->dir_entry_count + 1) / 2; /* 50% */ | 717 | mpc.threshold = (adc->dir_entry_count + 1) / 2; /* 50% */ |
818 | GNUNET_CONTAINER_multihashmap_iterate (adc->metacounter, | 718 | GNUNET_CONTAINER_multihashmap_iterate (adc->metacounter, &migrate_and_drop, |
819 | &migrate_and_drop, | 719 | &mpc); |
820 | &mpc); | ||
821 | GNUNET_CONTAINER_multihashmap_destroy (adc->metacounter); | 720 | GNUNET_CONTAINER_multihashmap_destroy (adc->metacounter); |
822 | return mpc.md; | 721 | return mpc.md; |
823 | } | 722 | } |
@@ -832,9 +731,7 @@ process_metadata (struct AddDirContext *adc) | |||
832 | * @param filename file or directory to scan | 731 | * @param filename file or directory to scan |
833 | */ | 732 | */ |
834 | static int | 733 | static int |
835 | scan_directory (void *cls, | 734 | scan_directory (void *cls, const char *filename) |
836 | const char *filename) | ||
837 | |||
838 | { | 735 | { |
839 | struct AddDirContext *adc = cls; | 736 | struct AddDirContext *adc = cls; |
840 | struct stat sbuf; | 737 | struct stat sbuf; |
@@ -848,64 +745,46 @@ scan_directory (void *cls, | |||
848 | if (0 != STAT (filename, &sbuf)) | 745 | if (0 != STAT (filename, &sbuf)) |
849 | return GNUNET_OK; | 746 | return GNUNET_OK; |
850 | if (S_ISDIR (sbuf.st_mode)) | 747 | if (S_ISDIR (sbuf.st_mode)) |
748 | { | ||
749 | parent = adc->parent; | ||
750 | mhm = adc->metamap; | ||
751 | mcm = adc->metacounter; | ||
752 | pc = adc->dir_entry_count; | ||
753 | adc->metamap = GNUNET_CONTAINER_multihashmap_create (1024); | ||
754 | adc->metacounter = GNUNET_CONTAINER_multihashmap_create (1024); | ||
755 | adc->dir_entry_count = 0; | ||
756 | pd = GNUNET_malloc (sizeof (struct PublishData)); | ||
757 | gtk_tree_store_insert_before (adc->ts, &pd->iter, parent, NULL); | ||
758 | adc->parent = &pd->iter; | ||
759 | GNUNET_DISK_directory_scan (filename, &scan_directory, adc); | ||
760 | pd->meta = process_metadata (adc); | ||
761 | adc->no_ksk = pd->meta; | ||
762 | GNUNET_DISK_directory_scan (filename, &publish_entry, adc); | ||
763 | GNUNET_CONTAINER_multihashmap_destroy (adc->metamap); | ||
764 | adc->metamap = mhm; | ||
765 | adc->metacounter = mcm; | ||
766 | adc->parent = parent; | ||
767 | adc->dir_entry_count = pc + 1; | ||
768 | if (adc->metamap != NULL) | ||
851 | { | 769 | { |
852 | parent = adc->parent; | 770 | GNUNET_CRYPTO_hash (filename, strlen (filename), &hc); |
853 | mhm = adc->metamap; | 771 | GNUNET_CONTAINER_multihashmap_put (adc->metamap, &hc, pd, |
854 | mcm = adc->metacounter; | 772 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
855 | pc = adc->dir_entry_count; | 773 | GNUNET_CONTAINER_meta_data_iterate (pd->meta, &add_to_meta_counter, mcm); |
856 | adc->metamap = GNUNET_CONTAINER_multihashmap_create (1024); | ||
857 | adc->metacounter = GNUNET_CONTAINER_multihashmap_create (1024); | ||
858 | adc->dir_entry_count = 0; | ||
859 | pd = GNUNET_malloc (sizeof (struct PublishData)); | ||
860 | gtk_tree_store_insert_before (adc->ts, | ||
861 | &pd->iter, | ||
862 | parent, | ||
863 | NULL); | ||
864 | adc->parent = &pd->iter; | ||
865 | GNUNET_DISK_directory_scan (filename, | ||
866 | &scan_directory, | ||
867 | adc); | ||
868 | pd->meta = process_metadata (adc); | ||
869 | adc->no_ksk = pd->meta; | ||
870 | GNUNET_DISK_directory_scan (filename, | ||
871 | &publish_entry, | ||
872 | adc); | ||
873 | GNUNET_CONTAINER_multihashmap_destroy (adc->metamap); | ||
874 | adc->metamap = mhm; | ||
875 | adc->metacounter = mcm; | ||
876 | adc->parent = parent; | ||
877 | adc->dir_entry_count = pc + 1; | ||
878 | if (adc->metamap != NULL) | ||
879 | { | ||
880 | GNUNET_CRYPTO_hash (filename, | ||
881 | strlen (filename), | ||
882 | &hc); | ||
883 | GNUNET_CONTAINER_multihashmap_put (adc->metamap, | ||
884 | &hc, | ||
885 | pd, | ||
886 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | ||
887 | GNUNET_CONTAINER_meta_data_iterate (pd->meta, | ||
888 | &add_to_meta_counter, | ||
889 | mcm); | ||
890 | } | ||
891 | else | ||
892 | { | ||
893 | GNUNET_assert (mcm == NULL); | ||
894 | /* we're top-level */ | ||
895 | add_entry_to_ts (adc->ts, | ||
896 | &pd->iter, | ||
897 | filename, | ||
898 | &adc->bo, | ||
899 | adc->do_index, | ||
900 | NULL, | ||
901 | pd->meta); | ||
902 | } | ||
903 | } | 774 | } |
904 | else | 775 | else |
905 | { | 776 | { |
906 | GNUNET_assert (adc->metamap != NULL); | 777 | GNUNET_assert (mcm == NULL); |
907 | extract_file (adc, filename); | 778 | /* we're top-level */ |
779 | add_entry_to_ts (adc->ts, &pd->iter, filename, &adc->bo, adc->do_index, | ||
780 | NULL, pd->meta); | ||
908 | } | 781 | } |
782 | } | ||
783 | else | ||
784 | { | ||
785 | GNUNET_assert (adc->metamap != NULL); | ||
786 | extract_file (adc, filename); | ||
787 | } | ||
909 | return GNUNET_OK; | 788 | return GNUNET_OK; |
910 | } | 789 | } |
911 | 790 | ||
@@ -918,25 +797,26 @@ scan_directory (void *cls, | |||
918 | * @param do_index should we index? | 797 | * @param do_index should we index? |
919 | */ | 798 | */ |
920 | static void | 799 | static void |
921 | add_dir (const char *filename, | 800 | add_dir (const char *filename, const struct GNUNET_FS_BlockOptions *bo, |
922 | const struct GNUNET_FS_BlockOptions *bo, | 801 | int do_index) |
923 | int do_index) | ||
924 | { | 802 | { |
925 | struct stat sbuf; | 803 | struct stat sbuf; |
926 | struct AddDirContext scan_ctx; | 804 | struct AddDirContext scan_ctx; |
927 | 805 | ||
928 | if (0 != STAT (filename, &sbuf)) | 806 | if (0 != STAT (filename, &sbuf)) |
929 | return; | 807 | return; |
930 | if (! S_ISDIR (sbuf.st_mode)) | 808 | if (!S_ISDIR (sbuf.st_mode)) |
931 | { | 809 | { |
932 | GNUNET_break (0); | 810 | GNUNET_break (0); |
933 | return; | 811 | return; |
934 | } | 812 | } |
935 | memset (&scan_ctx, 0, sizeof (scan_ctx)); | 813 | memset (&scan_ctx, 0, sizeof (scan_ctx)); |
936 | scan_ctx.bo = *bo; | 814 | scan_ctx.bo = *bo; |
937 | scan_ctx.do_index = do_index; | 815 | scan_ctx.do_index = do_index; |
938 | scan_ctx.ts = GTK_TREE_STORE (gtk_builder_get_object (master_builder, | 816 | scan_ctx.ts = |
939 | "GNUNET_GTK_file_sharing_publishing_tree_store")); | 817 | GTK_TREE_STORE (gtk_builder_get_object |
818 | (master_builder, | ||
819 | "GNUNET_GTK_file_sharing_publishing_tree_store")); | ||
940 | scan_directory (&scan_ctx, filename); | 820 | scan_directory (&scan_ctx, filename); |
941 | } | 821 | } |
942 | 822 | ||
@@ -945,22 +825,20 @@ add_dir (const char *filename, | |||
945 | 825 | ||
946 | 826 | ||
947 | static void | 827 | static void |
948 | selection_changed_cb (GtkTreeSelection *ts, | 828 | selection_changed_cb (GtkTreeSelection * ts, gpointer user_data) |
949 | gpointer user_data) | ||
950 | { | 829 | { |
951 | update_selectivity (); | 830 | update_selectivity (); |
952 | } | 831 | } |
953 | 832 | ||
954 | 833 | ||
955 | static void | 834 | static void |
956 | remove_old_entry (GtkTreeStore *ts, | 835 | remove_old_entry (GtkTreeStore * ts, GtkTreeIter * root) |
957 | GtkTreeIter *root) | ||
958 | { | 836 | { |
959 | GtkTreeIter child; | 837 | GtkTreeIter child; |
960 | 838 | ||
961 | while (TRUE == gtk_tree_model_iter_children (GTK_TREE_MODEL (ts), | 839 | while (TRUE == |
962 | &child, root)) | 840 | gtk_tree_model_iter_children (GTK_TREE_MODEL (ts), &child, root)) |
963 | remove_old_entry (ts, &child); | 841 | remove_old_entry (ts, &child); |
964 | gtk_tree_store_remove (ts, root); | 842 | gtk_tree_store_remove (ts, root); |
965 | } | 843 | } |
966 | 844 | ||
@@ -969,10 +847,8 @@ remove_old_entry (GtkTreeStore *ts, | |||
969 | * Move an entry in the tree. | 847 | * Move an entry in the tree. |
970 | */ | 848 | */ |
971 | static void | 849 | static void |
972 | move_entry (GtkTreeModel *tm, | 850 | move_entry (GtkTreeModel * tm, GtkTreeIter * old, GtkTreeIter * newpos, |
973 | GtkTreeIter *old, | 851 | int dsel) |
974 | GtkTreeIter *newpos, | ||
975 | int dsel) | ||
976 | { | 852 | { |
977 | struct GNUNET_FS_FileInformation *fip; | 853 | struct GNUNET_FS_FileInformation *fip; |
978 | GtkTreeView *tv; | 854 | GtkTreeView *tv; |
@@ -987,72 +863,56 @@ move_entry (GtkTreeModel *tm, | |||
987 | GtkTreeIter cnewpos; | 863 | GtkTreeIter cnewpos; |
988 | GtkTreeRowReference *rr; | 864 | GtkTreeRowReference *rr; |
989 | GtkTreeRowReference *rr2; | 865 | GtkTreeRowReference *rr2; |
990 | 866 | ||
991 | gtk_tree_model_get (tm, | 867 | gtk_tree_model_get (tm, old, 0, &fsf, 1, &do_index, 2, &short_fn, 3, |
992 | old, | 868 | &anonymity_level, 4, &priority, 5, &fip, -1); |
993 | 0, &fsf, | 869 | gtk_tree_store_set (GTK_TREE_STORE (tm), newpos, 0, fsf, 1, do_index, 2, |
994 | 1, &do_index, | 870 | short_fn, 3, (guint) anonymity_level, 4, (guint) priority, |
995 | 2, &short_fn, | 871 | 5, fip, -1); |
996 | 3, &anonymity_level, | ||
997 | 4, &priority, | ||
998 | 5, &fip, | ||
999 | -1); | ||
1000 | gtk_tree_store_set (GTK_TREE_STORE (tm), newpos, | ||
1001 | 0, fsf, | ||
1002 | 1, do_index, | ||
1003 | 2, short_fn, | ||
1004 | 3, (guint)anonymity_level, | ||
1005 | 4, (guint) priority, | ||
1006 | 5, fip, | ||
1007 | -1); | ||
1008 | sel = NULL; | 872 | sel = NULL; |
1009 | tv = NULL; | 873 | tv = NULL; |
1010 | if (dsel == GNUNET_YES) | 874 | if (dsel == GNUNET_YES) |
1011 | { | 875 | { |
1012 | tv = GTK_TREE_VIEW (gtk_builder_get_object (master_builder, | 876 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1013 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 877 | (master_builder, |
1014 | sel = gtk_tree_view_get_selection (tv); | 878 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); |
1015 | path = gtk_tree_model_get_path (tm, newpos); | 879 | sel = gtk_tree_view_get_selection (tv); |
1016 | rr = gtk_tree_row_reference_new (tm, path); | 880 | path = gtk_tree_model_get_path (tm, newpos); |
1017 | gtk_tree_path_free (path); | 881 | rr = gtk_tree_row_reference_new (tm, path); |
1018 | } | 882 | gtk_tree_path_free (path); |
883 | } | ||
1019 | else | 884 | else |
1020 | { | 885 | { |
1021 | rr = NULL; | 886 | rr = NULL; |
1022 | } | 887 | } |
1023 | if (TRUE == gtk_tree_model_iter_children (tm, &child, old)) | 888 | if (TRUE == gtk_tree_model_iter_children (tm, &child, old)) |
889 | { | ||
890 | do | ||
1024 | { | 891 | { |
1025 | do | 892 | path = gtk_tree_model_get_path (tm, &child); |
1026 | { | 893 | rr2 = gtk_tree_row_reference_new (tm, path); |
1027 | path = gtk_tree_model_get_path (tm, &child); | 894 | gtk_tree_path_free (path); |
1028 | rr2 = gtk_tree_row_reference_new (tm, path); | 895 | gtk_tree_store_insert_before (GTK_TREE_STORE (tm), &cnewpos, newpos, |
1029 | gtk_tree_path_free (path); | 896 | NULL); |
1030 | gtk_tree_store_insert_before (GTK_TREE_STORE (tm), | 897 | move_entry (tm, &child, &cnewpos, GNUNET_NO); |
1031 | &cnewpos, newpos, NULL); | 898 | path = gtk_tree_row_reference_get_path (rr2); |
1032 | move_entry (tm, &child, &cnewpos, GNUNET_NO); | 899 | gtk_tree_row_reference_free (rr2); |
1033 | path = gtk_tree_row_reference_get_path (rr2); | 900 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, &child, path)); |
1034 | gtk_tree_row_reference_free (rr2); | 901 | gtk_tree_path_free (path); |
1035 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, | ||
1036 | &child, | ||
1037 | path)); | ||
1038 | gtk_tree_path_free (path); | ||
1039 | } | ||
1040 | while (TRUE == gtk_tree_model_iter_next (tm, &child)); | ||
1041 | } | 902 | } |
903 | while (TRUE == gtk_tree_model_iter_next (tm, &child)); | ||
904 | } | ||
1042 | g_free (short_fn); | 905 | g_free (short_fn); |
1043 | g_free (fsf); | 906 | g_free (fsf); |
1044 | if (dsel == GNUNET_YES) | 907 | if (dsel == GNUNET_YES) |
1045 | { | 908 | { |
1046 | path = gtk_tree_row_reference_get_path (rr); | 909 | path = gtk_tree_row_reference_get_path (rr); |
1047 | gtk_tree_row_reference_free (rr); | 910 | gtk_tree_row_reference_free (rr); |
1048 | gtk_tree_view_expand_to_path (tv, path); | 911 | gtk_tree_view_expand_to_path (tv, path); |
1049 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, | 912 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, newpos, path)); |
1050 | newpos, | 913 | gtk_tree_path_free (path); |
1051 | path)); | 914 | gtk_tree_selection_select_iter (sel, newpos); |
1052 | gtk_tree_path_free (path); | 915 | } |
1053 | gtk_tree_selection_select_iter (sel, | ||
1054 | newpos); | ||
1055 | } | ||
1056 | update_selectivity (); | 916 | update_selectivity (); |
1057 | } | 917 | } |
1058 | 918 | ||
@@ -1060,24 +920,22 @@ move_entry (GtkTreeModel *tm, | |||
1060 | * User has changed the "current" identifier for the content in | 920 | * User has changed the "current" identifier for the content in |
1061 | * the GtkTreeView. Update the model. | 921 | * the GtkTreeView. Update the model. |
1062 | */ | 922 | */ |
1063 | void | 923 | void GNUNET_GTK_master_publish_dialog_pseudonym_updates_renderer_edited_cb |
1064 | GNUNET_GTK_master_publish_dialog_pseudonym_updates_renderer_edited_cb (GtkCellRendererText *renderer, | 924 | (GtkCellRendererText * renderer, gchar * cpath, gchar * new_text, |
1065 | gchar *cpath, | 925 | gpointer user_data) |
1066 | gchar *new_text, | ||
1067 | gpointer user_data) | ||
1068 | { | 926 | { |
1069 | GtkTreeIter iter; | 927 | GtkTreeIter iter; |
1070 | GtkTreeStore *ts; | 928 | GtkTreeStore *ts; |
1071 | 929 | ||
1072 | ts = GTK_TREE_STORE (gtk_builder_get_object (master_builder, | 930 | ts = GTK_TREE_STORE (gtk_builder_get_object |
1073 | "GNUNET_GTK_pseudonym_tree_store")); | 931 | (master_builder, "GNUNET_GTK_pseudonym_tree_store")); |
1074 | 932 | ||
1075 | if (TRUE != | 933 | if (TRUE != |
1076 | gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ts), &iter, cpath)) | 934 | gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ts), &iter, cpath)) |
1077 | { | 935 | { |
1078 | GNUNET_break (0); | 936 | GNUNET_break (0); |
1079 | return; | 937 | return; |
1080 | } | 938 | } |
1081 | gtk_tree_store_set (ts, &iter, 5, new_text, -1); | 939 | gtk_tree_store_set (ts, &iter, 5, new_text, -1); |
1082 | update_selectivity (); | 940 | update_selectivity (); |
1083 | } | 941 | } |
@@ -1087,32 +945,30 @@ GNUNET_GTK_master_publish_dialog_pseudonym_updates_renderer_edited_cb (GtkCellRe | |||
1087 | * User has changed the "current" identifier for the content in | 945 | * User has changed the "current" identifier for the content in |
1088 | * the GtkTreeView. Update the model. | 946 | * the GtkTreeView. Update the model. |
1089 | */ | 947 | */ |
1090 | void | 948 | void GNUNET_GTK_master_publish_dialog_pseudonym_identifier_renderer_edited_cb |
1091 | GNUNET_GTK_master_publish_dialog_pseudonym_identifier_renderer_edited_cb (GtkCellRendererText *renderer, | 949 | (GtkCellRendererText * renderer, gchar * cpath, gchar * new_text, |
1092 | gchar *cpath, | 950 | gpointer user_data) |
1093 | gchar *new_text, | ||
1094 | gpointer user_data) | ||
1095 | { | 951 | { |
1096 | GtkTreeIter iter; | 952 | GtkTreeIter iter; |
1097 | GtkTreeStore *ts; | 953 | GtkTreeStore *ts; |
1098 | 954 | ||
1099 | ts = GTK_TREE_STORE (gtk_builder_get_object (master_builder, | 955 | ts = GTK_TREE_STORE (gtk_builder_get_object |
1100 | "GNUNET_GTK_pseudonym_tree_store")); | 956 | (master_builder, "GNUNET_GTK_pseudonym_tree_store")); |
1101 | 957 | ||
1102 | if (TRUE != | 958 | if (TRUE != |
1103 | gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ts), &iter, cpath)) | 959 | gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ts), &iter, cpath)) |
1104 | { | 960 | { |
1105 | GNUNET_break (0); | 961 | GNUNET_break (0); |
1106 | return; | 962 | return; |
1107 | } | 963 | } |
1108 | gtk_tree_store_set (ts, &iter, 2, new_text, -1); | 964 | gtk_tree_store_set (ts, &iter, 2, new_text, -1); |
1109 | update_selectivity (); | 965 | update_selectivity (); |
1110 | } | 966 | } |
1111 | 967 | ||
1112 | 968 | ||
1113 | void | 969 | void |
1114 | GNUNET_GTK_master_publish_dialog_right_button_clicked_cb (GtkWidget * dummy, | 970 | GNUNET_GTK_master_publish_dialog_right_button_clicked_cb (GtkWidget * dummy, |
1115 | gpointer data) | 971 | gpointer data) |
1116 | { | 972 | { |
1117 | GtkTreeView *tv; | 973 | GtkTreeView *tv; |
1118 | GtkTreeModel *tm; | 974 | GtkTreeModel *tm; |
@@ -1123,49 +979,45 @@ GNUNET_GTK_master_publish_dialog_right_button_clicked_cb (GtkWidget * dummy, | |||
1123 | GtkTreeIter prev; | 979 | GtkTreeIter prev; |
1124 | GtkTreeIter pos; | 980 | GtkTreeIter pos; |
1125 | 981 | ||
1126 | tv = GTK_TREE_VIEW (gtk_builder_get_object (master_builder, | 982 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1127 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 983 | (master_builder, |
984 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | ||
1128 | sel = gtk_tree_view_get_selection (tv); | 985 | sel = gtk_tree_view_get_selection (tv); |
1129 | if (TRUE != gtk_tree_selection_get_selected (sel, | 986 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
1130 | &tm, | 987 | { |
1131 | &iter)) | 988 | GNUNET_break (0); |
1132 | { | 989 | return; |
1133 | GNUNET_break (0); | 990 | } |
1134 | return; | ||
1135 | } | ||
1136 | if (TRUE == gtk_tree_model_iter_parent (tm, &parent, &iter)) | 991 | if (TRUE == gtk_tree_model_iter_parent (tm, &parent, &iter)) |
1137 | { | 992 | { |
1138 | GNUNET_assert (TRUE == gtk_tree_model_iter_children (tm, &pred, &parent)); | 993 | GNUNET_assert (TRUE == gtk_tree_model_iter_children (tm, &pred, &parent)); |
1139 | } | 994 | } |
1140 | else if (TRUE != gtk_tree_model_get_iter_first (tm, &pred)) | 995 | else if (TRUE != gtk_tree_model_get_iter_first (tm, &pred)) |
1141 | { | 996 | { |
1142 | GNUNET_break (0); | 997 | GNUNET_break (0); |
1143 | return; | 998 | return; |
1144 | } | 999 | } |
1145 | /* iterate over 'next' of pred to find out who our predecessor is! */ | 1000 | /* iterate over 'next' of pred to find out who our predecessor is! */ |
1146 | memset (&prev, 0, sizeof (GtkTreeIter)); | 1001 | memset (&prev, 0, sizeof (GtkTreeIter)); |
1147 | while (GNUNET_YES != gtk_tree_iter_equals (tm, &pred, &iter)) | 1002 | while (GNUNET_YES != gtk_tree_iter_equals (tm, &pred, &iter)) |
1148 | { | 1003 | { |
1149 | prev = pred; | 1004 | prev = pred; |
1150 | GNUNET_assert (TRUE == gtk_tree_model_iter_next (tm, &pred)); | 1005 | GNUNET_assert (TRUE == gtk_tree_model_iter_next (tm, &pred)); |
1151 | } | 1006 | } |
1152 | gtk_tree_store_insert_before (GTK_TREE_STORE (tm), | 1007 | gtk_tree_store_insert_before (GTK_TREE_STORE (tm), &pos, &prev, NULL); |
1153 | &pos, &prev, NULL); | 1008 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
1154 | if (TRUE != gtk_tree_selection_get_selected (sel, | 1009 | { |
1155 | &tm, | 1010 | GNUNET_break (0); |
1156 | &iter)) | 1011 | return; |
1157 | { | 1012 | } |
1158 | GNUNET_break (0); | ||
1159 | return; | ||
1160 | } | ||
1161 | move_entry (tm, &iter, &pos, GNUNET_YES); | 1013 | move_entry (tm, &iter, &pos, GNUNET_YES); |
1162 | remove_old_entry (GTK_TREE_STORE (tm), &iter); | 1014 | remove_old_entry (GTK_TREE_STORE (tm), &iter); |
1163 | } | 1015 | } |
1164 | 1016 | ||
1165 | 1017 | ||
1166 | void | 1018 | void |
1167 | GNUNET_GTK_master_publish_dialog_left_button_clicked_cb (GtkWidget * dummy, | 1019 | GNUNET_GTK_master_publish_dialog_left_button_clicked_cb (GtkWidget * dummy, |
1168 | gpointer data) | 1020 | gpointer data) |
1169 | { | 1021 | { |
1170 | GtkTreeView *tv; | 1022 | GtkTreeView *tv; |
1171 | GtkTreeModel *tm; | 1023 | GtkTreeModel *tm; |
@@ -1174,38 +1026,34 @@ GNUNET_GTK_master_publish_dialog_left_button_clicked_cb (GtkWidget * dummy, | |||
1174 | GtkTreeIter parent; | 1026 | GtkTreeIter parent; |
1175 | GtkTreeIter pos; | 1027 | GtkTreeIter pos; |
1176 | 1028 | ||
1177 | tv = GTK_TREE_VIEW (gtk_builder_get_object (master_builder, | 1029 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1178 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 1030 | (master_builder, |
1031 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | ||
1179 | sel = gtk_tree_view_get_selection (tv); | 1032 | sel = gtk_tree_view_get_selection (tv); |
1180 | if (TRUE != gtk_tree_selection_get_selected (sel, | 1033 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
1181 | &tm, | 1034 | { |
1182 | &iter)) | 1035 | GNUNET_break (0); |
1183 | { | 1036 | return; |
1184 | GNUNET_break (0); | 1037 | } |
1185 | return; | ||
1186 | } | ||
1187 | if (TRUE != gtk_tree_model_iter_parent (tm, &parent, &iter)) | 1038 | if (TRUE != gtk_tree_model_iter_parent (tm, &parent, &iter)) |
1188 | { | 1039 | { |
1189 | GNUNET_break (0); | 1040 | GNUNET_break (0); |
1190 | return; | 1041 | return; |
1191 | } | 1042 | } |
1192 | gtk_tree_store_insert_after (GTK_TREE_STORE (tm), | 1043 | gtk_tree_store_insert_after (GTK_TREE_STORE (tm), &pos, NULL, &parent); |
1193 | &pos, NULL, &parent); | 1044 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
1194 | if (TRUE != gtk_tree_selection_get_selected (sel, | 1045 | { |
1195 | &tm, | 1046 | GNUNET_break (0); |
1196 | &iter)) | 1047 | return; |
1197 | { | 1048 | } |
1198 | GNUNET_break (0); | ||
1199 | return; | ||
1200 | } | ||
1201 | move_entry (tm, &iter, &pos, GNUNET_YES); | 1049 | move_entry (tm, &iter, &pos, GNUNET_YES); |
1202 | remove_old_entry (GTK_TREE_STORE (tm), &iter); | 1050 | remove_old_entry (GTK_TREE_STORE (tm), &iter); |
1203 | } | 1051 | } |
1204 | 1052 | ||
1205 | 1053 | ||
1206 | void | 1054 | void |
1207 | GNUNET_GTK_master_publish_dialog_up_button_clicked_cb (GtkWidget * dummy, | 1055 | GNUNET_GTK_master_publish_dialog_up_button_clicked_cb (GtkWidget * dummy, |
1208 | gpointer data) | 1056 | gpointer data) |
1209 | { | 1057 | { |
1210 | GtkTreeView *tv; | 1058 | GtkTreeView *tv; |
1211 | GtkTreeModel *tm; | 1059 | GtkTreeModel *tm; |
@@ -1217,54 +1065,50 @@ GNUNET_GTK_master_publish_dialog_up_button_clicked_cb (GtkWidget * dummy, | |||
1217 | GtkTreeIter *pprev; | 1065 | GtkTreeIter *pprev; |
1218 | GtkTreeIter pos; | 1066 | GtkTreeIter pos; |
1219 | 1067 | ||
1220 | tv = GTK_TREE_VIEW (gtk_builder_get_object (master_builder, | 1068 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1221 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 1069 | (master_builder, |
1070 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | ||
1222 | sel = gtk_tree_view_get_selection (tv); | 1071 | sel = gtk_tree_view_get_selection (tv); |
1223 | if (TRUE != gtk_tree_selection_get_selected (sel, | 1072 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
1224 | &tm, | 1073 | { |
1225 | &iter)) | 1074 | GNUNET_break (0); |
1226 | { | 1075 | return; |
1227 | GNUNET_break (0); | 1076 | } |
1228 | return; | ||
1229 | } | ||
1230 | if (TRUE == gtk_tree_model_iter_parent (tm, &parent, &iter)) | 1077 | if (TRUE == gtk_tree_model_iter_parent (tm, &parent, &iter)) |
1231 | { | 1078 | { |
1232 | GNUNET_assert (TRUE == gtk_tree_model_iter_children (tm, &pred, &parent)); | 1079 | GNUNET_assert (TRUE == gtk_tree_model_iter_children (tm, &pred, &parent)); |
1233 | pprev = &parent; | 1080 | pprev = &parent; |
1234 | } | 1081 | } |
1235 | else if (TRUE == gtk_tree_model_get_iter_first (tm, &pred)) | 1082 | else if (TRUE == gtk_tree_model_get_iter_first (tm, &pred)) |
1236 | { | 1083 | { |
1237 | pprev = NULL; | 1084 | pprev = NULL; |
1238 | } | 1085 | } |
1239 | else | 1086 | else |
1240 | { | 1087 | { |
1241 | GNUNET_break (0); | 1088 | GNUNET_break (0); |
1242 | return; | 1089 | return; |
1243 | } | 1090 | } |
1244 | /* iterate over 'next' of pred to find out who our predecessor is! */ | 1091 | /* iterate over 'next' of pred to find out who our predecessor is! */ |
1245 | while (GNUNET_YES != gtk_tree_iter_equals (tm, &pred, &iter)) | 1092 | while (GNUNET_YES != gtk_tree_iter_equals (tm, &pred, &iter)) |
1246 | { | 1093 | { |
1247 | prev = pred; | 1094 | prev = pred; |
1248 | pprev = &prev; | 1095 | pprev = &prev; |
1249 | GNUNET_assert (TRUE == gtk_tree_model_iter_next (tm, &pred)); | 1096 | GNUNET_assert (TRUE == gtk_tree_model_iter_next (tm, &pred)); |
1250 | } | 1097 | } |
1251 | gtk_tree_store_insert_before (GTK_TREE_STORE (tm), | 1098 | gtk_tree_store_insert_before (GTK_TREE_STORE (tm), &pos, NULL, pprev); |
1252 | &pos, NULL, pprev); | 1099 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
1253 | if (TRUE != gtk_tree_selection_get_selected (sel, | 1100 | { |
1254 | &tm, | 1101 | GNUNET_break (0); |
1255 | &iter)) | 1102 | return; |
1256 | { | 1103 | } |
1257 | GNUNET_break (0); | ||
1258 | return; | ||
1259 | } | ||
1260 | move_entry (tm, &iter, &pos, GNUNET_YES); | 1104 | move_entry (tm, &iter, &pos, GNUNET_YES); |
1261 | remove_old_entry (GTK_TREE_STORE (tm), &iter); | 1105 | remove_old_entry (GTK_TREE_STORE (tm), &iter); |
1262 | } | 1106 | } |
1263 | 1107 | ||
1264 | 1108 | ||
1265 | void | 1109 | void |
1266 | GNUNET_GTK_master_publish_dialog_down_button_clicked_cb (GtkWidget * dummy, | 1110 | GNUNET_GTK_master_publish_dialog_down_button_clicked_cb (GtkWidget * dummy, |
1267 | gpointer data) | 1111 | gpointer data) |
1268 | { | 1112 | { |
1269 | GtkTreeView *tv; | 1113 | GtkTreeView *tv; |
1270 | GtkTreeModel *tm; | 1114 | GtkTreeModel *tm; |
@@ -1273,41 +1117,35 @@ GNUNET_GTK_master_publish_dialog_down_button_clicked_cb (GtkWidget * dummy, | |||
1273 | GtkTreeIter next; | 1117 | GtkTreeIter next; |
1274 | GtkTreeIter pos; | 1118 | GtkTreeIter pos; |
1275 | 1119 | ||
1276 | tv = GTK_TREE_VIEW (gtk_builder_get_object (master_builder, | 1120 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1277 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 1121 | (master_builder, |
1122 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | ||
1278 | sel = gtk_tree_view_get_selection (tv); | 1123 | sel = gtk_tree_view_get_selection (tv); |
1279 | if (TRUE != gtk_tree_selection_get_selected (sel, | 1124 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
1280 | &tm, | 1125 | { |
1281 | &iter)) | 1126 | GNUNET_break (0); |
1282 | { | 1127 | return; |
1283 | GNUNET_break (0); | 1128 | } |
1284 | return; | 1129 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &next)) |
1285 | } | 1130 | { |
1286 | if (TRUE != gtk_tree_selection_get_selected (sel, | 1131 | GNUNET_break (0); |
1287 | &tm, | 1132 | return; |
1288 | &next)) | 1133 | } |
1289 | { | ||
1290 | GNUNET_break (0); | ||
1291 | return; | ||
1292 | } | ||
1293 | GNUNET_assert (TRUE == gtk_tree_model_iter_next (tm, &next)); | 1134 | GNUNET_assert (TRUE == gtk_tree_model_iter_next (tm, &next)); |
1294 | gtk_tree_store_insert_after (GTK_TREE_STORE (tm), | 1135 | gtk_tree_store_insert_after (GTK_TREE_STORE (tm), &pos, NULL, &next); |
1295 | &pos, NULL, &next); | 1136 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
1296 | if (TRUE != gtk_tree_selection_get_selected (sel, | 1137 | { |
1297 | &tm, | 1138 | GNUNET_break (0); |
1298 | &iter)) | 1139 | return; |
1299 | { | 1140 | } |
1300 | GNUNET_break (0); | ||
1301 | return; | ||
1302 | } | ||
1303 | move_entry (tm, &iter, &pos, GNUNET_YES); | 1141 | move_entry (tm, &iter, &pos, GNUNET_YES); |
1304 | remove_old_entry (GTK_TREE_STORE (tm), &iter); | 1142 | remove_old_entry (GTK_TREE_STORE (tm), &iter); |
1305 | } | 1143 | } |
1306 | 1144 | ||
1307 | 1145 | ||
1308 | void | 1146 | void |
1309 | GNUNET_GTK_master_publish_dialog_new_button_clicked_cb (GtkWidget * dummy, | 1147 | GNUNET_GTK_master_publish_dialog_new_button_clicked_cb (GtkWidget * dummy, |
1310 | gpointer data) | 1148 | gpointer data) |
1311 | { | 1149 | { |
1312 | GtkTreeView *tv; | 1150 | GtkTreeView *tv; |
1313 | GtkTreeSelection *sel; | 1151 | GtkTreeSelection *sel; |
@@ -1315,8 +1153,9 @@ GNUNET_GTK_master_publish_dialog_new_button_clicked_cb (GtkWidget * dummy, | |||
1315 | GtkTreeIter pos; | 1153 | GtkTreeIter pos; |
1316 | struct GNUNET_FS_BlockOptions bo; | 1154 | struct GNUNET_FS_BlockOptions bo; |
1317 | 1155 | ||
1318 | tv = GTK_TREE_VIEW (gtk_builder_get_object (master_builder, | 1156 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1319 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 1157 | (master_builder, |
1158 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | ||
1320 | sel = gtk_tree_view_get_selection (tv); | 1159 | sel = gtk_tree_view_get_selection (tv); |
1321 | /* FIXME: consider opening a dialog to get | 1160 | /* FIXME: consider opening a dialog to get |
1322 | * anonymity, priority and expiration prior | 1161 | * anonymity, priority and expiration prior |
@@ -1325,26 +1164,21 @@ GNUNET_GTK_master_publish_dialog_new_button_clicked_cb (GtkWidget * dummy, | |||
1325 | */ | 1164 | */ |
1326 | bo.anonymity_level = 1; | 1165 | bo.anonymity_level = 1; |
1327 | bo.content_priority = 1000; | 1166 | bo.content_priority = 1000; |
1328 | bo.expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS); | 1167 | bo.expiration_time = |
1168 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS); | ||
1329 | bo.replication_level = 1; | 1169 | bo.replication_level = 1; |
1330 | if (TRUE != gtk_tree_selection_get_selected (sel, | 1170 | if (TRUE != gtk_tree_selection_get_selected (sel, NULL, &iter)) |
1331 | NULL, | 1171 | { |
1332 | &iter)) | 1172 | create_dir_at_iter ("unnamed/", &bo, NULL, &pos); |
1333 | { | 1173 | return; |
1334 | create_dir_at_iter ("unnamed/", | 1174 | } |
1335 | &bo, | 1175 | create_dir_at_iter ("unnamed/", &bo, &iter, &pos); |
1336 | NULL, &pos); | ||
1337 | return; | ||
1338 | } | ||
1339 | create_dir_at_iter ("unnamed/", | ||
1340 | &bo, | ||
1341 | &iter, &pos); | ||
1342 | } | 1176 | } |
1343 | 1177 | ||
1344 | 1178 | ||
1345 | void | 1179 | void |
1346 | GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy, | 1180 | GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy, |
1347 | gpointer data) | 1181 | gpointer data) |
1348 | { | 1182 | { |
1349 | GtkWidget *ad; | 1183 | GtkWidget *ad; |
1350 | GtkBuilder *builder; | 1184 | GtkBuilder *builder; |
@@ -1353,35 +1187,44 @@ GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy, | |||
1353 | int do_index; | 1187 | int do_index; |
1354 | GtkSpinButton *sb; | 1188 | GtkSpinButton *sb; |
1355 | 1189 | ||
1356 | builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_file_dialog.glade"); | 1190 | builder = |
1191 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_file_dialog.glade"); | ||
1357 | if (builder == NULL) | 1192 | if (builder == NULL) |
1358 | { | 1193 | { |
1359 | GNUNET_break (0); | 1194 | GNUNET_break (0); |
1360 | return; | 1195 | return; |
1361 | } | 1196 | } |
1362 | ad = GTK_WIDGET (gtk_builder_get_object (builder, | 1197 | ad = GTK_WIDGET (gtk_builder_get_object |
1363 | "GNUNET_GTK_publish_file_dialog")); | 1198 | (builder, "GNUNET_GTK_publish_file_dialog")); |
1364 | GNUNET_FS_GTK_setup_expiration_year_adjustment (builder); | 1199 | GNUNET_FS_GTK_setup_expiration_year_adjustment (builder); |
1365 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) | 1200 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) |
1366 | { | 1201 | { |
1367 | gtk_widget_destroy (ad); | 1202 | gtk_widget_destroy (ad); |
1368 | g_object_unref (G_OBJECT (builder)); | 1203 | g_object_unref (G_OBJECT (builder)); |
1369 | return; | 1204 | return; |
1370 | } | 1205 | } |
1371 | filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(ad)); | 1206 | filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (ad)); |
1372 | sb = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 1207 | sb = GTK_SPIN_BUTTON (gtk_builder_get_object |
1373 | "GNUNET_GTK_publish_file_dialog_expiration_year_spin_button")); | 1208 | (builder, |
1374 | bo.anonymity_level = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 1209 | "GNUNET_GTK_publish_file_dialog_expiration_year_spin_button")); |
1375 | "GNUNET_GTK_publish_file_dialog_anonymity_spin_button"))); | 1210 | bo.anonymity_level = |
1376 | bo.content_priority = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 1211 | gtk_spin_button_get_value (GTK_SPIN_BUTTON |
1377 | "GNUNET_GTK_publish_file_dialog_priority_spin_button"))); | 1212 | (gtk_builder_get_object |
1213 | (builder, | ||
1214 | "GNUNET_GTK_publish_file_dialog_anonymity_spin_button"))); | ||
1215 | bo.content_priority = | ||
1216 | gtk_spin_button_get_value (GTK_SPIN_BUTTON | ||
1217 | (gtk_builder_get_object | ||
1218 | (builder, | ||
1219 | "GNUNET_GTK_publish_file_dialog_priority_spin_button"))); | ||
1378 | bo.expiration_time = GNUNET_FS_GTK_get_expiration_time (sb); | 1220 | bo.expiration_time = GNUNET_FS_GTK_get_expiration_time (sb); |
1379 | bo.replication_level = 1; /* FIXME... */ | 1221 | bo.replication_level = 1; /* FIXME... */ |
1380 | do_index = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, | 1222 | do_index = |
1381 | "GNUNET_GTK_publish_file_dialog_do_index_checkbutton"))); | 1223 | gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON |
1382 | add_file_at_iter (filename, | 1224 | (gtk_builder_get_object |
1383 | &bo, do_index, | 1225 | (builder, |
1384 | NULL); | 1226 | "GNUNET_GTK_publish_file_dialog_do_index_checkbutton"))); |
1227 | add_file_at_iter (filename, &bo, do_index, NULL); | ||
1385 | gtk_widget_destroy (ad); | 1228 | gtk_widget_destroy (ad); |
1386 | g_object_unref (G_OBJECT (builder)); | 1229 | g_object_unref (G_OBJECT (builder)); |
1387 | g_free (filename); | 1230 | g_free (filename); |
@@ -1390,8 +1233,8 @@ GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy, | |||
1390 | 1233 | ||
1391 | 1234 | ||
1392 | void | 1235 | void |
1393 | GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy, | 1236 | GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy, |
1394 | gpointer data) | 1237 | gpointer data) |
1395 | { | 1238 | { |
1396 | GtkTreeView *tv; | 1239 | GtkTreeView *tv; |
1397 | GtkTreeModel *tm; | 1240 | GtkTreeModel *tm; |
@@ -1403,36 +1246,21 @@ GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy, | |||
1403 | gchar *short_fn; | 1246 | gchar *short_fn; |
1404 | struct GNUNET_FS_FileInformation *fip; | 1247 | struct GNUNET_FS_FileInformation *fip; |
1405 | 1248 | ||
1406 | tv = GTK_TREE_VIEW (gtk_builder_get_object (master_builder, | 1249 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1407 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 1250 | (master_builder, |
1251 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | ||
1408 | sel = gtk_tree_view_get_selection (tv); | 1252 | sel = gtk_tree_view_get_selection (tv); |
1409 | if (TRUE != gtk_tree_selection_get_selected (sel, | 1253 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
1410 | &tm, | 1254 | { |
1411 | &iter)) | 1255 | GNUNET_break (0); |
1412 | { | 1256 | return; |
1413 | GNUNET_break (0); | 1257 | } |
1414 | return; | 1258 | gtk_tree_model_get (tm, &iter, 1, &do_index, 2, &short_fn, 3, |
1415 | } | 1259 | &anonymity_level, 4, &priority, 5, &fip, -1); |
1416 | gtk_tree_model_get (tm, | 1260 | GNUNET_FS_GTK_edit_publish_dialog (&do_index, &short_fn, &anonymity_level, |
1417 | &iter, | 1261 | &priority, fip); |
1418 | 1, &do_index, | 1262 | gtk_tree_store_set (GTK_TREE_STORE (tm), &iter, 1, do_index, 2, short_fn, 3, |
1419 | 2, &short_fn, | 1263 | anonymity_level, 4, priority, -1); |
1420 | 3, &anonymity_level, | ||
1421 | 4, &priority, | ||
1422 | 5, &fip, | ||
1423 | -1); | ||
1424 | GNUNET_FS_GTK_edit_publish_dialog (&do_index, | ||
1425 | &short_fn, | ||
1426 | &anonymity_level, | ||
1427 | &priority, | ||
1428 | fip); | ||
1429 | gtk_tree_store_set (GTK_TREE_STORE (tm), | ||
1430 | &iter, | ||
1431 | 1, do_index, | ||
1432 | 2, short_fn, | ||
1433 | 3, anonymity_level, | ||
1434 | 4, priority, | ||
1435 | -1); | ||
1436 | g_free (short_fn); | 1264 | g_free (short_fn); |
1437 | } | 1265 | } |
1438 | 1266 | ||
@@ -1442,22 +1270,19 @@ GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy, | |||
1442 | * client-info pointer. | 1270 | * client-info pointer. |
1443 | */ | 1271 | */ |
1444 | static int | 1272 | static int |
1445 | free_fi_row_reference (void *cls, | 1273 | free_fi_row_reference (void *cls, struct GNUNET_FS_FileInformation *fi, |
1446 | struct GNUNET_FS_FileInformation *fi, | 1274 | uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, |
1447 | uint64_t length, | 1275 | struct GNUNET_FS_Uri **uri, |
1448 | struct GNUNET_CONTAINER_MetaData *meta, | 1276 | struct GNUNET_FS_BlockOptions *bo, int *do_index, |
1449 | struct GNUNET_FS_Uri **uri, | 1277 | void **client_info) |
1450 | struct GNUNET_FS_BlockOptions *bo, | ||
1451 | int *do_index, | ||
1452 | void **client_info) | ||
1453 | { | 1278 | { |
1454 | GtkTreeRowReference *row = *client_info; | 1279 | GtkTreeRowReference *row = *client_info; |
1455 | 1280 | ||
1456 | if (row == NULL) | 1281 | if (row == NULL) |
1457 | { | 1282 | { |
1458 | GNUNET_break (0); | 1283 | GNUNET_break (0); |
1459 | return GNUNET_OK; | 1284 | return GNUNET_OK; |
1460 | } | 1285 | } |
1461 | gtk_tree_row_reference_free (row); | 1286 | gtk_tree_row_reference_free (row); |
1462 | return GNUNET_OK; | 1287 | return GNUNET_OK; |
1463 | } | 1288 | } |
@@ -1465,8 +1290,8 @@ free_fi_row_reference (void *cls, | |||
1465 | 1290 | ||
1466 | 1291 | ||
1467 | void | 1292 | void |
1468 | GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget * dummy, | 1293 | GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget * dummy, |
1469 | gpointer data) | 1294 | gpointer data) |
1470 | { | 1295 | { |
1471 | GtkTreeView *tv; | 1296 | GtkTreeView *tv; |
1472 | GtkTreeModel *tm; | 1297 | GtkTreeModel *tm; |
@@ -1474,32 +1299,25 @@ GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget * dummy, | |||
1474 | GtkTreeIter iter; | 1299 | GtkTreeIter iter; |
1475 | struct GNUNET_FS_FileInformation *fip; | 1300 | struct GNUNET_FS_FileInformation *fip; |
1476 | 1301 | ||
1477 | tv = GTK_TREE_VIEW (gtk_builder_get_object (master_builder, | 1302 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1478 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 1303 | (master_builder, |
1304 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | ||
1479 | sel = gtk_tree_view_get_selection (tv); | 1305 | sel = gtk_tree_view_get_selection (tv); |
1480 | if (TRUE != gtk_tree_selection_get_selected (sel, | 1306 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
1481 | &tm, | 1307 | { |
1482 | &iter)) | 1308 | GNUNET_break (0); |
1483 | { | 1309 | return; |
1484 | GNUNET_break (0); | 1310 | } |
1485 | return; | 1311 | gtk_tree_model_get (tm, &iter, 5, &fip, -1); |
1486 | } | 1312 | GNUNET_FS_file_information_destroy (fip, &free_fi_row_reference, NULL); |
1487 | gtk_tree_model_get (tm, | 1313 | gtk_tree_store_remove (GTK_TREE_STORE (tm), &iter); |
1488 | &iter, | ||
1489 | 5, &fip, | ||
1490 | -1); | ||
1491 | GNUNET_FS_file_information_destroy (fip, | ||
1492 | &free_fi_row_reference, | ||
1493 | NULL); | ||
1494 | gtk_tree_store_remove (GTK_TREE_STORE (tm), | ||
1495 | &iter); | ||
1496 | update_selectivity (); | 1314 | update_selectivity (); |
1497 | } | 1315 | } |
1498 | 1316 | ||
1499 | 1317 | ||
1500 | void | 1318 | void |
1501 | GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget * dummy, | 1319 | GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget * dummy, |
1502 | gpointer data) | 1320 | gpointer data) |
1503 | { | 1321 | { |
1504 | GtkWidget *ad; | 1322 | GtkWidget *ad; |
1505 | GtkBuilder *builder; | 1323 | GtkBuilder *builder; |
@@ -1508,32 +1326,44 @@ GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget * dummy, | |||
1508 | GtkSpinButton *sb; | 1326 | GtkSpinButton *sb; |
1509 | struct GNUNET_FS_BlockOptions bo; | 1327 | struct GNUNET_FS_BlockOptions bo; |
1510 | 1328 | ||
1511 | builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_directory_dialog.glade"); | 1329 | builder = |
1330 | GNUNET_GTK_get_new_builder | ||
1331 | ("gnunet_fs_gtk_publish_directory_dialog.glade"); | ||
1512 | if (builder == NULL) | 1332 | if (builder == NULL) |
1513 | { | 1333 | { |
1514 | GNUNET_break (0); | 1334 | GNUNET_break (0); |
1515 | return; | 1335 | return; |
1516 | } | 1336 | } |
1517 | GNUNET_FS_GTK_setup_expiration_year_adjustment (builder); | 1337 | GNUNET_FS_GTK_setup_expiration_year_adjustment (builder); |
1518 | ad = GTK_WIDGET (gtk_builder_get_object (builder, | 1338 | ad = GTK_WIDGET (gtk_builder_get_object |
1519 | "GNUNET_GTK_publish_directory_dialog")); | 1339 | (builder, "GNUNET_GTK_publish_directory_dialog")); |
1520 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) | 1340 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) |
1521 | { | 1341 | { |
1522 | gtk_widget_destroy (ad); | 1342 | gtk_widget_destroy (ad); |
1523 | g_object_unref (G_OBJECT (builder)); | 1343 | g_object_unref (G_OBJECT (builder)); |
1524 | return; | 1344 | return; |
1525 | } | 1345 | } |
1526 | filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(ad)); | 1346 | filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (ad)); |
1527 | sb = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 1347 | sb = GTK_SPIN_BUTTON (gtk_builder_get_object |
1528 | "GNUNET_GTK_publish_directory_dialog_expiration_year_spin_button")); | 1348 | (builder, |
1529 | bo.anonymity_level = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 1349 | "GNUNET_GTK_publish_directory_dialog_expiration_year_spin_button")); |
1530 | "GNUNET_GTK_publish_directory_dialog_anonymity_spin_button"))); | 1350 | bo.anonymity_level = |
1531 | bo.content_priority = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 1351 | gtk_spin_button_get_value (GTK_SPIN_BUTTON |
1532 | "GNUNET_GTK_publish_directory_dialog_priority_spin_button"))); | 1352 | (gtk_builder_get_object |
1353 | (builder, | ||
1354 | "GNUNET_GTK_publish_directory_dialog_anonymity_spin_button"))); | ||
1355 | bo.content_priority = | ||
1356 | gtk_spin_button_get_value (GTK_SPIN_BUTTON | ||
1357 | (gtk_builder_get_object | ||
1358 | (builder, | ||
1359 | "GNUNET_GTK_publish_directory_dialog_priority_spin_button"))); | ||
1533 | bo.expiration_time = GNUNET_FS_GTK_get_expiration_time (sb); | 1360 | bo.expiration_time = GNUNET_FS_GTK_get_expiration_time (sb); |
1534 | do_index = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, | 1361 | do_index = |
1535 | "GNUNET_GTK_publish_directory_dialog_do_index_checkbutton"))); | 1362 | gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON |
1536 | 1363 | (gtk_builder_get_object | |
1364 | (builder, | ||
1365 | "GNUNET_GTK_publish_directory_dialog_do_index_checkbutton"))); | ||
1366 | |||
1537 | gtk_widget_destroy (ad); | 1367 | gtk_widget_destroy (ad); |
1538 | g_object_unref (G_OBJECT (builder)); | 1368 | g_object_unref (G_OBJECT (builder)); |
1539 | /* FIXME: open progress dialog here... */ | 1369 | /* FIXME: open progress dialog here... */ |
@@ -1553,32 +1383,25 @@ GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget * dummy, | |||
1553 | * @return file information from the given position (never NULL) | 1383 | * @return file information from the given position (never NULL) |
1554 | */ | 1384 | */ |
1555 | static struct GNUNET_FS_FileInformation * | 1385 | static struct GNUNET_FS_FileInformation * |
1556 | get_file_information (GtkTreeModel *tm, | 1386 | get_file_information (GtkTreeModel * tm, GtkTreeIter * iter) |
1557 | GtkTreeIter *iter) | ||
1558 | { | 1387 | { |
1559 | struct GNUNET_FS_FileInformation *fi; | 1388 | struct GNUNET_FS_FileInformation *fi; |
1560 | struct GNUNET_FS_FileInformation *fic; | 1389 | struct GNUNET_FS_FileInformation *fic; |
1561 | GtkTreeIter child; | 1390 | GtkTreeIter child; |
1562 | 1391 | ||
1563 | gtk_tree_model_get (tm, iter, | 1392 | gtk_tree_model_get (tm, iter, 5, &fi, -1); |
1564 | 5, &fi, | 1393 | gtk_tree_store_set (GTK_TREE_STORE (tm), iter, 5, NULL, -1); |
1565 | -1); | ||
1566 | gtk_tree_store_set (GTK_TREE_STORE (tm), iter, | ||
1567 | 5, NULL, | ||
1568 | -1); | ||
1569 | GNUNET_assert (fi != NULL); | 1394 | GNUNET_assert (fi != NULL); |
1570 | if (gtk_tree_model_iter_children (tm, &child, iter)) | 1395 | if (gtk_tree_model_iter_children (tm, &child, iter)) |
1396 | { | ||
1397 | GNUNET_break (GNUNET_YES == GNUNET_FS_file_information_is_directory (fi)); | ||
1398 | do | ||
1571 | { | 1399 | { |
1572 | GNUNET_break (GNUNET_YES == | 1400 | fic = get_file_information (tm, &child); |
1573 | GNUNET_FS_file_information_is_directory (fi)); | 1401 | GNUNET_break (GNUNET_OK == GNUNET_FS_file_information_add (fi, fic)); |
1574 | do | ||
1575 | { | ||
1576 | fic = get_file_information (tm, &child); | ||
1577 | GNUNET_break (GNUNET_OK == | ||
1578 | GNUNET_FS_file_information_add (fi, fic)); | ||
1579 | } | ||
1580 | while (gtk_tree_model_iter_next (tm, &child)); | ||
1581 | } | 1402 | } |
1403 | while (gtk_tree_model_iter_next (tm, &child)); | ||
1404 | } | ||
1582 | return fi; | 1405 | return fi; |
1583 | } | 1406 | } |
1584 | 1407 | ||
@@ -1590,7 +1413,7 @@ struct UpdateableContext | |||
1590 | { | 1413 | { |
1591 | /** | 1414 | /** |
1592 | * Parent of current insertion. | 1415 | * Parent of current insertion. |
1593 | */ | 1416 | */ |
1594 | GtkTreeIter *parent; | 1417 | GtkTreeIter *parent; |
1595 | 1418 | ||
1596 | /** | 1419 | /** |
@@ -1628,13 +1451,12 @@ struct UpdateableContext | |||
1628 | * @param last_uri associated URI | 1451 | * @param last_uri associated URI |
1629 | * @param last_meta associate meta data | 1452 | * @param last_meta associate meta data |
1630 | * @param next_id ID for future updates | 1453 | * @param next_id ID for future updates |
1631 | */ | 1454 | */ |
1632 | static void | 1455 | static void |
1633 | add_updateable_to_ts (void *cls, | 1456 | add_updateable_to_ts (void *cls, const char *last_id, |
1634 | const char *last_id, | 1457 | const struct GNUNET_FS_Uri *last_uri, |
1635 | const struct GNUNET_FS_Uri *last_uri, | 1458 | const struct GNUNET_CONTAINER_MetaData *last_meta, |
1636 | const struct GNUNET_CONTAINER_MetaData *last_meta, | 1459 | const char *next_id) |
1637 | const char *next_id) | ||
1638 | { | 1460 | { |
1639 | struct UpdateableContext *uc = cls; | 1461 | struct UpdateableContext *uc = cls; |
1640 | struct UpdateableContext sc; | 1462 | struct UpdateableContext sc; |
@@ -1644,41 +1466,31 @@ add_updateable_to_ts (void *cls, | |||
1644 | GNUNET_HashCode hc; | 1466 | GNUNET_HashCode hc; |
1645 | 1467 | ||
1646 | uc->update_called = GNUNET_YES; | 1468 | uc->update_called = GNUNET_YES; |
1647 | GNUNET_CRYPTO_hash (last_id, | 1469 | GNUNET_CRYPTO_hash (last_id, strlen (last_id), &hc); |
1648 | strlen (last_id), | 1470 | if (NULL != GNUNET_CONTAINER_multihashmap_get (uc->seen, &hc)) |
1649 | &hc); | ||
1650 | if (NULL != | ||
1651 | GNUNET_CONTAINER_multihashmap_get (uc->seen, | ||
1652 | &hc)) | ||
1653 | return; | 1471 | return; |
1654 | GNUNET_CONTAINER_multihashmap_put (uc->seen, | 1472 | GNUNET_CONTAINER_multihashmap_put (uc->seen, &hc, "dummy", |
1655 | &hc, | 1473 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
1656 | "dummy", | 1474 | desc = |
1657 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 1475 | GNUNET_CONTAINER_meta_data_get_first_by_types (last_meta, |
1658 | desc = GNUNET_CONTAINER_meta_data_get_first_by_types (last_meta, | 1476 | EXTRACTOR_METATYPE_DESCRIPTION, |
1659 | EXTRACTOR_METATYPE_DESCRIPTION, | 1477 | EXTRACTOR_METATYPE_TITLE, |
1660 | EXTRACTOR_METATYPE_TITLE, | 1478 | EXTRACTOR_METATYPE_BOOK_TITLE, |
1661 | EXTRACTOR_METATYPE_BOOK_TITLE, | 1479 | EXTRACTOR_METATYPE_FILENAME, |
1662 | EXTRACTOR_METATYPE_FILENAME, | 1480 | EXTRACTOR_METATYPE_SUMMARY, |
1663 | EXTRACTOR_METATYPE_SUMMARY, | 1481 | EXTRACTOR_METATYPE_ALBUM, |
1664 | EXTRACTOR_METATYPE_ALBUM, | 1482 | EXTRACTOR_METATYPE_COMMENT, |
1665 | EXTRACTOR_METATYPE_COMMENT, | 1483 | EXTRACTOR_METATYPE_SUBJECT, |
1666 | EXTRACTOR_METATYPE_SUBJECT, | 1484 | -1); |
1667 | -1); | 1485 | gtk_tree_store_insert_with_values (uc->ts, &iter, uc->parent, G_MAXINT, 0, |
1668 | gtk_tree_store_insert_with_values (uc->ts, | 1486 | uc->namespace_name, 1, uc->ns, 2, last_id, |
1669 | &iter, | 1487 | 3, GNUNET_FS_uri_dup (last_uri), 4, |
1670 | uc->parent, | 1488 | GNUNET_CONTAINER_meta_data_duplicate |
1671 | G_MAXINT, | 1489 | (last_meta), 5, "", 6, desc, 7, |
1672 | 0, uc->namespace_name, | 1490 | TRUE /* update editable (always) */ , |
1673 | 1, uc->ns, | 1491 | 8, FALSE |
1674 | 2, last_id, | 1492 | /* current not editable (only for top-level) */ |
1675 | 3, GNUNET_FS_uri_dup (last_uri), | 1493 | , -1); |
1676 | 4, GNUNET_CONTAINER_meta_data_duplicate (last_meta), | ||
1677 | 5, "", | ||
1678 | 6, desc, | ||
1679 | 7, TRUE /* update editable (always) */, | ||
1680 | 8, FALSE /* current not editable (only for top-level) */, | ||
1681 | -1); | ||
1682 | GNUNET_free_non_null (desc); | 1494 | GNUNET_free_non_null (desc); |
1683 | sc.parent = &iter; | 1495 | sc.parent = &iter; |
1684 | sc.ts = uc->ts; | 1496 | sc.ts = uc->ts; |
@@ -1686,30 +1498,20 @@ add_updateable_to_ts (void *cls, | |||
1686 | sc.ns = uc->ns; | 1498 | sc.ns = uc->ns; |
1687 | sc.seen = uc->seen; | 1499 | sc.seen = uc->seen; |
1688 | sc.update_called = GNUNET_NO; | 1500 | sc.update_called = GNUNET_NO; |
1689 | GNUNET_FS_namespace_list_updateable (uc->ns, | 1501 | GNUNET_FS_namespace_list_updateable (uc->ns, next_id, &add_updateable_to_ts, |
1690 | next_id, | 1502 | &sc); |
1691 | &add_updateable_to_ts, | 1503 | if ((sc.update_called == GNUNET_NO) && (next_id != NULL) && |
1692 | &sc); | 1504 | (strlen (next_id) > 0)) |
1693 | if ( (sc.update_called == GNUNET_NO) && | 1505 | { |
1694 | (next_id != NULL) && | 1506 | /* add leaf */ |
1695 | (strlen (next_id) > 0) ) | 1507 | gtk_tree_store_insert_with_values (uc->ts, &titer, &iter, G_MAXINT, 0, |
1696 | { | 1508 | uc->namespace_name, 1, uc->ns, 2, |
1697 | /* add leaf */ | 1509 | next_id, 3, NULL, 4, NULL, 5, "", 6, "", |
1698 | gtk_tree_store_insert_with_values (uc->ts, | 1510 | 7, TRUE /* update editable (always) */ , |
1699 | &titer, | 1511 | 8, FALSE |
1700 | &iter, | 1512 | /* current not editable (only for top-level) */ |
1701 | G_MAXINT, | 1513 | , -1); |
1702 | 0, uc->namespace_name, | 1514 | } |
1703 | 1, uc->ns, | ||
1704 | 2, next_id, | ||
1705 | 3, NULL, | ||
1706 | 4, NULL, | ||
1707 | 5, "", | ||
1708 | 6, "", | ||
1709 | 7, TRUE /* update editable (always) */, | ||
1710 | 8, FALSE /* current not editable (only for top-level) */, | ||
1711 | -1); | ||
1712 | } | ||
1713 | } | 1515 | } |
1714 | 1516 | ||
1715 | 1517 | ||
@@ -1722,9 +1524,7 @@ add_updateable_to_ts (void *cls, | |||
1722 | * @param id identity of the namespace to add | 1524 | * @param id identity of the namespace to add |
1723 | */ | 1525 | */ |
1724 | static void | 1526 | static void |
1725 | add_namespace_to_ts (void *cls, | 1527 | add_namespace_to_ts (void *cls, const char *name, const GNUNET_HashCode * id) |
1726 | const char *name, | ||
1727 | const GNUNET_HashCode *id) | ||
1728 | { | 1528 | { |
1729 | GtkTreeStore *ts = cls; | 1529 | GtkTreeStore *ts = cls; |
1730 | struct UpdateableContext uc; | 1530 | struct UpdateableContext uc; |
@@ -1733,99 +1533,76 @@ add_namespace_to_ts (void *cls, | |||
1733 | uc.parent = &iter; | 1533 | uc.parent = &iter; |
1734 | uc.namespace_name = name; | 1534 | uc.namespace_name = name; |
1735 | uc.ts = ts; | 1535 | uc.ts = ts; |
1736 | uc.ns = GNUNET_FS_namespace_create (GNUNET_FS_GTK_get_fs_handle (), | 1536 | uc.ns = GNUNET_FS_namespace_create (GNUNET_FS_GTK_get_fs_handle (), name); |
1737 | name); | ||
1738 | uc.update_called = GNUNET_NO; | 1537 | uc.update_called = GNUNET_NO; |
1739 | gtk_tree_store_insert_with_values (ts, &iter, | 1538 | gtk_tree_store_insert_with_values (ts, &iter, NULL, G_MAXINT, 0, name, 1, |
1740 | NULL, | 1539 | uc.ns, 2, NULL /* last-id */ , |
1741 | G_MAXINT, | 1540 | 3, NULL /* last-uri */ , |
1742 | 0, name, | 1541 | 4, NULL /* meta */ , |
1743 | 1, uc.ns, | 1542 | 5, NULL /* next-ID */ , |
1744 | 2, NULL /* last-id */, | 1543 | 6, NULL /* last-description */ , |
1745 | 3, NULL /* last-uri */, | 1544 | 7, TRUE /* update editable */ , |
1746 | 4, NULL /* meta */, | 1545 | 8, TRUE /* current editable */ , |
1747 | 5, NULL /* next-ID */, | 1546 | -1); |
1748 | 6, NULL /* last-description */, | ||
1749 | 7, TRUE /* update editable */, | ||
1750 | 8, TRUE /* current editable */, | ||
1751 | -1); | ||
1752 | uc.seen = GNUNET_CONTAINER_multihashmap_create (128); | 1547 | uc.seen = GNUNET_CONTAINER_multihashmap_create (128); |
1753 | GNUNET_FS_namespace_list_updateable (uc.ns, NULL, | 1548 | GNUNET_FS_namespace_list_updateable (uc.ns, NULL, &add_updateable_to_ts, &uc); |
1754 | &add_updateable_to_ts, &uc); | ||
1755 | GNUNET_CONTAINER_multihashmap_destroy (uc.seen); | 1549 | GNUNET_CONTAINER_multihashmap_destroy (uc.seen); |
1756 | } | 1550 | } |
1757 | 1551 | ||
1758 | 1552 | ||
1759 | static void | 1553 | static void |
1760 | free_pseudonym_tree_store (GtkTreeModel *tm, | 1554 | free_pseudonym_tree_store (GtkTreeModel * tm, GtkTreeIter * iter) |
1761 | GtkTreeIter *iter) | ||
1762 | { | 1555 | { |
1763 | struct GNUNET_FS_Uri *uri; | 1556 | struct GNUNET_FS_Uri *uri; |
1764 | struct GNUNET_CONTAINER_MetaData *meta; | 1557 | struct GNUNET_CONTAINER_MetaData *meta; |
1765 | struct GNUNET_FS_Namespace *ns; | 1558 | struct GNUNET_FS_Namespace *ns; |
1766 | GtkTreeIter child; | 1559 | GtkTreeIter child; |
1767 | 1560 | ||
1768 | gtk_tree_model_get (tm, | 1561 | gtk_tree_model_get (tm, iter, 1, &ns, 3, &uri, 4, &meta, -1); |
1769 | iter, | ||
1770 | 1, &ns, | ||
1771 | 3, &uri, | ||
1772 | 4, &meta, | ||
1773 | -1); | ||
1774 | if (uri != NULL) | 1562 | if (uri != NULL) |
1775 | GNUNET_FS_uri_destroy (uri); | 1563 | GNUNET_FS_uri_destroy (uri); |
1776 | if (meta != NULL) | 1564 | if (meta != NULL) |
1777 | GNUNET_CONTAINER_meta_data_destroy (meta); | 1565 | GNUNET_CONTAINER_meta_data_destroy (meta); |
1778 | if (ns != NULL) | 1566 | if (ns != NULL) |
1567 | { | ||
1568 | // FIXME: delete ns? | ||
1569 | // GNUNET_FS_namespace_delete (nso, GNUNET_NO); | ||
1570 | } | ||
1571 | if (TRUE == gtk_tree_model_iter_children (tm, &child, iter)) | ||
1572 | { | ||
1573 | do | ||
1779 | { | 1574 | { |
1780 | // FIXME: delete ns? | 1575 | free_pseudonym_tree_store (tm, &child); |
1781 | // GNUNET_FS_namespace_delete (nso, GNUNET_NO); | ||
1782 | } | ||
1783 | if (TRUE == | ||
1784 | gtk_tree_model_iter_children (tm, &child, iter)) | ||
1785 | { | ||
1786 | do | ||
1787 | { | ||
1788 | free_pseudonym_tree_store (tm, | ||
1789 | &child); | ||
1790 | } | ||
1791 | while (TRUE == gtk_tree_model_iter_next (tm, | ||
1792 | &child)); | ||
1793 | } | 1576 | } |
1577 | while (TRUE == gtk_tree_model_iter_next (tm, &child)); | ||
1578 | } | ||
1794 | } | 1579 | } |
1795 | 1580 | ||
1796 | 1581 | ||
1797 | static void | 1582 | static void |
1798 | free_file_information_tree_store (GtkTreeModel *tm, | 1583 | free_file_information_tree_store (GtkTreeModel * tm, GtkTreeIter * iter) |
1799 | GtkTreeIter *iter) | ||
1800 | { | 1584 | { |
1801 | GtkTreeIter child; | 1585 | GtkTreeIter child; |
1802 | struct GNUNET_FS_FileInformation *fip; | 1586 | struct GNUNET_FS_FileInformation *fip; |
1803 | 1587 | ||
1804 | gtk_tree_model_get (tm, | 1588 | gtk_tree_model_get (tm, iter, 5, &fip, -1); |
1805 | iter, | ||
1806 | 5, &fip, | ||
1807 | -1); | ||
1808 | if (fip != NULL) | 1589 | if (fip != NULL) |
1809 | GNUNET_FS_file_information_destroy (fip, NULL, NULL); | 1590 | GNUNET_FS_file_information_destroy (fip, NULL, NULL); |
1810 | if (TRUE == | 1591 | if (TRUE == gtk_tree_model_iter_children (tm, &child, iter)) |
1811 | gtk_tree_model_iter_children (tm, &child, iter)) | 1592 | { |
1593 | do | ||
1812 | { | 1594 | { |
1813 | do | 1595 | free_file_information_tree_store (tm, &child); |
1814 | { | ||
1815 | free_file_information_tree_store (tm, | ||
1816 | &child); | ||
1817 | } | ||
1818 | while (TRUE == gtk_tree_model_iter_next (tm, | ||
1819 | &child)); | ||
1820 | } | 1596 | } |
1597 | while (TRUE == gtk_tree_model_iter_next (tm, &child)); | ||
1598 | } | ||
1821 | } | 1599 | } |
1822 | 1600 | ||
1823 | 1601 | ||
1824 | /** | 1602 | /** |
1825 | */ | 1603 | */ |
1826 | void | 1604 | void |
1827 | GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy, | 1605 | GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy, gpointer data) |
1828 | gpointer data) | ||
1829 | { | 1606 | { |
1830 | GtkWidget *ad; | 1607 | GtkWidget *ad; |
1831 | GtkTreeStore *ts; | 1608 | GtkTreeStore *ts; |
@@ -1839,90 +1616,79 @@ GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy, | |||
1839 | struct GNUNET_FS_Namespace *namespace; | 1616 | struct GNUNET_FS_Namespace *namespace; |
1840 | gchar *namespace_id; | 1617 | gchar *namespace_id; |
1841 | gchar *namespace_uid; | 1618 | gchar *namespace_uid; |
1842 | 1619 | ||
1843 | GNUNET_assert (master_builder == NULL); | 1620 | GNUNET_assert (master_builder == NULL); |
1844 | master_builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_dialog.glade"); | 1621 | master_builder = |
1622 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_dialog.glade"); | ||
1845 | if (master_builder == NULL) | 1623 | if (master_builder == NULL) |
1846 | return; | 1624 | return; |
1847 | tv = GTK_TREE_VIEW (gtk_builder_get_object (master_builder, | 1625 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1848 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 1626 | (master_builder, |
1627 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | ||
1849 | sel = gtk_tree_view_get_selection (tv); | 1628 | sel = gtk_tree_view_get_selection (tv); |
1850 | g_signal_connect(G_OBJECT(sel), "changed", | 1629 | g_signal_connect (G_OBJECT (sel), "changed", |
1851 | G_CALLBACK(selection_changed_cb), NULL); | 1630 | G_CALLBACK (selection_changed_cb), NULL); |
1852 | ad = GTK_WIDGET (gtk_builder_get_object (master_builder, | 1631 | ad = GTK_WIDGET (gtk_builder_get_object |
1853 | "GNUNET_GTK_master_publish_dialog")); | 1632 | (master_builder, "GNUNET_GTK_master_publish_dialog")); |
1854 | ts = GTK_TREE_STORE (gtk_builder_get_object (master_builder, | 1633 | ts = GTK_TREE_STORE (gtk_builder_get_object |
1855 | "GNUNET_GTK_pseudonym_tree_store")); | 1634 | (master_builder, "GNUNET_GTK_pseudonym_tree_store")); |
1856 | GNUNET_FS_namespace_list (GNUNET_FS_GTK_get_fs_handle (), | 1635 | GNUNET_FS_namespace_list (GNUNET_FS_GTK_get_fs_handle (), |
1857 | &add_namespace_to_ts, | 1636 | &add_namespace_to_ts, ts); |
1858 | ts); | 1637 | tm = GTK_TREE_MODEL (gtk_builder_get_object |
1859 | tm = GTK_TREE_MODEL (gtk_builder_get_object (master_builder, | 1638 | (master_builder, |
1860 | "GNUNET_GTK_file_sharing_publishing_tree_store")); | 1639 | "GNUNET_GTK_file_sharing_publishing_tree_store")); |
1861 | tv = GTK_TREE_VIEW (gtk_builder_get_object (master_builder, | 1640 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1862 | "GNUNET_GTK_master_publish_dialog_pseudonym_tree_view")); | 1641 | (master_builder, |
1642 | "GNUNET_GTK_master_publish_dialog_pseudonym_tree_view")); | ||
1863 | sel = gtk_tree_view_get_selection (tv); | 1643 | sel = gtk_tree_view_get_selection (tv); |
1864 | g_signal_connect(G_OBJECT(sel), "changed", | 1644 | g_signal_connect (G_OBJECT (sel), "changed", |
1865 | G_CALLBACK(selection_changed_cb), NULL); | 1645 | G_CALLBACK (selection_changed_cb), NULL); |
1866 | ret = gtk_dialog_run (GTK_DIALOG (ad)); | 1646 | ret = gtk_dialog_run (GTK_DIALOG (ad)); |
1867 | if (ret == GTK_RESPONSE_OK) | 1647 | if (ret == GTK_RESPONSE_OK) |
1648 | { | ||
1649 | if (TRUE == gtk_tree_selection_get_selected (sel, &ptm, &iter)) | ||
1868 | { | 1650 | { |
1869 | if (TRUE == gtk_tree_selection_get_selected (sel, &ptm, &iter)) | 1651 | gtk_tree_model_get (ptm, &iter, 1, &namespace, 2, &namespace_id, 5, |
1870 | { | 1652 | &namespace_uid, -1); |
1871 | gtk_tree_model_get (ptm, | 1653 | } |
1872 | &iter, | 1654 | else |
1873 | 1, &namespace, | 1655 | { |
1874 | 2, &namespace_id, | 1656 | namespace = NULL; |
1875 | 5, &namespace_uid, | 1657 | namespace_id = NULL; |
1876 | -1); | 1658 | namespace_uid = NULL; |
1877 | } | 1659 | } |
1878 | else | 1660 | if (gtk_tree_model_get_iter_first (tm, &iter)) |
1879 | { | 1661 | do |
1880 | namespace = NULL; | ||
1881 | namespace_id = NULL; | ||
1882 | namespace_uid = NULL; | ||
1883 | } | ||
1884 | if (gtk_tree_model_get_iter_first (tm, &iter)) | ||
1885 | do | ||
1886 | { | ||
1887 | fi = get_file_information (tm, &iter); | ||
1888 | GNUNET_FS_publish_start (GNUNET_FS_GTK_get_fs_handle (), | ||
1889 | fi, | ||
1890 | namespace, | ||
1891 | namespace_id, | ||
1892 | namespace_uid, | ||
1893 | GNUNET_FS_PUBLISH_OPTION_NONE); | ||
1894 | } | ||
1895 | while (gtk_tree_model_iter_next (tm, &iter)); | ||
1896 | if (namespace_id != NULL) | ||
1897 | g_free (namespace_id); | ||
1898 | if (namespace_uid != NULL) | ||
1899 | g_free (namespace_uid); | ||
1900 | } | ||
1901 | ptm = GTK_TREE_MODEL (gtk_builder_get_object (master_builder, | ||
1902 | "GNUNET_GTK_pseudonym_tree_store")); | ||
1903 | /* free state from 'ptm' */ | ||
1904 | if (TRUE == | ||
1905 | gtk_tree_model_get_iter_first (ptm, | ||
1906 | &iter)) | ||
1907 | do | ||
1908 | { | 1662 | { |
1909 | free_pseudonym_tree_store (ptm, | 1663 | fi = get_file_information (tm, &iter); |
1910 | &iter); | 1664 | GNUNET_FS_publish_start (GNUNET_FS_GTK_get_fs_handle (), fi, namespace, |
1665 | namespace_id, namespace_uid, | ||
1666 | GNUNET_FS_PUBLISH_OPTION_NONE); | ||
1911 | } | 1667 | } |
1912 | while (TRUE == gtk_tree_model_iter_next (ptm, | 1668 | while (gtk_tree_model_iter_next (tm, &iter)); |
1913 | &iter)); | 1669 | if (namespace_id != NULL) |
1914 | 1670 | g_free (namespace_id); | |
1671 | if (namespace_uid != NULL) | ||
1672 | g_free (namespace_uid); | ||
1673 | } | ||
1674 | ptm = | ||
1675 | GTK_TREE_MODEL (gtk_builder_get_object | ||
1676 | (master_builder, "GNUNET_GTK_pseudonym_tree_store")); | ||
1677 | /* free state from 'ptm' */ | ||
1678 | if (TRUE == gtk_tree_model_get_iter_first (ptm, &iter)) | ||
1679 | do | ||
1680 | { | ||
1681 | free_pseudonym_tree_store (ptm, &iter); | ||
1682 | } | ||
1683 | while (TRUE == gtk_tree_model_iter_next (ptm, &iter)); | ||
1684 | |||
1915 | /* free state from 'tm' */ | 1685 | /* free state from 'tm' */ |
1916 | if (TRUE == | 1686 | if (TRUE == gtk_tree_model_get_iter_first (tm, &iter)) |
1917 | gtk_tree_model_get_iter_first (tm, | 1687 | do |
1918 | &iter)) | 1688 | { |
1919 | do | 1689 | free_file_information_tree_store (tm, &iter); |
1920 | { | 1690 | } |
1921 | free_file_information_tree_store (tm, | 1691 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); |
1922 | &iter); | ||
1923 | } | ||
1924 | while (TRUE == gtk_tree_model_iter_next (tm, | ||
1925 | &iter)); | ||
1926 | 1692 | ||
1927 | gtk_widget_destroy (ad); | 1693 | gtk_widget_destroy (ad); |
1928 | g_object_unref (G_OBJECT (master_builder)); | 1694 | g_object_unref (G_OBJECT (master_builder)); |
diff --git a/src/fs/gnunet-fs-gtk-main_window_file_search.c b/src/fs/gnunet-fs-gtk-main_window_file_search.c index 2fec7fcc..9d776eec 100644 --- a/src/fs/gnunet-fs-gtk-main_window_file_search.c +++ b/src/fs/gnunet-fs-gtk-main_window_file_search.c | |||
@@ -35,11 +35,15 @@ static GtkBuilder *builder; | |||
35 | * User double-clicked on namespace or pressed enter; | 35 | * User double-clicked on namespace or pressed enter; |
36 | * move namespace root to the 'keywords' line. | 36 | * move namespace root to the 'keywords' line. |
37 | */ | 37 | */ |
38 | void | 38 | void |
39 | GNUNET_GTK_search_dialog_namespace_tree_view_row_activated_cb (GtkTreeView *tree_view, | 39 | GNUNET_GTK_search_dialog_namespace_tree_view_row_activated_cb (GtkTreeView * |
40 | GtkTreePath *path, | 40 | tree_view, |
41 | GtkTreeViewColumn *column, | 41 | GtkTreePath * |
42 | gpointer user_data) | 42 | path, |
43 | GtkTreeViewColumn | ||
44 | * column, | ||
45 | gpointer | ||
46 | user_data) | ||
43 | { | 47 | { |
44 | GtkTreeModel *ls; | 48 | GtkTreeModel *ls; |
45 | GtkTreeSelection *sel; | 49 | GtkTreeSelection *sel; |
@@ -47,27 +51,22 @@ GNUNET_GTK_search_dialog_namespace_tree_view_row_activated_cb (GtkTreeView | |||
47 | GtkTreeIter iter; | 51 | GtkTreeIter iter; |
48 | char *root; | 52 | char *root; |
49 | 53 | ||
50 | query = GTK_ENTRY (gtk_builder_get_object (builder, | 54 | query = |
51 | "GNUNET_GTK_search_dialog_keyword_entry")); | 55 | GTK_ENTRY (gtk_builder_get_object |
52 | sel = gtk_tree_view_get_selection (tree_view); | 56 | (builder, "GNUNET_GTK_search_dialog_keyword_entry")); |
53 | if (TRUE == | 57 | sel = gtk_tree_view_get_selection (tree_view); |
54 | gtk_tree_selection_get_selected (sel, | 58 | if (TRUE == gtk_tree_selection_get_selected (sel, &ls, &iter)) |
55 | &ls, | 59 | { |
56 | &iter)) | 60 | gtk_tree_model_get (ls, &iter, 1, &root, -1); |
57 | { | 61 | gtk_entry_set_text (query, root); |
58 | gtk_tree_model_get (ls, &iter, | 62 | GNUNET_free (root); |
59 | 1, &root, | 63 | } |
60 | -1); | ||
61 | gtk_entry_set_text (query, | ||
62 | root); | ||
63 | GNUNET_free (root); | ||
64 | } | ||
65 | } | 64 | } |
66 | 65 | ||
67 | 66 | ||
68 | void | 67 | void |
69 | GNUNET_GTK_search_dialog_search_button_clicked_cb (GtkWidget * dummy, | 68 | GNUNET_GTK_search_dialog_search_button_clicked_cb (GtkWidget * dummy, |
70 | gpointer data) | 69 | gpointer data) |
71 | { | 70 | { |
72 | GtkEntry *query; | 71 | GtkEntry *query; |
73 | GtkSpinButton *anonymity; | 72 | GtkSpinButton *anonymity; |
@@ -80,47 +79,41 @@ GNUNET_GTK_search_dialog_search_button_clicked_cb (GtkWidget * dummy, | |||
80 | GtkTreeSelection *sel; | 79 | GtkTreeSelection *sel; |
81 | GtkTreeIter iter; | 80 | GtkTreeIter iter; |
82 | 81 | ||
83 | query = GTK_ENTRY (gtk_builder_get_object (builder, | 82 | query = |
84 | "GNUNET_GTK_search_dialog_keyword_entry")); | 83 | GTK_ENTRY (gtk_builder_get_object |
85 | anonymity = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | 84 | (builder, "GNUNET_GTK_search_dialog_keyword_entry")); |
86 | "GNUNET_GTK_search_dialog_anonymity_spin_button")); | 85 | anonymity = |
87 | namespace = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 86 | GTK_SPIN_BUTTON (gtk_builder_get_object |
88 | "GNUNET_GTK_search_dialog_namespace_tree_view")); | 87 | (builder, |
88 | "GNUNET_GTK_search_dialog_anonymity_spin_button")); | ||
89 | namespace = | ||
90 | GTK_TREE_VIEW (gtk_builder_get_object | ||
91 | (builder, "GNUNET_GTK_search_dialog_namespace_tree_view")); | ||
89 | keywords = gtk_entry_get_text (query); | 92 | keywords = gtk_entry_get_text (query); |
90 | nsid = NULL; | 93 | nsid = NULL; |
91 | sel = gtk_tree_view_get_selection (namespace); | 94 | sel = gtk_tree_view_get_selection (namespace); |
92 | if (TRUE == | 95 | if (TRUE == gtk_tree_selection_get_selected (sel, &ls, &iter)) |
93 | gtk_tree_selection_get_selected (sel, | 96 | gtk_tree_model_get (ls, &iter, 2, &nsid, -1); |
94 | &ls, | ||
95 | &iter)) | ||
96 | gtk_tree_model_get (ls, &iter, | ||
97 | 2, &nsid, | ||
98 | -1); | ||
99 | if (nsid != NULL) | 97 | if (nsid != NULL) |
98 | { | ||
99 | uri = GNUNET_FS_uri_sks_create_from_nsid (nsid, keywords); | ||
100 | GNUNET_assert (uri != NULL); | ||
101 | } | ||
102 | else | ||
103 | { | ||
104 | emsg = NULL; | ||
105 | uri = GNUNET_FS_uri_ksk_create (keywords, &emsg); | ||
106 | if (uri == NULL) | ||
100 | { | 107 | { |
101 | uri = GNUNET_FS_uri_sks_create_from_nsid (nsid, | 108 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Invalid keyword string `%s': %s"), |
102 | keywords); | 109 | keywords, emsg); |
103 | GNUNET_assert (uri != NULL); | 110 | GNUNET_free_non_null (emsg); |
104 | } | 111 | return; |
105 | else | ||
106 | { | ||
107 | emsg = NULL; | ||
108 | uri = GNUNET_FS_uri_ksk_create (keywords, &emsg); | ||
109 | if (uri == NULL) | ||
110 | { | ||
111 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
112 | _("Invalid keyword string `%s': %s"), | ||
113 | keywords, | ||
114 | emsg); | ||
115 | GNUNET_free_non_null (emsg); | ||
116 | return; | ||
117 | } | ||
118 | } | 112 | } |
119 | GNUNET_FS_search_start (GNUNET_FS_GTK_get_fs_handle (), | 113 | } |
120 | uri, | 114 | GNUNET_FS_search_start (GNUNET_FS_GTK_get_fs_handle (), uri, |
121 | gtk_spin_button_get_value_as_int (anonymity), | 115 | gtk_spin_button_get_value_as_int (anonymity), |
122 | GNUNET_FS_SEARCH_OPTION_NONE, | 116 | GNUNET_FS_SEARCH_OPTION_NONE, NULL); |
123 | NULL); | ||
124 | GNUNET_FS_uri_destroy (uri); | 117 | GNUNET_FS_uri_destroy (uri); |
125 | } | 118 | } |
126 | 119 | ||
@@ -136,12 +129,8 @@ GNUNET_GTK_search_dialog_search_button_clicked_cb (GtkWidget * dummy, | |||
136 | * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort | 129 | * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort |
137 | */ | 130 | */ |
138 | static int | 131 | static int |
139 | add_namespace_to_ls (void *cls, | 132 | add_namespace_to_ls (void *cls, const GNUNET_HashCode * pseudonym, |
140 | const GNUNET_HashCode * | 133 | const struct GNUNET_CONTAINER_MetaData *md, int rating) |
141 | pseudonym, | ||
142 | const struct | ||
143 | GNUNET_CONTAINER_MetaData * md, | ||
144 | int rating) | ||
145 | { | 134 | { |
146 | GtkListStore *ls = cls; | 135 | GtkListStore *ls = cls; |
147 | char *root; | 136 | char *root; |
@@ -152,41 +141,36 @@ add_namespace_to_ls (void *cls, | |||
152 | char *emsg; | 141 | char *emsg; |
153 | struct GNUNET_FS_Uri *uri; | 142 | struct GNUNET_FS_Uri *uri; |
154 | GtkTreeIter iter; | 143 | GtkTreeIter iter; |
155 | 144 | ||
156 | ns_name = GNUNET_PSEUDONYM_id_to_name (GNUNET_FS_GTK_get_configuration (), | 145 | ns_name = |
157 | pseudonym); | 146 | GNUNET_PSEUDONYM_id_to_name (GNUNET_FS_GTK_get_configuration (), |
147 | pseudonym); | ||
158 | nsid = GNUNET_malloc (sizeof (GNUNET_HashCode)); | 148 | nsid = GNUNET_malloc (sizeof (GNUNET_HashCode)); |
159 | *nsid = *pseudonym; | 149 | *nsid = *pseudonym; |
160 | root = NULL; | 150 | root = NULL; |
161 | uris = GNUNET_CONTAINER_meta_data_get_by_type (md, | 151 | uris = GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_URI); |
162 | EXTRACTOR_METATYPE_URI); | ||
163 | if (uris != NULL) | 152 | if (uris != NULL) |
164 | { | 153 | { |
165 | emsg = NULL; | 154 | emsg = NULL; |
166 | uri = GNUNET_FS_uri_parse (uris, &emsg); | 155 | uri = GNUNET_FS_uri_parse (uris, &emsg); |
167 | if (uri == NULL) | 156 | if (uri == NULL) |
168 | GNUNET_free (emsg); | 157 | GNUNET_free (emsg); |
169 | root = GNUNET_FS_uri_sks_get_content_id (uri); | 158 | root = GNUNET_FS_uri_sks_get_content_id (uri); |
170 | GNUNET_FS_uri_destroy (uri); | 159 | GNUNET_FS_uri_destroy (uri); |
171 | } | 160 | } |
172 | description = GNUNET_CONTAINER_meta_data_get_first_by_types (md, | 161 | description = |
173 | EXTRACTOR_METATYPE_TITLE, | 162 | GNUNET_CONTAINER_meta_data_get_first_by_types (md, |
174 | EXTRACTOR_METATYPE_BOOK_TITLE, | 163 | EXTRACTOR_METATYPE_TITLE, |
175 | EXTRACTOR_METATYPE_DESCRIPTION, | 164 | EXTRACTOR_METATYPE_BOOK_TITLE, |
176 | EXTRACTOR_METATYPE_SUMMARY, | 165 | EXTRACTOR_METATYPE_DESCRIPTION, |
177 | EXTRACTOR_METATYPE_ALBUM, | 166 | EXTRACTOR_METATYPE_SUMMARY, |
178 | EXTRACTOR_METATYPE_COMMENT, | 167 | EXTRACTOR_METATYPE_ALBUM, |
179 | EXTRACTOR_METATYPE_SUBJECT, | 168 | EXTRACTOR_METATYPE_COMMENT, |
180 | EXTRACTOR_METATYPE_KEYWORDS, | 169 | EXTRACTOR_METATYPE_SUBJECT, |
181 | -1); | 170 | EXTRACTOR_METATYPE_KEYWORDS, |
182 | gtk_list_store_insert_with_values (ls, | 171 | -1); |
183 | &iter, | 172 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, 0, ns_name, 1, root, |
184 | G_MAXINT, | 173 | 2, nsid, 3, description, -1); |
185 | 0, ns_name, | ||
186 | 1, root, | ||
187 | 2, nsid, | ||
188 | 3, description, | ||
189 | -1); | ||
190 | GNUNET_free (ns_name); | 174 | GNUNET_free (ns_name); |
191 | GNUNET_free_non_null (root); | 175 | GNUNET_free_non_null (root); |
192 | GNUNET_free_non_null (description); | 176 | GNUNET_free_non_null (description); |
@@ -198,43 +182,35 @@ add_namespace_to_ls (void *cls, | |||
198 | * Search selected in 'file' menu. | 182 | * Search selected in 'file' menu. |
199 | */ | 183 | */ |
200 | void | 184 | void |
201 | GNUNET_GTK_main_menu_file_search_activate_cb (GtkWidget * dummy, | 185 | GNUNET_GTK_main_menu_file_search_activate_cb (GtkWidget * dummy, gpointer data) |
202 | gpointer data) | ||
203 | { | 186 | { |
204 | GtkWidget *ad; | 187 | GtkWidget *ad; |
205 | GtkListStore *ls; | 188 | GtkListStore *ls; |
206 | GtkTreeIter iter; | 189 | GtkTreeIter iter; |
207 | GNUNET_HashCode *nsid; | 190 | GNUNET_HashCode *nsid; |
208 | 191 | ||
209 | GNUNET_assert (builder == NULL); | 192 | GNUNET_assert (builder == NULL); |
210 | builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_search_dialog.glade"); | 193 | builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_search_dialog.glade"); |
211 | if (builder == NULL) | 194 | if (builder == NULL) |
212 | return; | 195 | return; |
213 | ad = GTK_WIDGET (gtk_builder_get_object (builder, | 196 | ad = GTK_WIDGET (gtk_builder_get_object |
214 | "GNUNET_GTK_search_dialog")); | 197 | (builder, "GNUNET_GTK_search_dialog")); |
215 | ls = GTK_LIST_STORE (gtk_builder_get_object (builder, | 198 | ls = GTK_LIST_STORE (gtk_builder_get_object |
216 | "GNUNET_GTK_namespace_list_store")); | 199 | (builder, "GNUNET_GTK_namespace_list_store")); |
217 | GNUNET_PSEUDONYM_list_all (GNUNET_FS_GTK_get_configuration (), | 200 | GNUNET_PSEUDONYM_list_all (GNUNET_FS_GTK_get_configuration (), |
218 | &add_namespace_to_ls, | 201 | &add_namespace_to_ls, ls); |
219 | ls); | ||
220 | gtk_dialog_run (GTK_DIALOG (ad)); | 202 | gtk_dialog_run (GTK_DIALOG (ad)); |
221 | 203 | ||
222 | /* free nsids from 'ls' */ | 204 | /* free nsids from 'ls' */ |
223 | if (TRUE == | 205 | if (TRUE == gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ls), &iter)) |
224 | gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ls), | 206 | { |
225 | &iter)) | 207 | do |
226 | { | 208 | { |
227 | do | 209 | gtk_tree_model_get (GTK_TREE_MODEL (ls), &iter, 2, &nsid, -1); |
228 | { | 210 | GNUNET_free (nsid); |
229 | gtk_tree_model_get (GTK_TREE_MODEL (ls), | ||
230 | &iter, | ||
231 | 2, &nsid, | ||
232 | -1); | ||
233 | GNUNET_free (nsid); | ||
234 | } | ||
235 | while (TRUE == gtk_tree_model_iter_next (GTK_TREE_MODEL (ls), | ||
236 | &iter)); | ||
237 | } | 211 | } |
212 | while (TRUE == gtk_tree_model_iter_next (GTK_TREE_MODEL (ls), &iter)); | ||
213 | } | ||
238 | gtk_widget_destroy (ad); | 214 | gtk_widget_destroy (ad); |
239 | g_object_unref (G_OBJECT (builder)); | 215 | g_object_unref (G_OBJECT (builder)); |
240 | builder = NULL; | 216 | builder = NULL; |
diff --git a/src/fs/gnunet-fs-gtk-main_window_open_directory.c b/src/fs/gnunet-fs-gtk-main_window_open_directory.c index aea8814b..ae3b7d0b 100644 --- a/src/fs/gnunet-fs-gtk-main_window_open_directory.c +++ b/src/fs/gnunet-fs-gtk-main_window_open_directory.c | |||
@@ -32,7 +32,7 @@ struct AddChildContext | |||
32 | struct SearchTab *tab; | 32 | struct SearchTab *tab; |
33 | struct SearchResult *par; | 33 | struct SearchResult *par; |
34 | GtkTreeRowReference *prr; | 34 | GtkTreeRowReference *prr; |
35 | GtkTreeIter iter; | 35 | GtkTreeIter iter; |
36 | }; | 36 | }; |
37 | 37 | ||
38 | 38 | ||
@@ -51,13 +51,10 @@ struct AddChildContext | |||
51 | * embedded with the directory itself). | 51 | * embedded with the directory itself). |
52 | * @param data data available for the file (length bytes) | 52 | * @param data data available for the file (length bytes) |
53 | */ | 53 | */ |
54 | static void | 54 | static void |
55 | add_child (void *cls, | 55 | add_child (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri, |
56 | const char *filename, | 56 | const struct GNUNET_CONTAINER_MetaData *meta, size_t length, |
57 | const struct GNUNET_FS_Uri *uri, | 57 | const void *data) |
58 | const struct GNUNET_CONTAINER_MetaData *meta, | ||
59 | size_t length, | ||
60 | const void *data) | ||
61 | { | 58 | { |
62 | struct AddChildContext *acc = cls; | 59 | struct AddChildContext *acc = cls; |
63 | struct GNUNET_CONTAINER_MetaData *dmeta; | 60 | struct GNUNET_CONTAINER_MetaData *dmeta; |
@@ -65,39 +62,27 @@ add_child (void *cls, | |||
65 | GtkTreeIter iter; | 62 | GtkTreeIter iter; |
66 | 63 | ||
67 | if (uri == NULL) | 64 | if (uri == NULL) |
68 | { | 65 | { |
69 | /* directory meta data itself */ | 66 | /* directory meta data itself */ |
70 | dmeta = GNUNET_CONTAINER_meta_data_duplicate (meta); | 67 | dmeta = GNUNET_CONTAINER_meta_data_duplicate (meta); |
71 | GNUNET_CONTAINER_meta_data_insert (dmeta, | 68 | GNUNET_CONTAINER_meta_data_insert (dmeta, "<user>", |
72 | "<user>", | 69 | EXTRACTOR_METATYPE_FILENAME, |
73 | EXTRACTOR_METATYPE_FILENAME, | 70 | EXTRACTOR_METAFORMAT_C_STRING, |
74 | EXTRACTOR_METAFORMAT_C_STRING, | 71 | "text/plain", acc->filename, |
75 | "text/plain", | 72 | strlen (acc->filename) + 1); |
76 | acc->filename, | 73 | acc->tab = GNUNET_GTK_add_to_uri_tab (&acc->iter, &acc->par, dmeta, NULL); |
77 | strlen (acc->filename) + 1); | 74 | tp = gtk_tree_model_get_path (GTK_TREE_MODEL (acc->tab->ts), &acc->iter); |
78 | acc->tab = GNUNET_GTK_add_to_uri_tab (&acc->iter, | 75 | acc->prr = gtk_tree_row_reference_new (GTK_TREE_MODEL (acc->tab->ts), tp); |
79 | &acc->par, | 76 | gtk_tree_path_free (tp); |
80 | dmeta, | 77 | acc->ts = acc->tab->ts; |
81 | NULL); | 78 | GNUNET_CONTAINER_meta_data_destroy (dmeta); |
82 | tp = gtk_tree_model_get_path (GTK_TREE_MODEL (acc->tab->ts), | 79 | return; |
83 | &acc->iter); | 80 | } |
84 | acc->prr = gtk_tree_row_reference_new (GTK_TREE_MODEL (acc->tab->ts), | ||
85 | tp); | ||
86 | gtk_tree_path_free (tp); | ||
87 | acc->ts = acc->tab->ts; | ||
88 | GNUNET_CONTAINER_meta_data_destroy (dmeta); | ||
89 | return; | ||
90 | } | ||
91 | if (acc->ts == NULL) | 81 | if (acc->ts == NULL) |
92 | return; | 82 | return; |
93 | GNUNET_assert (NULL != | 83 | GNUNET_assert (NULL != |
94 | GNUNET_GTK_add_search_result (acc->tab, | 84 | GNUNET_GTK_add_search_result (acc->tab, &iter, acc->prr, uri, |
95 | &iter, | 85 | meta, NULL, 0)); |
96 | acc->prr, | ||
97 | uri, | ||
98 | meta, | ||
99 | NULL, | ||
100 | 0)); | ||
101 | } | 86 | } |
102 | 87 | ||
103 | 88 | ||
@@ -106,8 +91,8 @@ add_child (void *cls, | |||
106 | * file and then display a new tab with its contents. | 91 | * file and then display a new tab with its contents. |
107 | */ | 92 | */ |
108 | void | 93 | void |
109 | GNUNET_GTK_main_menu_file_open_gnunet_directory_activate_cb (GtkWidget * dummy, | 94 | GNUNET_GTK_main_menu_file_open_gnunet_directory_activate_cb (GtkWidget * dummy, |
110 | gpointer data) | 95 | gpointer data) |
111 | { | 96 | { |
112 | struct AddChildContext acc; | 97 | struct AddChildContext acc; |
113 | GtkWidget *ad; | 98 | GtkWidget *ad; |
@@ -115,32 +100,31 @@ GNUNET_GTK_main_menu_file_open_gnunet_directory_activate_cb (GtkWidget * dummy, | |||
115 | char *filename; | 100 | char *filename; |
116 | GtkFileFilter *ff; | 101 | GtkFileFilter *ff; |
117 | 102 | ||
118 | builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_open_directory_dialog.glade"); | 103 | builder = |
104 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_open_directory_dialog.glade"); | ||
119 | if (builder == NULL) | 105 | if (builder == NULL) |
120 | { | 106 | { |
121 | GNUNET_break (0); | 107 | GNUNET_break (0); |
122 | return; | 108 | return; |
123 | } | 109 | } |
124 | ad = GTK_WIDGET (gtk_builder_get_object (builder, | 110 | ad = GTK_WIDGET (gtk_builder_get_object |
125 | "GNUNET_GTK_open_directory_dialog")); | 111 | (builder, "GNUNET_GTK_open_directory_dialog")); |
126 | ff = GTK_FILE_FILTER (gtk_builder_get_object (builder, | 112 | ff = GTK_FILE_FILTER (gtk_builder_get_object |
127 | "gnunet_directory_filter")); | 113 | (builder, "gnunet_directory_filter")); |
128 | /* FIXME: some day, write a custom file filter for gnunet-directories... */ | 114 | /* FIXME: some day, write a custom file filter for gnunet-directories... */ |
129 | gtk_file_filter_add_pattern (ff, "*" GNUNET_FS_DIRECTORY_EXT); | 115 | gtk_file_filter_add_pattern (ff, "*" GNUNET_FS_DIRECTORY_EXT); |
130 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) | 116 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) |
131 | { | 117 | { |
132 | gtk_widget_destroy (ad); | 118 | gtk_widget_destroy (ad); |
133 | g_object_unref (G_OBJECT (builder)); | 119 | g_object_unref (G_OBJECT (builder)); |
134 | return; | 120 | return; |
135 | } | 121 | } |
136 | filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(ad)); | 122 | filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (ad)); |
137 | gtk_widget_destroy (ad); | 123 | gtk_widget_destroy (ad); |
138 | g_object_unref (G_OBJECT (builder)); | 124 | g_object_unref (G_OBJECT (builder)); |
139 | acc.filename = filename; | 125 | acc.filename = filename; |
140 | acc.ts = NULL; | 126 | acc.ts = NULL; |
141 | GNUNET_FS_GTK_mmap_and_scan (filename, | 127 | GNUNET_FS_GTK_mmap_and_scan (filename, &add_child, &acc); |
142 | &add_child, | ||
143 | &acc); | ||
144 | g_free (filename); | 128 | g_free (filename); |
145 | } | 129 | } |
146 | 130 | ||
diff --git a/src/fs/gnunet-fs-gtk-main_window_view_toggles.c b/src/fs/gnunet-fs-gtk-main_window_view_toggles.c index 1ef930d4..cfd15953 100644 --- a/src/fs/gnunet-fs-gtk-main_window_view_toggles.c +++ b/src/fs/gnunet-fs-gtk-main_window_view_toggles.c | |||
@@ -36,12 +36,11 @@ | |||
36 | * @param toggle_menu name of menu entry | 36 | * @param toggle_menu name of menu entry |
37 | */ | 37 | */ |
38 | static void | 38 | static void |
39 | toggle_view (const char *toggled_widget, | 39 | toggle_view (const char *toggled_widget, const char *toggle_menu) |
40 | const char *toggle_menu) | ||
41 | { | 40 | { |
42 | GtkCheckMenuItem *mi; | 41 | GtkCheckMenuItem *mi; |
43 | GtkWidget *widget; | 42 | GtkWidget *widget; |
44 | 43 | ||
45 | widget = GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object (toggled_widget)); | 44 | widget = GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object (toggled_widget)); |
46 | mi = GTK_CHECK_MENU_ITEM (GNUNET_FS_GTK_get_main_window_object (toggle_menu)); | 45 | mi = GTK_CHECK_MENU_ITEM (GNUNET_FS_GTK_get_main_window_object (toggle_menu)); |
47 | if (gtk_check_menu_item_get_active (mi)) | 46 | if (gtk_check_menu_item_get_active (mi)) |
@@ -55,11 +54,10 @@ toggle_view (const char *toggled_widget, | |||
55 | * Preview view is toggled. | 54 | * Preview view is toggled. |
56 | */ | 55 | */ |
57 | void | 56 | void |
58 | GNUNET_GTK_main_menu_view_preview_toggled_cb (GtkWidget * dummy, | 57 | GNUNET_GTK_main_menu_view_preview_toggled_cb (GtkWidget * dummy, gpointer data) |
59 | gpointer data) | ||
60 | { | 58 | { |
61 | toggle_view ("GNUNET_GTK_main_window_preview_image", | 59 | toggle_view ("GNUNET_GTK_main_window_preview_image", |
62 | "GNUNET_GTK_main_menu_view_preview"); | 60 | "GNUNET_GTK_main_menu_view_preview"); |
63 | } | 61 | } |
64 | 62 | ||
65 | 63 | ||
@@ -67,11 +65,11 @@ GNUNET_GTK_main_menu_view_preview_toggled_cb (GtkWidget * dummy, | |||
67 | * Neighbour view is toggled. | 65 | * Neighbour view is toggled. |
68 | */ | 66 | */ |
69 | void | 67 | void |
70 | GNUNET_GTK_main_menu_view_neighbours_toggled_cb (GtkWidget * dummy, | 68 | GNUNET_GTK_main_menu_view_neighbours_toggled_cb (GtkWidget * dummy, |
71 | gpointer data) | 69 | gpointer data) |
72 | { | 70 | { |
73 | toggle_view ("GNUNET_GTK_main_window_peerinfo_treeview", | 71 | toggle_view ("GNUNET_GTK_main_window_peerinfo_treeview", |
74 | "GNUNET_GTK_main_menu_view_neighbours"); | 72 | "GNUNET_GTK_main_menu_view_neighbours"); |
75 | } | 73 | } |
76 | 74 | ||
77 | 75 | ||
@@ -79,11 +77,10 @@ GNUNET_GTK_main_menu_view_neighbours_toggled_cb (GtkWidget * dummy, | |||
79 | * Metadata view is toggled. | 77 | * Metadata view is toggled. |
80 | */ | 78 | */ |
81 | void | 79 | void |
82 | GNUNET_GTK_main_menu_view_metadata_toggled_cb (GtkWidget * dummy, | 80 | GNUNET_GTK_main_menu_view_metadata_toggled_cb (GtkWidget * dummy, gpointer data) |
83 | gpointer data) | ||
84 | { | 81 | { |
85 | toggle_view ("GNUNET_GTK_main_window_metadata_treeview", | 82 | toggle_view ("GNUNET_GTK_main_window_metadata_treeview", |
86 | "GNUNET_GTK_main_menu_view_metadata"); | 83 | "GNUNET_GTK_main_menu_view_metadata"); |
87 | } | 84 | } |
88 | 85 | ||
89 | 86 | ||
diff --git a/src/fs/gnunet-fs-gtk.c b/src/fs/gnunet-fs-gtk.c index 8f05dfae..1e00a87d 100644 --- a/src/fs/gnunet-fs-gtk.c +++ b/src/fs/gnunet-fs-gtk.c | |||
@@ -97,14 +97,13 @@ GNUNET_FS_GTK_get_main_window_object (const char *name) | |||
97 | * FIXME: does this need to be a separate task!? | 97 | * FIXME: does this need to be a separate task!? |
98 | */ | 98 | */ |
99 | static void | 99 | static void |
100 | shutdown_task (void *cls, | 100 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
101 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
102 | { | 101 | { |
103 | if (fs != NULL) | 102 | if (fs != NULL) |
104 | { | 103 | { |
105 | GNUNET_FS_stop (fs); | 104 | GNUNET_FS_stop (fs); |
106 | fs = NULL; | 105 | fs = NULL; |
107 | } | 106 | } |
108 | EXTRACTOR_plugin_remove_all (plugins); | 107 | EXTRACTOR_plugin_remove_all (plugins); |
109 | plugins = NULL; | 108 | plugins = NULL; |
110 | } | 109 | } |
@@ -113,29 +112,26 @@ shutdown_task (void *cls, | |||
113 | /** | 112 | /** |
114 | * Callback invoked if the application is supposed to exit. | 113 | * Callback invoked if the application is supposed to exit. |
115 | */ | 114 | */ |
116 | void | 115 | void |
117 | GNUNET_GTK_quit_cb (GtkObject *object, | 116 | GNUNET_GTK_quit_cb (GtkObject * object, gpointer user_data) |
118 | gpointer user_data) | ||
119 | { | 117 | { |
120 | GNUNET_GTK_tray_icon_destroy (); | 118 | GNUNET_GTK_tray_icon_destroy (); |
121 | GNUNET_GTK_main_loop_quit (ml); | 119 | GNUNET_GTK_main_loop_quit (ml); |
122 | GNUNET_SCHEDULER_add_now (&shutdown_task, | 120 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
123 | NULL); | ||
124 | } | 121 | } |
125 | 122 | ||
126 | 123 | ||
127 | /** | 124 | /** |
128 | * Search selected in 'file' menu. (from main_window_file_search.c) | 125 | * Search selected in 'file' menu. (from main_window_file_search.c) |
129 | */ | 126 | */ |
130 | void | 127 | void GNUNET_GTK_main_menu_file_search_activate_cb (GtkWidget * dummy, |
131 | GNUNET_GTK_main_menu_file_search_activate_cb (GtkWidget * dummy, | 128 | gpointer data); |
132 | gpointer data); | ||
133 | 129 | ||
134 | 130 | ||
135 | /** | 131 | /** |
136 | * Add the tab with the 'new' icon for starting a search. | 132 | * Add the tab with the 'new' icon for starting a search. |
137 | */ | 133 | */ |
138 | static void | 134 | static void |
139 | add_new_tab () | 135 | add_new_tab () |
140 | { | 136 | { |
141 | GtkNotebook *notebook; | 137 | GtkNotebook *notebook; |
@@ -145,28 +141,28 @@ add_new_tab () | |||
145 | GtkWidget *label; | 141 | GtkWidget *label; |
146 | GtkWidget *frame; | 142 | GtkWidget *frame; |
147 | 143 | ||
148 | builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_main_tab_new_frame.glade"); | 144 | builder = |
145 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_main_tab_new_frame.glade"); | ||
149 | 146 | ||
150 | /* load frame */ | 147 | /* load frame */ |
151 | sf = GTK_WINDOW (gtk_builder_get_object (builder, | 148 | sf = GTK_WINDOW (gtk_builder_get_object (builder, "_main_tab_new_frame")); |
152 | "_main_tab_new_frame")); | ||
153 | label = gtk_bin_get_child (GTK_BIN (sf)); | 149 | label = gtk_bin_get_child (GTK_BIN (sf)); |
154 | gtk_widget_ref (label); | 150 | gtk_widget_ref (label); |
155 | gtk_container_remove (GTK_CONTAINER (sf), label); | 151 | gtk_container_remove (GTK_CONTAINER (sf), label); |
156 | gtk_widget_destroy (GTK_WIDGET (sf)); | 152 | gtk_widget_destroy (GTK_WIDGET (sf)); |
157 | g_object_unref (builder); | 153 | g_object_unref (builder); |
158 | g_signal_connect(G_OBJECT(label), "clicked", | 154 | g_signal_connect (G_OBJECT (label), "clicked", |
159 | G_CALLBACK(&GNUNET_GTK_main_menu_file_search_activate_cb), NULL); | 155 | G_CALLBACK (&GNUNET_GTK_main_menu_file_search_activate_cb), |
156 | NULL); | ||
160 | 157 | ||
161 | notebook = GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_notebook")); | 158 | notebook = |
159 | GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object | ||
160 | ("GNUNET_GTK_main_window_notebook")); | ||
162 | pages = gtk_notebook_get_n_pages (notebook); | 161 | pages = gtk_notebook_get_n_pages (notebook); |
163 | frame = gtk_label_new (""); | 162 | frame = gtk_label_new (""); |
164 | gtk_widget_show (frame); | 163 | gtk_widget_show (frame); |
165 | gtk_notebook_append_page (notebook, | 164 | gtk_notebook_append_page (notebook, frame, label); |
166 | frame, | 165 | gtk_notebook_set_current_page (notebook, pages); |
167 | label); | ||
168 | gtk_notebook_set_current_page (notebook, | ||
169 | pages); | ||
170 | gtk_widget_show (GTK_WIDGET (notebook)); | 166 | gtk_widget_show (GTK_WIDGET (notebook)); |
171 | } | 167 | } |
172 | 168 | ||
@@ -174,54 +170,67 @@ add_new_tab () | |||
174 | /** | 170 | /** |
175 | * Actual main function run right after GNUnet's scheduler | 171 | * Actual main function run right after GNUnet's scheduler |
176 | * is initialized. Initializes up GTK and Glade. | 172 | * is initialized. Initializes up GTK and Glade. |
177 | */ | 173 | */ |
178 | static void | 174 | static void |
179 | run (void *cls, | 175 | run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
180 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
181 | { | 176 | { |
182 | GtkWidget *main_window; | 177 | GtkWidget *main_window; |
178 | |||
183 | ml = cls; | 179 | ml = cls; |
184 | 180 | ||
185 | GNUNET_GTK_set_icon_search_path (); | 181 | GNUNET_GTK_set_icon_search_path (); |
186 | GNUNET_GTK_setup_nls (); | 182 | GNUNET_GTK_setup_nls (); |
187 | 183 | ||
188 | /* setup main window */ | 184 | /* setup main window */ |
189 | main_window = GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window")); | 185 | main_window = |
186 | GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object | ||
187 | ("GNUNET_GTK_main_window")); | ||
190 | gtk_window_maximize (GTK_WINDOW (main_window)); | 188 | gtk_window_maximize (GTK_WINDOW (main_window)); |
191 | GNUNET_GTK_tray_icon_create (GTK_WINDOW (main_window), | 189 | GNUNET_GTK_tray_icon_create (GTK_WINDOW (main_window), |
192 | "gnunet-gtk" /* FIXME: rename icon? */, | 190 | "gnunet-gtk" /* FIXME: rename icon? */ , |
193 | "gnunet-fs-gtk"); | 191 | "gnunet-fs-gtk"); |
194 | 192 | ||
195 | /* initialize file-sharing */ | 193 | /* initialize file-sharing */ |
196 | plugins = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY); | 194 | plugins = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY); |
197 | fs = GNUNET_FS_start (GNUNET_GTK_main_loop_get_configuration (ml), | 195 | fs = GNUNET_FS_start (GNUNET_GTK_main_loop_get_configuration (ml), |
198 | "gnunet-gtk", | 196 | "gnunet-gtk", &GNUNET_GTK_fs_event_handler, NULL, |
199 | &GNUNET_GTK_fs_event_handler, | 197 | GNUNET_FS_FLAGS_NONE |
200 | NULL, | 198 | /* fixme later for persistence/probes */ , |
201 | GNUNET_FS_FLAGS_NONE /* fixme later for persistence/probes */, | 199 | /* set other options here later! */ |
202 | /* set other options here later! */ | 200 | GNUNET_FS_OPTIONS_END); |
203 | GNUNET_FS_OPTIONS_END); | 201 | if (fs != NULL) |
204 | if (fs != NULL) | 202 | { |
205 | { | 203 | add_new_tab (); |
206 | add_new_tab (); | 204 | } |
207 | } | ||
208 | else | 205 | else |
209 | { | 206 | { |
210 | gtk_widget_hide (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_menu_file_create_pseudonym"))); | 207 | gtk_widget_hide (GTK_WIDGET |
211 | gtk_widget_hide (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_menu_file_advertise_pseudonym"))); | 208 | (GNUNET_FS_GTK_get_main_window_object |
212 | gtk_widget_hide (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_menu_file_publish"))); | 209 | ("GNUNET_GTK_main_menu_file_create_pseudonym"))); |
213 | gtk_widget_hide (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_menu_file_search"))); | 210 | gtk_widget_hide (GTK_WIDGET |
214 | gtk_widget_hide (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_menu_file_download_uri"))); | 211 | (GNUNET_FS_GTK_get_main_window_object |
215 | gtk_widget_hide (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_menu_file_open_gnunet_directory"))); | 212 | ("GNUNET_GTK_main_menu_file_advertise_pseudonym"))); |
216 | /* FIXME: set warning in status bar... */ | 213 | gtk_widget_hide (GTK_WIDGET |
217 | } | 214 | (GNUNET_FS_GTK_get_main_window_object |
215 | ("GNUNET_GTK_main_menu_file_publish"))); | ||
216 | gtk_widget_hide (GTK_WIDGET | ||
217 | (GNUNET_FS_GTK_get_main_window_object | ||
218 | ("GNUNET_GTK_main_menu_file_search"))); | ||
219 | gtk_widget_hide (GTK_WIDGET | ||
220 | (GNUNET_FS_GTK_get_main_window_object | ||
221 | ("GNUNET_GTK_main_menu_file_download_uri"))); | ||
222 | gtk_widget_hide (GTK_WIDGET | ||
223 | (GNUNET_FS_GTK_get_main_window_object | ||
224 | ("GNUNET_GTK_main_menu_file_open_gnunet_directory"))); | ||
225 | /* FIXME: set warning in status bar... */ | ||
226 | } | ||
218 | /* make GUI visible */ | 227 | /* make GUI visible */ |
219 | if (!tray_only) | 228 | if (!tray_only) |
220 | { | 229 | { |
221 | gtk_widget_show (main_window); | 230 | gtk_widget_show (main_window); |
222 | gtk_window_present (GTK_WINDOW (main_window)); | 231 | gtk_window_present (GTK_WINDOW (main_window)); |
223 | } | 232 | } |
224 | 233 | ||
225 | } | 234 | } |
226 | 235 | ||
227 | 236 | ||
@@ -236,12 +245,9 @@ main (int argc, char *const *argv) | |||
236 | }; | 245 | }; |
237 | 246 | ||
238 | if (GNUNET_OK != | 247 | if (GNUNET_OK != |
239 | GNUNET_GTK_main_loop_start ("gnunet-gtk", | 248 | GNUNET_GTK_main_loop_start ("gnunet-gtk", "GTK GUI for GNUnet", argc, |
240 | "GTK GUI for GNUnet", | 249 | argv, options, |
241 | argc, argv, | 250 | "gnunet_fs_gtk_main_window.glade", &run)) |
242 | options, | ||
243 | "gnunet_fs_gtk_main_window.glade", | ||
244 | &run)) | ||
245 | return 1; | 251 | return 1; |
246 | return 0; | 252 | return 0; |
247 | } | 253 | } |
diff --git a/src/lib/about.c b/src/lib/about.c index e75e11dc..095ce21a 100644 --- a/src/lib/about.c +++ b/src/lib/about.c | |||
@@ -33,8 +33,7 @@ | |||
33 | * @param dialogname name of the about dialog in the file | 33 | * @param dialogname name of the about dialog in the file |
34 | */ | 34 | */ |
35 | void | 35 | void |
36 | GNUNET_GTK_display_about (const char *dialogfile, | 36 | GNUNET_GTK_display_about (const char *dialogfile, const char *dialogname) |
37 | const char *dialogname) | ||
38 | { | 37 | { |
39 | GtkBuilder *builder; | 38 | GtkBuilder *builder; |
40 | GtkWidget *ad; | 39 | GtkWidget *ad; |
@@ -42,8 +41,7 @@ GNUNET_GTK_display_about (const char *dialogfile, | |||
42 | builder = GNUNET_GTK_get_new_builder (dialogfile); | 41 | builder = GNUNET_GTK_get_new_builder (dialogfile); |
43 | if (builder == NULL) | 42 | if (builder == NULL) |
44 | return; | 43 | return; |
45 | ad = GTK_WIDGET (gtk_builder_get_object (builder, | 44 | ad = GTK_WIDGET (gtk_builder_get_object (builder, dialogname)); |
46 | dialogname)); | ||
47 | gtk_dialog_run (GTK_DIALOG (ad)); | 45 | gtk_dialog_run (GTK_DIALOG (ad)); |
48 | gtk_widget_destroy (ad); | 46 | gtk_widget_destroy (ad); |
49 | g_object_unref (G_OBJECT (builder)); | 47 | g_object_unref (G_OBJECT (builder)); |
diff --git a/src/lib/eventloop.c b/src/lib/eventloop.c index a1f8d44b..6f5595e6 100644 --- a/src/lib/eventloop.c +++ b/src/lib/eventloop.c | |||
@@ -55,11 +55,11 @@ struct GNUNET_GTK_MainLoop | |||
55 | * Initial task to run to setup the system. | 55 | * Initial task to run to setup the system. |
56 | */ | 56 | */ |
57 | GNUNET_SCHEDULER_Task main_task; | 57 | GNUNET_SCHEDULER_Task main_task; |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * Builder for the main window. | 60 | * Builder for the main window. |
61 | */ | 61 | */ |
62 | GtkBuilder *builder; | 62 | GtkBuilder *builder; |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Gib's Main loop. | 65 | * Gib's Main loop. |
@@ -192,7 +192,7 @@ GNUNET_GTK_main_loop_quit (struct GNUNET_GTK_MainLoop *ml) | |||
192 | */ | 192 | */ |
193 | GObject * | 193 | GObject * |
194 | GNUNET_GTK_main_loop_get_object (struct GNUNET_GTK_MainLoop *ml, | 194 | GNUNET_GTK_main_loop_get_object (struct GNUNET_GTK_MainLoop *ml, |
195 | const char *name) | 195 | const char *name) |
196 | { | 196 | { |
197 | return gtk_builder_get_object (ml->builder, name); | 197 | return gtk_builder_get_object (ml->builder, name); |
198 | } | 198 | } |
@@ -205,10 +205,10 @@ GNUNET_GTK_main_loop_get_object (struct GNUNET_GTK_MainLoop *ml, | |||
205 | * @param tc scheduler context | 205 | * @param tc scheduler context |
206 | */ | 206 | */ |
207 | static void | 207 | static void |
208 | dispatch_gtk_task (void *cls, | 208 | dispatch_gtk_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
209 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
210 | { | 209 | { |
211 | struct GNUNET_GTK_MainLoop *ml = cls; | 210 | struct GNUNET_GTK_MainLoop *ml = cls; |
211 | |||
212 | g_main_context_dispatch (ml->gmc); | 212 | g_main_context_dispatch (ml->gmc); |
213 | } | 213 | } |
214 | 214 | ||
@@ -220,8 +220,7 @@ dispatch_gtk_task (void *cls, | |||
220 | * @param new_size desired size of the cached poll array | 220 | * @param new_size desired size of the cached poll array |
221 | */ | 221 | */ |
222 | static void | 222 | static void |
223 | resize_cached_poll_array (struct GNUNET_GTK_MainLoop *ml, | 223 | resize_cached_poll_array (struct GNUNET_GTK_MainLoop *ml, guint new_size) |
224 | guint new_size) | ||
225 | { | 224 | { |
226 | if (NULL == ml->cached_poll_array) | 225 | if (NULL == ml->cached_poll_array) |
227 | ml->cached_poll_array = g_new (GPollFD, new_size); | 226 | ml->cached_poll_array = g_new (GPollFD, new_size); |
@@ -235,16 +234,14 @@ resize_cached_poll_array (struct GNUNET_GTK_MainLoop *ml, | |||
235 | * Dummy task to keep our scheduler running. | 234 | * Dummy task to keep our scheduler running. |
236 | */ | 235 | */ |
237 | static void | 236 | static void |
238 | keepalive_task (void *cls, | 237 | keepalive_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
239 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
240 | { | 238 | { |
241 | struct GNUNET_GTK_MainLoop *ml = cls; | 239 | struct GNUNET_GTK_MainLoop *ml = cls; |
242 | 240 | ||
243 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 241 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Dummy task was scheduled\n"); |
244 | "Dummy task was scheduled\n"); | 242 | ml->dummy_task = |
245 | ml->dummy_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 243 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
246 | &keepalive_task, | 244 | &keepalive_task, ml); |
247 | ml); | ||
248 | } | 245 | } |
249 | 246 | ||
250 | 247 | ||
@@ -267,8 +264,7 @@ keepalive_task (void *cls, | |||
267 | * @return number of selected sockets, GNUNET_SYSERR on error | 264 | * @return number of selected sockets, GNUNET_SYSERR on error |
268 | */ | 265 | */ |
269 | static int | 266 | static int |
270 | gnunet_gtk_select (void *cls, | 267 | gnunet_gtk_select (void *cls, struct GNUNET_NETWORK_FDSet *rfds, |
271 | struct GNUNET_NETWORK_FDSet *rfds, | ||
272 | struct GNUNET_NETWORK_FDSet *wfds, | 268 | struct GNUNET_NETWORK_FDSet *wfds, |
273 | struct GNUNET_NETWORK_FDSet *efds, | 269 | struct GNUNET_NETWORK_FDSet *efds, |
274 | const struct GNUNET_TIME_Relative timeout) | 270 | const struct GNUNET_TIME_Relative timeout) |
@@ -299,10 +295,7 @@ gnunet_gtk_select (void *cls, | |||
299 | #endif | 295 | #endif |
300 | 296 | ||
301 | if (TRUE != g_main_loop_is_running (ml->gml)) | 297 | if (TRUE != g_main_loop_is_running (ml->gml)) |
302 | return GNUNET_NETWORK_socket_select (rfds, | 298 | return GNUNET_NETWORK_socket_select (rfds, wfds, efds, timeout); |
303 | wfds, | ||
304 | efds, | ||
305 | timeout); | ||
306 | if (NULL != rfds) | 299 | if (NULL != rfds) |
307 | FD_COPY (&rfds->sds, &aread); | 300 | FD_COPY (&rfds->sds, &aread); |
308 | else | 301 | else |
@@ -340,249 +333,260 @@ gnunet_gtk_select (void *cls, | |||
340 | #if !WINDOWS | 333 | #if !WINDOWS |
341 | fd_counter = 0; | 334 | fd_counter = 0; |
342 | for (i = 0; i < max_nfds; i++) | 335 | for (i = 0; i < max_nfds; i++) |
343 | { | 336 | { |
344 | int isset[3]; | 337 | int isset[3]; |
345 | 338 | ||
346 | isset[0] = (rfds == NULL) ? 0 : FD_ISSET (i, &rfds->sds); | 339 | isset[0] = (rfds == NULL) ? 0 : FD_ISSET (i, &rfds->sds); |
347 | isset[1] = (wfds == NULL) ? 0 : FD_ISSET (i, &wfds->sds); | 340 | isset[1] = (wfds == NULL) ? 0 : FD_ISSET (i, &wfds->sds); |
348 | isset[2] = (efds == NULL) ? 0 : FD_ISSET (i, &efds->sds); | 341 | isset[2] = (efds == NULL) ? 0 : FD_ISSET (i, &efds->sds); |
349 | if ((! isset[0]) && (! isset[1]) && (! isset[2])) | 342 | if ((!isset[0]) && (!isset[1]) && (!isset[2])) |
350 | continue; | 343 | continue; |
351 | if (fd_counter >= ml->cached_poll_array_size) | 344 | if (fd_counter >= ml->cached_poll_array_size) |
352 | resize_cached_poll_array (ml, ml->cached_poll_array_size * 2); | 345 | resize_cached_poll_array (ml, ml->cached_poll_array_size * 2); |
353 | ml->cached_poll_array[fd_counter].fd = i; | 346 | ml->cached_poll_array[fd_counter].fd = i; |
354 | ml->cached_poll_array[fd_counter].events | 347 | ml->cached_poll_array[fd_counter].events = |
355 | = (isset[0] ? G_IO_IN | G_IO_HUP | G_IO_ERR : 0) | 348 | (isset[0] ? G_IO_IN | G_IO_HUP | G_IO_ERR : 0) | (isset[1] ? G_IO_OUT | |
356 | | (isset[1] ? G_IO_OUT | G_IO_ERR : 0) | 349 | G_IO_ERR : 0) | |
357 | | (isset[2] ? G_IO_ERR : 0); | 350 | (isset[2] ? G_IO_ERR : 0); |
358 | fd_counter++; | 351 | fd_counter++; |
359 | } | 352 | } |
360 | #else | 353 | #else |
361 | /* FIXME: why while(1) here!? */ | 354 | /* FIXME: why while(1) here!? */ |
362 | while (1) | 355 | while (1) |
356 | { | ||
357 | struct GNUNET_CONTAINER_SList_Iterator *t; | ||
358 | |||
359 | fd_counter = 0; | ||
360 | /* We might overshoot a little, but that won't hurt very much */ | ||
361 | int need_nfds = | ||
362 | (rfds->sds.fd_count + rfds->sds.fd_count + rfds->sds.fd_count > | ||
363 | 0 ? 3 : 0) + (rfds == | ||
364 | NULL ? 0 : GNUNET_CONTAINER_slist_count (rfds->handles)) | ||
365 | + (wfds == NULL ? 0 : 1) + 1; | ||
366 | if (need_nfds >= ml->cached_poll_array_size) | ||
367 | resize_cached_poll_array (ml, need_nfds * 2); | ||
368 | /* Since there are also gmainloop's own fds, just need_nfds won't be | ||
369 | * enough, so make it twice as long. | ||
370 | */ | ||
371 | if (ml->read_array_length < GNUNET_CONTAINER_slist_count (rfds->handles)) | ||
372 | { | ||
373 | ml->read_array = | ||
374 | GNUNET_realloc (ml->read_array, | ||
375 | GNUNET_CONTAINER_slist_count (rfds->handles) * | ||
376 | sizeof (struct GNUNET_DISK_FileHandle *)); | ||
377 | ml->read_array_length = GNUNET_CONTAINER_slist_count (rfds->handles); | ||
378 | } | ||
379 | if (rfds != NULL) | ||
363 | { | 380 | { |
364 | struct GNUNET_CONTAINER_SList_Iterator *t; | 381 | for (t = GNUNET_CONTAINER_slist_begin (rfds->handles), i = 0; |
365 | 382 | GNUNET_CONTAINER_slist_end (t) != GNUNET_YES; | |
366 | fd_counter = 0; | 383 | GNUNET_CONTAINER_slist_next (t), i += 1) |
367 | /* We might overshoot a little, but that won't hurt very much */ | 384 | { |
368 | int need_nfds = (rfds->sds.fd_count + rfds->sds.fd_count + rfds->sds.fd_count > 0 ? 3 : 0) | 385 | struct GNUNET_DISK_FileHandle *fh = |
369 | + (rfds == NULL ? 0 : GNUNET_CONTAINER_slist_count (rfds->handles)) | 386 | GNUNET_CONTAINER_slist_get (t, NULL); |
370 | + (wfds == NULL ? 0 : 1) | 387 | if (fh->type == GNUNET_PIPE) |
371 | + 1; | 388 | { |
372 | if (need_nfds >= ml->cached_poll_array_size) | 389 | if (!ReadFile (fh->h, NULL, 0, NULL, fh->oOverlapRead)) |
373 | resize_cached_poll_array (ml, need_nfds * 2); | 390 | { |
374 | /* Since there are also gmainloop's own fds, just need_nfds won't be | 391 | DWORD error_code = GetLastError (); |
375 | * enough, so make it twice as long. | 392 | |
376 | */ | 393 | if (error_code == ERROR_IO_PENDING) |
377 | if (ml->read_array_length < GNUNET_CONTAINER_slist_count (rfds->handles)) | 394 | { |
378 | { | ||
379 | ml->read_array = GNUNET_realloc (ml->read_array, | ||
380 | GNUNET_CONTAINER_slist_count (rfds->handles) * sizeof (struct GNUNET_DISK_FileHandle *)); | ||
381 | ml->read_array_length = GNUNET_CONTAINER_slist_count (rfds->handles); | ||
382 | } | ||
383 | if (rfds != NULL) | ||
384 | { | ||
385 | for (t = GNUNET_CONTAINER_slist_begin (rfds->handles), i = 0; | ||
386 | GNUNET_CONTAINER_slist_end (t) != GNUNET_YES; | ||
387 | GNUNET_CONTAINER_slist_next (t), i += 1) | ||
388 | { | ||
389 | struct GNUNET_DISK_FileHandle *fh = GNUNET_CONTAINER_slist_get (t, NULL); | ||
390 | if (fh->type == GNUNET_PIPE) | ||
391 | { | ||
392 | if (!ReadFile (fh->h, NULL, 0, NULL, fh->oOverlapRead)) | ||
393 | { | ||
394 | DWORD error_code = GetLastError(); | ||
395 | if (error_code == ERROR_IO_PENDING) | ||
396 | { | ||
397 | #if DEBUG_EVENTLOOP | 395 | #if DEBUG_EVENTLOOP |
398 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 396 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
399 | "Adding the pipe's 0x%x overlapped event to the array as %d\n", | 397 | "Adding the pipe's 0x%x overlapped event to the array as %d\n", |
400 | fh->h, nhandles); | 398 | fh->h, nhandles); |
401 | #endif | 399 | #endif |
402 | ml->cached_poll_array[fd_counter].fd = (intptr_t) fh->oOverlapRead->hEvent; | 400 | ml->cached_poll_array[fd_counter].fd = |
403 | /* On W32 .events makes no sense - g_poll will just OR its | 401 | (intptr_t) fh->oOverlapRead->hEvent; |
404 | * contents into .revents when the .fd event fires. | 402 | /* On W32 .events makes no sense - g_poll will just OR its |
405 | * So we'll use it in the way that suits us the best. | 403 | * contents into .revents when the .fd event fires. |
406 | */ | 404 | * So we'll use it in the way that suits us the best. |
407 | ml->cached_poll_array[fd_counter].events = G_IO_IN; | 405 | */ |
408 | fd_counter += 1; | 406 | ml->cached_poll_array[fd_counter].events = G_IO_IN; |
409 | ml->read_array[read_handles] = fh; | 407 | fd_counter += 1; |
410 | read_handles += 1; | 408 | ml->read_array[read_handles] = fh; |
411 | } | 409 | read_handles += 1; |
412 | else | 410 | } |
413 | { | 411 | else |
414 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventReadReady; | 412 | { |
415 | ml->cached_poll_array[fd_counter].events = G_IO_HUP; | 413 | ml->cached_poll_array[fd_counter].fd = |
416 | fd_counter += 1; | 414 | (intptr_t) ml->hEventReadReady; |
417 | ml->read_array[read_handles] = fh; | 415 | ml->cached_poll_array[fd_counter].events = G_IO_HUP; |
418 | read_handles += 1; | 416 | fd_counter += 1; |
419 | } | 417 | ml->read_array[read_handles] = fh; |
420 | } | 418 | read_handles += 1; |
421 | else | 419 | } |
422 | { | 420 | } |
421 | else | ||
422 | { | ||
423 | #if DEBUG_EVENTLOOP | 423 | #if DEBUG_EVENTLOOP |
424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
425 | "Adding the read ready event to the array as %d\n", | 425 | "Adding the read ready event to the array as %d\n", |
426 | nhandles); | 426 | nhandles); |
427 | #endif | 427 | #endif |
428 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventReadReady; | 428 | ml->cached_poll_array[fd_counter].fd = |
429 | ml->cached_poll_array[fd_counter].events = G_IO_IN; | 429 | (intptr_t) ml->hEventReadReady; |
430 | fd_counter += 1; | 430 | ml->cached_poll_array[fd_counter].events = G_IO_IN; |
431 | ml->read_array[read_handles] = fh; | 431 | fd_counter += 1; |
432 | read_handles += 1; | 432 | ml->read_array[read_handles] = fh; |
433 | } | 433 | read_handles += 1; |
434 | } | 434 | } |
435 | else | 435 | } |
436 | { | 436 | else |
437 | GNUNET_CONTAINER_slist_add (ml->handles_read, | 437 | { |
438 | GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, | 438 | GNUNET_CONTAINER_slist_add (ml->handles_read, |
439 | fh, sizeof (struct GNUNET_DISK_FileHandle)); | 439 | GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, |
440 | pre_ret++; | 440 | fh, |
441 | } | 441 | sizeof (struct GNUNET_DISK_FileHandle)); |
442 | } | 442 | pre_ret++; |
443 | } | 443 | } |
444 | if ( (wfds != NULL) && (GNUNET_CONTAINER_slist_count (wfds->handles) > 0) ) | 444 | } |
445 | { | 445 | } |
446 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventPipeWrite; | 446 | if ((wfds != NULL) && (GNUNET_CONTAINER_slist_count (wfds->handles) > 0)) |
447 | ml->cached_poll_array[fd_counter].events = G_IO_OUT; | 447 | { |
448 | always_ready_write_fd = fd_counter; | 448 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventPipeWrite; |
449 | fd_counter += 1; | 449 | ml->cached_poll_array[fd_counter].events = G_IO_OUT; |
450 | } | 450 | always_ready_write_fd = fd_counter; |
451 | if (efds != NULL) | 451 | fd_counter += 1; |
452 | { | 452 | } |
453 | for (t = GNUNET_CONTAINER_slist_begin (efds->handles), i = 0; | 453 | if (efds != NULL) |
454 | GNUNET_CONTAINER_slist_end (t) != GNUNET_YES; | 454 | { |
455 | GNUNET_CONTAINER_slist_next (t), i += 1) | 455 | for (t = GNUNET_CONTAINER_slist_begin (efds->handles), i = 0; |
456 | { | 456 | GNUNET_CONTAINER_slist_end (t) != GNUNET_YES; |
457 | struct GNUNET_DISK_FileHandle *fh = GNUNET_CONTAINER_slist_get (t, NULL); | 457 | GNUNET_CONTAINER_slist_next (t), i += 1) |
458 | 458 | { | |
459 | DWORD dwBytes; | 459 | struct GNUNET_DISK_FileHandle *fh = |
460 | if (fh->type == GNUNET_PIPE) | 460 | GNUNET_CONTAINER_slist_get (t, NULL); |
461 | { | 461 | |
462 | if (!PeekNamedPipe (fh->h, NULL, 0, NULL, &dwBytes, NULL)) | 462 | DWORD dwBytes; |
463 | { | 463 | |
464 | GNUNET_CONTAINER_slist_add (ml->handles_except, | 464 | if (fh->type == GNUNET_PIPE) |
465 | GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, | 465 | { |
466 | fh, sizeof (struct GNUNET_DISK_FileHandle)); | 466 | if (!PeekNamedPipe (fh->h, NULL, 0, NULL, &dwBytes, NULL)) |
467 | pre_ret++; | 467 | { |
468 | } | 468 | GNUNET_CONTAINER_slist_add (ml->handles_except, |
469 | } | 469 | GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, |
470 | } | 470 | fh, |
471 | } | 471 | sizeof (struct GNUNET_DISK_FileHandle)); |
472 | GNUNET_CONTAINER_slist_iter_destroy (t); | 472 | pre_ret++; |
473 | 473 | } | |
474 | if ( (rfds != NULL) && (rfds->sds.fd_count > 0) ) | 474 | } |
475 | { | 475 | } |
476 | } | ||
477 | GNUNET_CONTAINER_slist_iter_destroy (t); | ||
478 | |||
479 | if ((rfds != NULL) && (rfds->sds.fd_count > 0)) | ||
480 | { | ||
476 | #if DEBUG_EVENTLOOP | 481 | #if DEBUG_EVENTLOOP |
477 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 482 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
478 | "Adding the socket read event to the array as %d\n", | 483 | "Adding the socket read event to the array as %d\n", |
479 | fd_counter); | 484 | fd_counter); |
480 | #endif | 485 | #endif |
481 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventRead; | 486 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventRead; |
482 | ml->cached_poll_array[fd_counter].events = G_IO_IN; | 487 | ml->cached_poll_array[fd_counter].events = G_IO_IN; |
483 | for (i = 0; i < rfds->sds.fd_count; i++) | 488 | for (i = 0; i < rfds->sds.fd_count; i++) |
484 | WSAEventSelect (rfds->sds.fd_array[i], ml->hEventRead, FD_ACCEPT | FD_READ | FD_CLOSE); | 489 | WSAEventSelect (rfds->sds.fd_array[i], ml->hEventRead, |
485 | fd_counter += 1; | 490 | FD_ACCEPT | FD_READ | FD_CLOSE); |
486 | sock_read = rfds->sds.fd_count; | 491 | fd_counter += 1; |
487 | } | 492 | sock_read = rfds->sds.fd_count; |
488 | if ( (wfds != NULL) && (wfds->sds.fd_count > 0) ) | 493 | } |
489 | { | 494 | if ((wfds != NULL) && (wfds->sds.fd_count > 0)) |
490 | int wakeup = 0; | 495 | { |
496 | int wakeup = 0; | ||
497 | |||
491 | #if DEBUG_EVENTLOOP | 498 | #if DEBUG_EVENTLOOP |
492 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 499 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
493 | "Adding the socket write event to the array as %d\n", | 500 | "Adding the socket write event to the array as %d\n", |
494 | fd_counter); | 501 | fd_counter); |
495 | #endif | 502 | #endif |
496 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventWrite; | 503 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventWrite; |
497 | ml->cached_poll_array[fd_counter].events = G_IO_OUT; | 504 | ml->cached_poll_array[fd_counter].events = G_IO_OUT; |
498 | for (i = 0; i < wfds->sds.fd_count; i++) | 505 | for (i = 0; i < wfds->sds.fd_count; i++) |
499 | { | 506 | { |
500 | DWORD error; | 507 | DWORD error; |
501 | int status; | 508 | int status; |
502 | status = send (wfds->sds.fd_array[i], NULL, 0, 0); | 509 | |
503 | error = GetLastError (); | 510 | status = send (wfds->sds.fd_array[i], NULL, 0, 0); |
511 | error = GetLastError (); | ||
504 | #if DEBUG_EVENTLOOP | 512 | #if DEBUG_EVENTLOOP |
505 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 513 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
506 | "pre-send to the socket %d returned %d (%u)\n", | 514 | "pre-send to the socket %d returned %d (%u)\n", i, status, |
507 | i, status, error); | 515 | error); |
508 | #endif | 516 | #endif |
509 | if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN)) | 517 | if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN)) |
510 | wakeup = 1; | 518 | wakeup = 1; |
511 | WSAEventSelect (wfds->sds.fd_array[i], ml->hEventWrite, FD_WRITE | FD_CONNECT | FD_CLOSE); | 519 | WSAEventSelect (wfds->sds.fd_array[i], ml->hEventWrite, |
512 | } | 520 | FD_WRITE | FD_CONNECT | FD_CLOSE); |
513 | if (wakeup) | 521 | } |
514 | SetEvent (ml->hEventWrite); | 522 | if (wakeup) |
515 | fd_counter += 1; | 523 | SetEvent (ml->hEventWrite); |
516 | sock_write = wfds->sds.fd_count; | 524 | fd_counter += 1; |
517 | } | 525 | sock_write = wfds->sds.fd_count; |
518 | if ( (efds != NULL) && (efds->sds.fd_count > 0) ) | 526 | } |
519 | { | 527 | if ((efds != NULL) && (efds->sds.fd_count > 0)) |
528 | { | ||
520 | #if DEBUG_EVENTLOOP | 529 | #if DEBUG_EVENTLOOP |
521 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 530 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
522 | "Adding the socket error event to the array as %d\n", | 531 | "Adding the socket error event to the array as %d\n", |
523 | fd_counter); | 532 | fd_counter); |
524 | #endif | 533 | #endif |
525 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventException; | 534 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventException; |
526 | ml->cached_poll_array[fd_counter].events = G_IO_ERR; | 535 | ml->cached_poll_array[fd_counter].events = G_IO_ERR; |
527 | for (i = 0; i < efds->sds.fd_count; i++) | 536 | for (i = 0; i < efds->sds.fd_count; i++) |
528 | WSAEventSelect (efds->sds.fd_array[i], ml->hEventException, FD_OOB | FD_CLOSE); | 537 | WSAEventSelect (efds->sds.fd_array[i], ml->hEventException, |
529 | fd_counter++; | 538 | FD_OOB | FD_CLOSE); |
530 | sock_err = efds->sds.fd_count; | 539 | fd_counter++; |
531 | } | 540 | sock_err = efds->sds.fd_count; |
532 | break; | ||
533 | } | 541 | } |
542 | break; | ||
543 | } | ||
534 | socks = sock_read + sock_write + sock_err; | 544 | socks = sock_read + sock_write + sock_err; |
535 | #endif | 545 | #endif |
536 | 546 | ||
537 | /* combine with Gtk events */ | 547 | /* combine with Gtk events */ |
538 | g_main_context_prepare (ml->gmc, &max_priority); | 548 | g_main_context_prepare (ml->gmc, &max_priority); |
539 | while (1) | 549 | while (1) |
540 | { | 550 | { |
541 | need_gfds = g_main_context_query (ml->gmc, | 551 | need_gfds = |
542 | max_priority, | 552 | g_main_context_query (ml->gmc, max_priority, &delay, |
543 | &delay, | 553 | &ml->cached_poll_array[fd_counter], |
544 | &ml->cached_poll_array[fd_counter], | 554 | ml->cached_poll_array_size - fd_counter); |
545 | ml->cached_poll_array_size - fd_counter); | 555 | if (ml->cached_poll_array_size >= need_gfds + fd_counter) |
546 | if (ml->cached_poll_array_size >= need_gfds + fd_counter) | 556 | break; |
547 | break; | 557 | resize_cached_poll_array (ml, fd_counter + need_gfds); |
548 | resize_cached_poll_array (ml, | 558 | } |
549 | fd_counter + need_gfds); | ||
550 | } | ||
551 | 559 | ||
552 | if (timeout.rel_value != GNUNET_TIME_UNIT_FOREVER_REL.rel_value) | 560 | if (timeout.rel_value != GNUNET_TIME_UNIT_FOREVER_REL.rel_value) |
553 | { | 561 | { |
554 | if (delay >= 0) | 562 | if (delay >= 0) |
555 | delay = GNUNET_MIN (timeout.rel_value / GNUNET_TIME_UNIT_MILLISECONDS.rel_value, | 563 | delay = |
556 | delay); | 564 | GNUNET_MIN (timeout.rel_value / |
557 | else | 565 | GNUNET_TIME_UNIT_MILLISECONDS.rel_value, delay); |
558 | delay = timeout.rel_value / GNUNET_TIME_UNIT_MILLISECONDS.rel_value; | 566 | else |
559 | } | 567 | delay = timeout.rel_value / GNUNET_TIME_UNIT_MILLISECONDS.rel_value; |
568 | } | ||
560 | 569 | ||
561 | #if WINDOWS | 570 | #if WINDOWS |
562 | if (pre_ret > 0) | 571 | if (pre_ret > 0) |
563 | { | 572 | { |
564 | #if DEBUG_EVENTLOOP | 573 | #if DEBUG_EVENTLOOP |
565 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 574 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "pre_ret is %d, setting delay to 0\n", |
566 | "pre_ret is %d, setting delay to 0\n", | 575 | pre_ret); |
567 | pre_ret); | ||
568 | #endif | 576 | #endif |
569 | delay = 0; | 577 | delay = 0; |
570 | } | 578 | } |
571 | #endif | 579 | #endif |
572 | 580 | ||
573 | #if DEBUG_EVENTLOOP | 581 | #if DEBUG_EVENTLOOP |
574 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 582 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
575 | "We have %d of our FDs and %d of GMC ones, going to wait %6dms\n", | 583 | "We have %d of our FDs and %d of GMC ones, going to wait %6dms\n", |
576 | fd_counter, need_gfds, delay); | 584 | fd_counter, need_gfds, delay); |
577 | #endif | 585 | #endif |
578 | 586 | ||
579 | poll_result = g_poll (ml->cached_poll_array, | 587 | poll_result = g_poll (ml->cached_poll_array, fd_counter + need_gfds, delay); |
580 | fd_counter + need_gfds, | ||
581 | delay); | ||
582 | #if DEBUG_EVENTLOOP | 588 | #if DEBUG_EVENTLOOP |
583 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 589 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "g_poll returned : %d\n", poll_result); |
584 | "g_poll returned : %d\n", | ||
585 | poll_result); | ||
586 | #endif | 590 | #endif |
587 | 591 | ||
588 | /* Take care of GUI events. | 592 | /* Take care of GUI events. |
@@ -590,12 +594,11 @@ gnunet_gtk_select (void *cls, | |||
590 | * from within a task (currently we're not in a task, but in a select() call, remember) | 594 | * from within a task (currently we're not in a task, but in a select() call, remember) |
591 | * Startup reason is used to pass the scheduler sanity check. | 595 | * Startup reason is used to pass the scheduler sanity check. |
592 | */ | 596 | */ |
593 | if (TRUE == g_main_context_check (ml->gmc, | 597 | if (TRUE == |
594 | max_priority, | 598 | g_main_context_check (ml->gmc, max_priority, |
595 | &ml->cached_poll_array[fd_counter], | 599 | &ml->cached_poll_array[fd_counter], need_gfds)) |
596 | need_gfds)) | ||
597 | GNUNET_SCHEDULER_add_continuation (&dispatch_gtk_task, ml, | 600 | GNUNET_SCHEDULER_add_continuation (&dispatch_gtk_task, ml, |
598 | GNUNET_SCHEDULER_REASON_STARTUP); | 601 | GNUNET_SCHEDULER_REASON_STARTUP); |
599 | 602 | ||
600 | /* Now map back GNUnet scheduler events ... */ | 603 | /* Now map back GNUnet scheduler events ... */ |
601 | #if !WINDOWS | 604 | #if !WINDOWS |
@@ -606,167 +609,177 @@ gnunet_gtk_select (void *cls, | |||
606 | if (NULL != efds) | 609 | if (NULL != efds) |
607 | GNUNET_NETWORK_fdset_zero (efds); | 610 | GNUNET_NETWORK_fdset_zero (efds); |
608 | for (i = 0; i < fd_counter; i++) | 611 | for (i = 0; i < fd_counter; i++) |
609 | { | 612 | { |
610 | int set = 0; | 613 | int set = 0; |
611 | 614 | ||
612 | if ( (NULL != rfds) && | 615 | if ((NULL != rfds) && |
613 | (set |= (FD_ISSET (ml->cached_poll_array[i].fd, &aread) && | 616 | (set |= |
614 | (0 != (ml->cached_poll_array[i].revents & (G_IO_IN | G_IO_HUP | G_IO_ERR)))))) | 617 | (FD_ISSET (ml->cached_poll_array[i].fd, &aread) && |
615 | GNUNET_NETWORK_fdset_set_native (rfds, ml->cached_poll_array[i].fd); | 618 | (0 != |
616 | if ( (NULL != wfds) && | 619 | (ml-> |
617 | (set |= (FD_ISSET (ml->cached_poll_array[i].fd, &awrite) && | 620 | cached_poll_array[i].revents & (G_IO_IN | G_IO_HUP | G_IO_ERR)))))) |
618 | (0 != (ml->cached_poll_array[i].revents & (G_IO_OUT | G_IO_ERR)))))) | 621 | GNUNET_NETWORK_fdset_set_native (rfds, ml->cached_poll_array[i].fd); |
619 | GNUNET_NETWORK_fdset_set_native (wfds, ml->cached_poll_array[i].fd); | 622 | if ((NULL != wfds) && |
620 | if ( (NULL != efds) && | 623 | (set |= |
621 | (set |= (FD_ISSET (ml->cached_poll_array[i].fd, &aexcept) && | 624 | (FD_ISSET (ml->cached_poll_array[i].fd, &awrite) && |
622 | (0 != (ml->cached_poll_array[i].revents & G_IO_ERR))))) | 625 | (0 != (ml->cached_poll_array[i].revents & (G_IO_OUT | G_IO_ERR)))))) |
623 | GNUNET_NETWORK_fdset_set_native (efds, ml->cached_poll_array[i].fd); | 626 | GNUNET_NETWORK_fdset_set_native (wfds, ml->cached_poll_array[i].fd); |
624 | if (set) | 627 | if ((NULL != efds) && |
625 | result++; | 628 | (set |= |
626 | } | 629 | (FD_ISSET (ml->cached_poll_array[i].fd, &aexcept) && |
630 | (0 != (ml->cached_poll_array[i].revents & G_IO_ERR))))) | ||
631 | GNUNET_NETWORK_fdset_set_native (efds, ml->cached_poll_array[i].fd); | ||
632 | if (set) | ||
633 | result++; | ||
634 | } | ||
627 | #else | 635 | #else |
628 | if (socks > 0) | 636 | if (socks > 0) |
629 | { | 637 | { |
630 | struct timeval tvslice; | 638 | struct timeval tvslice; |
631 | tvslice.tv_sec = 0; | 639 | |
632 | tvslice.tv_usec = 0; | 640 | tvslice.tv_sec = 0; |
633 | select_ret = select (max_nfds, &aread, &awrite, &aexcept, &tvslice); | 641 | tvslice.tv_usec = 0; |
634 | if (select_ret == -1) | 642 | select_ret = select (max_nfds, &aread, &awrite, &aexcept, &tvslice); |
635 | select_ret = 0; | 643 | if (select_ret == -1) |
644 | select_ret = 0; | ||
636 | #if DEBUG_EVENTLOOP | 645 | #if DEBUG_EVENTLOOP |
637 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 646 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "select() returned %d\n", select_ret); |
638 | "select() returned %d\n", | ||
639 | select_ret); | ||
640 | #endif | 647 | #endif |
641 | } | 648 | } |
642 | if (always_ready_write_fd >= 0 && ml->cached_poll_array[always_ready_write_fd].revents & G_IO_OUT) | 649 | if (always_ready_write_fd >= 0 && |
643 | { | 650 | ml->cached_poll_array[always_ready_write_fd].revents & G_IO_OUT) |
644 | GNUNET_CONTAINER_slist_append (ml->handles_write, wfds->handles); | 651 | { |
645 | result += GNUNET_CONTAINER_slist_count (ml->handles_write); | 652 | GNUNET_CONTAINER_slist_append (ml->handles_write, wfds->handles); |
653 | result += GNUNET_CONTAINER_slist_count (ml->handles_write); | ||
646 | #if DEBUG_EVENTLOOP | 654 | #if DEBUG_EVENTLOOP |
647 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added write pipe\n"); | 655 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added write pipe\n"); |
648 | #endif | 656 | #endif |
649 | } | 657 | } |
650 | for (i = 0; i < read_handles; i++) | 658 | for (i = 0; i < read_handles; i++) |
651 | { | 659 | { |
652 | DWORD error; | 660 | DWORD error; |
653 | BOOL bret; | 661 | BOOL bret; |
654 | if (!(ml->cached_poll_array[i].revents & (G_IO_IN | G_IO_HUP | G_IO_ERR))) | 662 | |
655 | continue; | 663 | if (!(ml->cached_poll_array[i].revents & (G_IO_IN | G_IO_HUP | G_IO_ERR))) |
656 | SetLastError (0); | 664 | continue; |
657 | waitstatus = 0; | 665 | SetLastError (0); |
658 | bret = PeekNamedPipe (ml->read_array[i]->h, NULL, 0, NULL, &waitstatus, NULL); | 666 | waitstatus = 0; |
659 | error = GetLastError (); | 667 | bret = |
668 | PeekNamedPipe (ml->read_array[i]->h, NULL, 0, NULL, &waitstatus, NULL); | ||
669 | error = GetLastError (); | ||
660 | #if DEBUG_EVENTLOOP | 670 | #if DEBUG_EVENTLOOP |
661 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 671 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
662 | "Peek at read pipe %d (0x%x) returned %d (%d bytes available) GLE %u\n", | 672 | "Peek at read pipe %d (0x%x) returned %d (%d bytes available) GLE %u\n", |
663 | i, ml->read_array[i]->h, bret, waitstatus, error); | 673 | i, ml->read_array[i]->h, bret, waitstatus, error); |
664 | #endif | 674 | #endif |
665 | if (bret == 0 || (ml->cached_poll_array[i].revents & G_IO_ERR)) | 675 | if (bret == 0 || (ml->cached_poll_array[i].revents & G_IO_ERR)) |
666 | { | 676 | { |
667 | if (efds != NULL) | 677 | if (efds != NULL) |
668 | { | 678 | { |
669 | struct GNUNET_CONTAINER_SList_Iterator *t; | 679 | struct GNUNET_CONTAINER_SList_Iterator *t; |
670 | for (t = GNUNET_CONTAINER_slist_begin (efds->handles), i = 0; | 680 | |
671 | GNUNET_CONTAINER_slist_end (t) != GNUNET_YES; | 681 | for (t = GNUNET_CONTAINER_slist_begin (efds->handles), i = 0; |
672 | GNUNET_CONTAINER_slist_next (t), i += 1) | 682 | GNUNET_CONTAINER_slist_end (t) != GNUNET_YES; |
673 | { | 683 | GNUNET_CONTAINER_slist_next (t), i += 1) |
674 | struct GNUNET_DISK_FileHandle *fh = GNUNET_CONTAINER_slist_get (t, NULL); | 684 | { |
675 | if (fh == ml->read_array[i]) | 685 | struct GNUNET_DISK_FileHandle *fh = |
676 | { | 686 | GNUNET_CONTAINER_slist_get (t, NULL); |
677 | GNUNET_CONTAINER_slist_add (ml->handles_except, | 687 | if (fh == ml->read_array[i]) |
678 | GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, | 688 | { |
679 | fh, sizeof (struct GNUNET_DISK_FileHandle)); | 689 | GNUNET_CONTAINER_slist_add (ml->handles_except, |
680 | break; | 690 | GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, |
681 | } | 691 | fh, |
682 | } | 692 | sizeof (struct GNUNET_DISK_FileHandle)); |
683 | GNUNET_CONTAINER_slist_iter_destroy (t); | 693 | break; |
684 | } | 694 | } |
685 | } | 695 | } |
686 | else if (waitstatus <= 0) | 696 | GNUNET_CONTAINER_slist_iter_destroy (t); |
687 | continue; | 697 | } |
688 | GNUNET_CONTAINER_slist_add (ml->handles_read, | 698 | } |
689 | GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, | 699 | else if (waitstatus <= 0) |
690 | ml->read_array[i], sizeof (struct GNUNET_DISK_FileHandle)); | 700 | continue; |
691 | result += 1; | 701 | GNUNET_CONTAINER_slist_add (ml->handles_read, |
702 | GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, | ||
703 | ml->read_array[i], | ||
704 | sizeof (struct GNUNET_DISK_FileHandle)); | ||
705 | result += 1; | ||
692 | #if DEBUG_EVENTLOOP | 706 | #if DEBUG_EVENTLOOP |
693 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 707 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added read Pipe 0x%x (0x%x)\n", |
694 | "Added read Pipe 0x%x (0x%x)\n", | 708 | ml->read_array[i], ml->read_array[i]->h); |
695 | ml->read_array[i], | ||
696 | ml->read_array[i]->h); | ||
697 | #endif | 709 | #endif |
698 | } | 710 | } |
699 | waitstatus = WaitForSingleObject (ml->hEventWrite, 0); | 711 | waitstatus = WaitForSingleObject (ml->hEventWrite, 0); |
700 | #if DEBUG_EVENTLOOP | 712 | #if DEBUG_EVENTLOOP |
701 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 713 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Wait for the write event returned %d\n", |
702 | "Wait for the write event returned %d\n", | 714 | waitstatus); |
703 | waitstatus); | ||
704 | #endif | 715 | #endif |
705 | if (waitstatus == WAIT_OBJECT_0) | 716 | if (waitstatus == WAIT_OBJECT_0) |
717 | { | ||
718 | for (i = 0; i < wfds->sds.fd_count; i++) | ||
706 | { | 719 | { |
707 | for (i = 0; i < wfds->sds.fd_count; i++) | 720 | DWORD error; |
708 | { | 721 | int status; |
709 | DWORD error; | 722 | int so_error = 0; |
710 | int status; | 723 | int sizeof_so_error = sizeof (so_error); |
711 | int so_error = 0; | 724 | int gso_result = getsockopt (wfds->sds.fd_array[i], |
712 | int sizeof_so_error = sizeof (so_error); | 725 | SOL_SOCKET, SO_ERROR, |
713 | int gso_result = getsockopt (wfds->sds.fd_array[i], | 726 | (char *) &so_error, &sizeof_so_error); |
714 | SOL_SOCKET, SO_ERROR, | 727 | |
715 | (char *) &so_error, &sizeof_so_error); | 728 | status = send (wfds->sds.fd_array[i], NULL, 0, 0); |
716 | status = send (wfds->sds.fd_array[i], NULL, 0, 0); | 729 | error = GetLastError (); |
717 | error = GetLastError (); | ||
718 | #if DEBUG_EVENTLOOP | 730 | #if DEBUG_EVENTLOOP |
719 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 731 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
720 | "send to the socket %d returned %d (%u)\n", | 732 | "send to the socket %d returned %d (%u)\n", i, status, error); |
721 | i, status, error); | ||
722 | #endif | 733 | #endif |
723 | if (status == 0 | 734 | if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN) || |
724 | || (error != WSAEWOULDBLOCK && error != WSAENOTCONN) | 735 | (status == -1 && gso_result == 0 && error == WSAENOTCONN && |
725 | || (status == -1 && gso_result == 0 && error == WSAENOTCONN && so_error == WSAECONNREFUSED)) | 736 | so_error == WSAECONNREFUSED)) |
726 | { | 737 | { |
727 | FD_SET (wfds->sds.fd_array[i], &awrite); | 738 | FD_SET (wfds->sds.fd_array[i], &awrite); |
728 | result += 1; | 739 | result += 1; |
729 | } | 740 | } |
730 | } | ||
731 | } | 741 | } |
742 | } | ||
732 | if (rfds) | 743 | if (rfds) |
744 | { | ||
745 | struct GNUNET_CONTAINER_SList_Iterator *t; | ||
746 | |||
747 | for (i = 0; i < rfds->sds.fd_count; i++) | ||
748 | WSAEventSelect (rfds->sds.fd_array[i], ml->hEventRead, 0); | ||
749 | for (t = GNUNET_CONTAINER_slist_begin (rfds->handles); | ||
750 | GNUNET_CONTAINER_slist_end (t) != GNUNET_YES; | ||
751 | GNUNET_CONTAINER_slist_next (t)) | ||
733 | { | 752 | { |
734 | struct GNUNET_CONTAINER_SList_Iterator *t; | 753 | struct GNUNET_DISK_FileHandle *fh = GNUNET_CONTAINER_slist_get (t, NULL); |
735 | for (i = 0; i < rfds->sds.fd_count; i++) | 754 | |
736 | WSAEventSelect (rfds->sds.fd_array[i], ml->hEventRead, 0); | 755 | if (fh->type == GNUNET_PIPE) |
737 | for (t = GNUNET_CONTAINER_slist_begin (rfds->handles); | 756 | CancelIo (fh->h); |
738 | GNUNET_CONTAINER_slist_end (t) != GNUNET_YES; | ||
739 | GNUNET_CONTAINER_slist_next (t)) | ||
740 | { | ||
741 | struct GNUNET_DISK_FileHandle *fh = GNUNET_CONTAINER_slist_get (t, NULL); | ||
742 | if (fh->type == GNUNET_PIPE) | ||
743 | CancelIo (fh->h); | ||
744 | } | ||
745 | GNUNET_CONTAINER_slist_iter_destroy (t); | ||
746 | GNUNET_NETWORK_fdset_zero (rfds); | ||
747 | if (select_ret != -1 && socks > 0) | ||
748 | GNUNET_NETWORK_fdset_copy_native (rfds, &aread, select_ret); | ||
749 | GNUNET_CONTAINER_slist_append (rfds->handles, ml->handles_read); | ||
750 | } | 757 | } |
758 | GNUNET_CONTAINER_slist_iter_destroy (t); | ||
759 | GNUNET_NETWORK_fdset_zero (rfds); | ||
760 | if (select_ret != -1 && socks > 0) | ||
761 | GNUNET_NETWORK_fdset_copy_native (rfds, &aread, select_ret); | ||
762 | GNUNET_CONTAINER_slist_append (rfds->handles, ml->handles_read); | ||
763 | } | ||
751 | if (wfds) | 764 | if (wfds) |
752 | { | 765 | { |
753 | for (i = 0; i < wfds->sds.fd_count; i++) | 766 | for (i = 0; i < wfds->sds.fd_count; i++) |
754 | WSAEventSelect (wfds->sds.fd_array[i], ml->hEventWrite, 0); | 767 | WSAEventSelect (wfds->sds.fd_array[i], ml->hEventWrite, 0); |
755 | GNUNET_NETWORK_fdset_zero (wfds); | 768 | GNUNET_NETWORK_fdset_zero (wfds); |
756 | if (select_ret != -1 && socks > 0) | 769 | if (select_ret != -1 && socks > 0) |
757 | GNUNET_NETWORK_fdset_copy_native (wfds, &awrite, select_ret); | 770 | GNUNET_NETWORK_fdset_copy_native (wfds, &awrite, select_ret); |
758 | GNUNET_CONTAINER_slist_append (wfds->handles, ml->handles_write); | 771 | GNUNET_CONTAINER_slist_append (wfds->handles, ml->handles_write); |
759 | } | 772 | } |
760 | if (efds) | 773 | if (efds) |
761 | { | 774 | { |
762 | for (i = 0; i < efds->sds.fd_count; i++) | 775 | for (i = 0; i < efds->sds.fd_count; i++) |
763 | WSAEventSelect (efds->sds.fd_array[i], ml->hEventException, 0); | 776 | WSAEventSelect (efds->sds.fd_array[i], ml->hEventException, 0); |
764 | GNUNET_NETWORK_fdset_zero (efds); | 777 | GNUNET_NETWORK_fdset_zero (efds); |
765 | if (select_ret != -1 && socks > 0) | 778 | if (select_ret != -1 && socks > 0) |
766 | GNUNET_NETWORK_fdset_copy_native (efds, &aexcept, select_ret); | 779 | GNUNET_NETWORK_fdset_copy_native (efds, &aexcept, select_ret); |
767 | GNUNET_CONTAINER_slist_append (efds->handles, ml->handles_except); | 780 | GNUNET_CONTAINER_slist_append (efds->handles, ml->handles_except); |
768 | result += GNUNET_CONTAINER_slist_count (ml->handles_except); | 781 | result += GNUNET_CONTAINER_slist_count (ml->handles_except); |
769 | } | 782 | } |
770 | if (fd_counter > 0) | 783 | if (fd_counter > 0) |
771 | /* This is not accurate (select_ret counts write-ready sockets, | 784 | /* This is not accurate (select_ret counts write-ready sockets, |
772 | * and result does as well. Anything out there actually cares | 785 | * and result does as well. Anything out there actually cares |
@@ -789,19 +802,18 @@ gnunet_gtk_select (void *cls, | |||
789 | * @param args leftover command line arguments (go to gtk) | 802 | * @param args leftover command line arguments (go to gtk) |
790 | * @param cfgfile name of the configuration file | 803 | * @param cfgfile name of the configuration file |
791 | * @param cfg handle to the configuration | 804 | * @param cfg handle to the configuration |
792 | */ | 805 | */ |
793 | static void | 806 | static void |
794 | run_main_loop (void *cls, | 807 | run_main_loop (void *cls, char *const *args, const char *cfgfile, |
795 | char *const *args, | 808 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
796 | const char *cfgfile, | ||
797 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
798 | { | 809 | { |
799 | struct GNUNET_GTK_MainLoop *ml = cls; | 810 | struct GNUNET_GTK_MainLoop *ml = cls; |
800 | int argc; | 811 | int argc; |
801 | 812 | ||
802 | /* command-line processing for Gtk arguments */ | 813 | /* command-line processing for Gtk arguments */ |
803 | argc = 0; | 814 | argc = 0; |
804 | while (args[argc] != NULL) argc++; | 815 | while (args[argc] != NULL) |
816 | argc++; | ||
805 | gtk_init (&argc, (char ***) &args); | 817 | gtk_init (&argc, (char ***) &args); |
806 | 818 | ||
807 | /* setup main context */ | 819 | /* setup main context */ |
@@ -828,16 +840,16 @@ run_main_loop (void *cls, | |||
828 | 840 | ||
829 | /* run main task of the application */ | 841 | /* run main task of the application */ |
830 | GNUNET_SCHEDULER_add_continuation (ml->main_task, ml, | 842 | GNUNET_SCHEDULER_add_continuation (ml->main_task, ml, |
831 | GNUNET_SCHEDULER_REASON_STARTUP); | 843 | GNUNET_SCHEDULER_REASON_STARTUP); |
832 | 844 | ||
833 | /* start the Gtk event loop */ | 845 | /* start the Gtk event loop */ |
834 | GNUNET_assert (TRUE == g_main_context_acquire (ml->gmc)); | 846 | GNUNET_assert (TRUE == g_main_context_acquire (ml->gmc)); |
835 | GNUNET_SCHEDULER_set_select (&gnunet_gtk_select, ml); | 847 | GNUNET_SCHEDULER_set_select (&gnunet_gtk_select, ml); |
836 | 848 | ||
837 | /* keep Gtk event loop running even if there are no GNUnet tasks */ | 849 | /* keep Gtk event loop running even if there are no GNUnet tasks */ |
838 | ml->dummy_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 850 | ml->dummy_task = |
839 | &keepalive_task, | 851 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
840 | ml); | 852 | &keepalive_task, ml); |
841 | 853 | ||
842 | } | 854 | } |
843 | 855 | ||
@@ -855,13 +867,11 @@ run_main_loop (void *cls, | |||
855 | * @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. bad command-line options, etc) | 867 | * @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. bad command-line options, etc) |
856 | */ | 868 | */ |
857 | int | 869 | int |
858 | GNUNET_GTK_main_loop_start (const char *binary_name, | 870 | GNUNET_GTK_main_loop_start (const char *binary_name, const char *binary_help, |
859 | const char *binary_help, | 871 | int argc, char *const *argv, |
860 | int argc, | 872 | struct GNUNET_GETOPT_CommandLineOption *options, |
861 | char *const*argv, | 873 | const char *main_window_file, |
862 | struct GNUNET_GETOPT_CommandLineOption *options, | 874 | GNUNET_SCHEDULER_Task main_task) |
863 | const char *main_window_file, | ||
864 | GNUNET_SCHEDULER_Task main_task) | ||
865 | { | 875 | { |
866 | struct GNUNET_GTK_MainLoop ml; | 876 | struct GNUNET_GTK_MainLoop ml; |
867 | int ret; | 877 | int ret; |
@@ -869,11 +879,9 @@ GNUNET_GTK_main_loop_start (const char *binary_name, | |||
869 | memset (&ml, 0, sizeof (ml)); | 879 | memset (&ml, 0, sizeof (ml)); |
870 | ml.main_window_file = main_window_file; | 880 | ml.main_window_file = main_window_file; |
871 | ml.main_task = main_task; | 881 | ml.main_task = main_task; |
872 | ret = GNUNET_PROGRAM_run (argc, argv, | 882 | ret = |
873 | binary_name, | 883 | GNUNET_PROGRAM_run (argc, argv, binary_name, "GTK GUI for GNUnet", |
874 | "GTK GUI for GNUnet", | 884 | options, &run_main_loop, &ml); |
875 | options, | ||
876 | &run_main_loop, &ml); | ||
877 | if (NULL != ml.cached_poll_array) | 885 | if (NULL != ml.cached_poll_array) |
878 | g_free (ml.cached_poll_array); | 886 | g_free (ml.cached_poll_array); |
879 | if (NULL != ml.rs) | 887 | if (NULL != ml.rs) |
diff --git a/src/lib/glade.c b/src/lib/glade.c index 3853ea93..b230bd1c 100644 --- a/src/lib/glade.c +++ b/src/lib/glade.c | |||
@@ -74,21 +74,16 @@ GNUNET_GTK_get_new_builder (const char *filename) | |||
74 | 74 | ||
75 | ret = gtk_builder_new (); | 75 | ret = gtk_builder_new (); |
76 | gtk_builder_set_translation_domain (ret, "gnunet-gtk"); | 76 | gtk_builder_set_translation_domain (ret, "gnunet-gtk"); |
77 | GNUNET_asprintf (&glade_path, | 77 | GNUNET_asprintf (&glade_path, "%s%s", GNUNET_GTK_get_data_dir (), filename); |
78 | "%s%s", | ||
79 | GNUNET_GTK_get_data_dir (), | ||
80 | filename); | ||
81 | error = NULL; | 78 | error = NULL; |
82 | if (0 == gtk_builder_add_from_file (ret, glade_path, &error)) | 79 | if (0 == gtk_builder_add_from_file (ret, glade_path, &error)) |
83 | { | 80 | { |
84 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 81 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to load `%s': %s\n"), |
85 | _("Failed to load `%s': %s\n"), | 82 | glade_path, error->message); |
86 | glade_path, | 83 | g_error_free (error); |
87 | error->message); | 84 | GNUNET_free (glade_path); |
88 | g_error_free (error); | 85 | return NULL; |
89 | GNUNET_free (glade_path); | 86 | } |
90 | return NULL; | ||
91 | } | ||
92 | gtk_builder_connect_signals (ret, NULL); | 87 | gtk_builder_connect_signals (ret, NULL); |
93 | GNUNET_free (glade_path); | 88 | GNUNET_free (glade_path); |
94 | return ret; | 89 | return ret; |
diff --git a/src/lib/nls.c b/src/lib/nls.c index 96e44a99..a040f8e5 100644 --- a/src/lib/nls.c +++ b/src/lib/nls.c | |||
@@ -40,10 +40,8 @@ GNUNET_GTK_setup_nls () | |||
40 | char *path; | 40 | char *path; |
41 | 41 | ||
42 | setlocale (LC_ALL, ""); | 42 | setlocale (LC_ALL, ""); |
43 | GNUNET_asprintf (&path, | 43 | GNUNET_asprintf (&path, "%s/%s/locale/", GNUNET_GTK_get_data_dir (), |
44 | "%s/%s/locale/", | 44 | PACKAGE_NAME); |
45 | GNUNET_GTK_get_data_dir (), | ||
46 | PACKAGE_NAME); | ||
47 | bindtextdomain ("gnunet-gtk", path); | 45 | bindtextdomain ("gnunet-gtk", path); |
48 | textdomain ("gnunet-gtk"); | 46 | textdomain ("gnunet-gtk"); |
49 | bind_textdomain_codeset ("GNUnet", "UTF-8"); | 47 | bind_textdomain_codeset ("GNUnet", "UTF-8"); |
@@ -51,7 +49,7 @@ GNUNET_GTK_setup_nls () | |||
51 | GNUNET_free (path); | 49 | GNUNET_free (path); |
52 | #else | 50 | #else |
53 | fprintf (stderr, | 51 | fprintf (stderr, |
54 | "WARNING: gnunet-gtk was compiled without i18n support (did CFLAGS contain -Werror?).\n"); | 52 | "WARNING: gnunet-gtk was compiled without i18n support (did CFLAGS contain -Werror?).\n"); |
55 | #endif | 53 | #endif |
56 | } | 54 | } |
57 | 55 | ||
diff --git a/src/lib/os_installation.c b/src/lib/os_installation.c index 9a884f27..b6927874 100644 --- a/src/lib/os_installation.c +++ b/src/lib/os_installation.c | |||
@@ -50,25 +50,21 @@ get_path_from_proc_maps () | |||
50 | FILE *f; | 50 | FILE *f; |
51 | char *lgu; | 51 | char *lgu; |
52 | 52 | ||
53 | GNUNET_snprintf (fn, | 53 | GNUNET_snprintf (fn, sizeof (fn), "/proc/%u/maps", getpid ()); |
54 | sizeof(fn), | ||
55 | "/proc/%u/maps", | ||
56 | getpid ()); | ||
57 | f = fopen (fn, "r"); | 54 | f = fopen (fn, "r"); |
58 | if (f == NULL) | 55 | if (f == NULL) |
59 | return NULL; | 56 | return NULL; |
60 | while (NULL != fgets (line, sizeof(line), f)) | 57 | while (NULL != fgets (line, sizeof (line), f)) |
58 | { | ||
59 | if ((1 == | ||
60 | sscanf (line, "%*x-%*x %*c%*c%*c%*c %*x %*2u:%*2u %*u%*[ ]%s", dir)) && | ||
61 | (NULL != (lgu = strstr (dir, "gnunet-gtk")))) | ||
61 | { | 62 | { |
62 | if ((1 == sscanf (line, | 63 | lgu[0] = '\0'; |
63 | "%*x-%*x %*c%*c%*c%*c %*x %*2u:%*2u %*u%*[ ]%s", | 64 | fclose (f); |
64 | dir)) && | 65 | return GNUNET_strdup (dir); |
65 | (NULL != (lgu = strstr (dir, "gnunet-gtk")))) | ||
66 | { | ||
67 | lgu[0] = '\0'; | ||
68 | fclose (f); | ||
69 | return GNUNET_strdup (dir); | ||
70 | } | ||
71 | } | 66 | } |
67 | } | ||
72 | fclose (f); | 68 | fclose (f); |
73 | return NULL; | 69 | return NULL; |
74 | } | 70 | } |
@@ -83,23 +79,22 @@ get_path_from_proc_exe () | |||
83 | char lnk[1024]; | 79 | char lnk[1024]; |
84 | ssize_t size; | 80 | ssize_t size; |
85 | 81 | ||
86 | GNUNET_snprintf (fn, | 82 | GNUNET_snprintf (fn, sizeof (fn), "/proc/%u/exe", getpid ()); |
87 | sizeof(fn), "/proc/%u/exe", getpid ()); | 83 | size = readlink (fn, lnk, sizeof (lnk) - 1); |
88 | size = readlink (fn, lnk, sizeof (lnk)-1); | ||
89 | if (size <= 0) | 84 | if (size <= 0) |
90 | { | 85 | { |
91 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "readlink", fn); | 86 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "readlink", fn); |
92 | return NULL; | 87 | return NULL; |
93 | } | 88 | } |
94 | GNUNET_assert (size < sizeof (lnk)); | 89 | GNUNET_assert (size < sizeof (lnk)); |
95 | lnk[size] = '\0'; | 90 | lnk[size] = '\0'; |
96 | while ((lnk[size] != '/') && (size > 0)) | 91 | while ((lnk[size] != '/') && (size > 0)) |
97 | size--; | 92 | size--; |
98 | if ((size < 4) || (lnk[size - 4] != '/')) | 93 | if ((size < 4) || (lnk[size - 4] != '/')) |
99 | { | 94 | { |
100 | /* not installed in "/bin/" -- binary path probably useless */ | 95 | /* not installed in "/bin/" -- binary path probably useless */ |
101 | return NULL; | 96 | return NULL; |
102 | } | 97 | } |
103 | lnk[size] = '\0'; | 98 | lnk[size] = '\0'; |
104 | return GNUNET_strdup (lnk); | 99 | return GNUNET_strdup (lnk); |
105 | } | 100 | } |
@@ -115,7 +110,7 @@ get_path_from_module_filename () | |||
115 | char path[4097]; | 110 | char path[4097]; |
116 | char *idx; | 111 | char *idx; |
117 | 112 | ||
118 | GetModuleFileName (NULL, path, sizeof(path)-1); | 113 | GetModuleFileName (NULL, path, sizeof (path) - 1); |
119 | idx = path + strlen (path); | 114 | idx = path + strlen (path); |
120 | while ((idx > path) && (*idx != '\\') && (*idx != '/')) | 115 | while ((idx > path) && (*idx != '\\') && (*idx != '/')) |
121 | idx--; | 116 | idx--; |
@@ -138,7 +133,7 @@ get_path_from_NSGetExecutablePath () | |||
138 | 133 | ||
139 | path = NULL; | 134 | path = NULL; |
140 | func = | 135 | func = |
141 | (MyNSGetExecutablePathProto) dlsym (RTLD_DEFAULT, "_NSGetExecutablePath"); | 136 | (MyNSGetExecutablePathProto) dlsym (RTLD_DEFAULT, "_NSGetExecutablePath"); |
142 | if (!func) | 137 | if (!func) |
143 | return NULL; | 138 | return NULL; |
144 | path = &zero; | 139 | path = &zero; |
@@ -150,10 +145,10 @@ get_path_from_NSGetExecutablePath () | |||
150 | path = GNUNET_malloc (len); | 145 | path = GNUNET_malloc (len); |
151 | ret = func (path, &len); | 146 | ret = func (path, &len); |
152 | if (ret != 0) | 147 | if (ret != 0) |
153 | { | 148 | { |
154 | GNUNET_free (path); | 149 | GNUNET_free (path); |
155 | return NULL; | 150 | return NULL; |
156 | } | 151 | } |
157 | len = strlen (path); | 152 | len = strlen (path); |
158 | while ((path[len] != '/') && (len > 0)) | 153 | while ((path[len] != '/') && (len > 0)) |
159 | len--; | 154 | len--; |
@@ -172,22 +167,22 @@ get_path_from_dyld_image () | |||
172 | p = NULL; | 167 | p = NULL; |
173 | c = _dyld_image_count (); | 168 | c = _dyld_image_count (); |
174 | for (i = 0; i < c; i++) | 169 | for (i = 0; i < c; i++) |
170 | { | ||
171 | if (_dyld_get_image_header (i) == &_mh_dylib_header) | ||
175 | { | 172 | { |
176 | if (_dyld_get_image_header (i) == &_mh_dylib_header) | 173 | path = _dyld_get_image_name (i); |
177 | { | 174 | if (path != NULL && strlen (path) > 0) |
178 | path = _dyld_get_image_name (i); | 175 | { |
179 | if (path != NULL && strlen (path) > 0) | 176 | p = strdup (path); |
180 | { | 177 | s = p + strlen (p); |
181 | p = strdup (path); | 178 | while ((s > p) && (*s != '/')) |
182 | s = p + strlen (p); | 179 | s--; |
183 | while ((s > p) && (*s != '/')) | 180 | s++; |
184 | s--; | 181 | *s = '\0'; |
185 | s++; | 182 | } |
186 | *s = '\0'; | 183 | break; |
187 | } | ||
188 | break; | ||
189 | } | ||
190 | } | 184 | } |
185 | } | ||
191 | return p; | 186 | return p; |
192 | } | 187 | } |
193 | #endif | 188 | #endif |
@@ -209,26 +204,26 @@ get_path_from_PATH () | |||
209 | pos = path; | 204 | pos = path; |
210 | 205 | ||
211 | while (NULL != (end = strchr (pos, ':'))) | 206 | while (NULL != (end = strchr (pos, ':'))) |
212 | { | 207 | { |
213 | *end = '\0'; | 208 | *end = '\0'; |
214 | sprintf (buf, "%s/%s", pos, "gnunet-gtk"); | 209 | sprintf (buf, "%s/%s", pos, "gnunet-gtk"); |
215 | if (GNUNET_DISK_file_test (buf) == GNUNET_YES) | 210 | if (GNUNET_DISK_file_test (buf) == GNUNET_YES) |
216 | { | ||
217 | pos = GNUNET_strdup (pos); | ||
218 | GNUNET_free (buf); | ||
219 | GNUNET_free (path); | ||
220 | return pos; | ||
221 | } | ||
222 | pos = end + 1; | ||
223 | } | ||
224 | sprintf (buf, "%s/%s", pos, "gnunet-gtk"); | ||
225 | if (GNUNET_DISK_file_test (buf) == GNUNET_YES) | ||
226 | { | 211 | { |
227 | pos = GNUNET_strdup (pos); | 212 | pos = GNUNET_strdup (pos); |
228 | GNUNET_free (buf); | 213 | GNUNET_free (buf); |
229 | GNUNET_free (path); | 214 | GNUNET_free (path); |
230 | return pos; | 215 | return pos; |
231 | } | 216 | } |
217 | pos = end + 1; | ||
218 | } | ||
219 | sprintf (buf, "%s/%s", pos, "gnunet-gtk"); | ||
220 | if (GNUNET_DISK_file_test (buf) == GNUNET_YES) | ||
221 | { | ||
222 | pos = GNUNET_strdup (pos); | ||
223 | GNUNET_free (buf); | ||
224 | GNUNET_free (path); | ||
225 | return pos; | ||
226 | } | ||
232 | GNUNET_free (buf); | 227 | GNUNET_free (buf); |
233 | GNUNET_free (path); | 228 | GNUNET_free (path); |
234 | return NULL; | 229 | return NULL; |
@@ -290,8 +285,7 @@ os_get_gnunet_path () | |||
290 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 285 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
291 | _ | 286 | _ |
292 | ("Could not determine installation path for %s. Set `%s' environment variable.\n"), | 287 | ("Could not determine installation path for %s. Set `%s' environment variable.\n"), |
293 | "gnunet-gtk", | 288 | "gnunet-gtk", "GNUNET_GTK_PREFIX"); |
294 | "GNUNET_GTK_PREFIX"); | ||
295 | return NULL; | 289 | return NULL; |
296 | } | 290 | } |
297 | 291 | ||
@@ -357,11 +351,11 @@ GNUNET_GTK_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind) | |||
357 | 351 | ||
358 | n = strlen (execpath); | 352 | n = strlen (execpath); |
359 | if (n == 0) | 353 | if (n == 0) |
360 | { | 354 | { |
361 | /* should never happen, but better safe than sorry */ | 355 | /* should never happen, but better safe than sorry */ |
362 | GNUNET_free (execpath); | 356 | GNUNET_free (execpath); |
363 | return NULL; | 357 | return NULL; |
364 | } | 358 | } |
365 | /* remove filename itself */ | 359 | /* remove filename itself */ |
366 | while ((n > 1) && (execpath[n - 1] == DIR_SEPARATOR)) | 360 | while ((n > 1) && (execpath[n - 1] == DIR_SEPARATOR)) |
367 | execpath[--n] = '\0'; | 361 | execpath[--n] = '\0'; |
@@ -370,62 +364,61 @@ GNUNET_GTK_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind) | |||
370 | if ((n > 5) && | 364 | if ((n > 5) && |
371 | ((0 == strcasecmp (&execpath[n - 5], "lib32")) || | 365 | ((0 == strcasecmp (&execpath[n - 5], "lib32")) || |
372 | (0 == strcasecmp (&execpath[n - 5], "lib64")))) | 366 | (0 == strcasecmp (&execpath[n - 5], "lib64")))) |
367 | { | ||
368 | if (dirkind != GNUNET_OS_IPK_LIBDIR) | ||
373 | { | 369 | { |
374 | if (dirkind != GNUNET_OS_IPK_LIBDIR) | 370 | /* strip '/lib32' or '/lib64' */ |
375 | { | 371 | execpath[n - 5] = '\0'; |
376 | /* strip '/lib32' or '/lib64' */ | 372 | n -= 5; |
377 | execpath[n - 5] = '\0'; | ||
378 | n -= 5; | ||
379 | } | ||
380 | else | ||
381 | isbasedir = 0; | ||
382 | } | 373 | } |
374 | else | ||
375 | isbasedir = 0; | ||
376 | } | ||
383 | else if ((n > 3) && | 377 | else if ((n > 3) && |
384 | ((0 == strcasecmp (&execpath[n - 3], "bin")) || | 378 | ((0 == strcasecmp (&execpath[n - 3], "bin")) || |
385 | (0 == strcasecmp (&execpath[n - 3], "lib")))) | 379 | (0 == strcasecmp (&execpath[n - 3], "lib")))) |
386 | { | 380 | { |
387 | /* strip '/bin' or '/lib' */ | 381 | /* strip '/bin' or '/lib' */ |
388 | execpath[n - 3] = '\0'; | 382 | execpath[n - 3] = '\0'; |
389 | n -= 3; | 383 | n -= 3; |
390 | } | 384 | } |
391 | /* in case this was a directory named foo-bin, remove "foo-" */ | 385 | /* in case this was a directory named foo-bin, remove "foo-" */ |
392 | while ((n > 1) && (execpath[n - 1] == DIR_SEPARATOR)) | 386 | while ((n > 1) && (execpath[n - 1] == DIR_SEPARATOR)) |
393 | execpath[--n] = '\0'; | 387 | execpath[--n] = '\0'; |
394 | switch (dirkind) | 388 | switch (dirkind) |
395 | { | 389 | { |
396 | case GNUNET_OS_IPK_PREFIX: | 390 | case GNUNET_OS_IPK_PREFIX: |
397 | case GNUNET_OS_IPK_SELF_PREFIX: | 391 | case GNUNET_OS_IPK_SELF_PREFIX: |
398 | dirname = DIR_SEPARATOR_STR; | 392 | dirname = DIR_SEPARATOR_STR; |
399 | break; | 393 | break; |
400 | case GNUNET_OS_IPK_BINDIR: | 394 | case GNUNET_OS_IPK_BINDIR: |
401 | dirname = DIR_SEPARATOR_STR "bin" DIR_SEPARATOR_STR; | 395 | dirname = DIR_SEPARATOR_STR "bin" DIR_SEPARATOR_STR; |
402 | break; | 396 | break; |
403 | case GNUNET_OS_IPK_LIBDIR: | 397 | case GNUNET_OS_IPK_LIBDIR: |
404 | if (isbasedir) | 398 | if (isbasedir) |
405 | dirname = | 399 | dirname = |
406 | DIR_SEPARATOR_STR "lib" DIR_SEPARATOR_STR "gnunet-gtk" | 400 | DIR_SEPARATOR_STR "lib" DIR_SEPARATOR_STR "gnunet-gtk" |
407 | DIR_SEPARATOR_STR; | 401 | DIR_SEPARATOR_STR; |
408 | else | 402 | else |
409 | dirname = DIR_SEPARATOR_STR "gnunet-gtk" DIR_SEPARATOR_STR; | 403 | dirname = DIR_SEPARATOR_STR "gnunet-gtk" DIR_SEPARATOR_STR; |
410 | break; | 404 | break; |
411 | case GNUNET_OS_IPK_DATADIR: | 405 | case GNUNET_OS_IPK_DATADIR: |
412 | dirname = | 406 | dirname = |
413 | DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR "gnunet-gtk" | 407 | DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR "gnunet-gtk" |
414 | DIR_SEPARATOR_STR; | 408 | DIR_SEPARATOR_STR; |
415 | break; | 409 | break; |
416 | case GNUNET_OS_IPK_ICONDIR: | 410 | case GNUNET_OS_IPK_ICONDIR: |
417 | dirname = | 411 | dirname = |
418 | DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR "icons" DIR_SEPARATOR_STR; | 412 | DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR "icons" DIR_SEPARATOR_STR; |
419 | break; | 413 | break; |
420 | case GNUNET_OS_IPK_LOCALEDIR: | 414 | case GNUNET_OS_IPK_LOCALEDIR: |
421 | dirname = | 415 | dirname = |
422 | DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR "locale" | 416 | DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR "locale" DIR_SEPARATOR_STR; |
423 | DIR_SEPARATOR_STR; | 417 | break; |
424 | break; | 418 | default: |
425 | default: | 419 | GNUNET_free (execpath); |
426 | GNUNET_free (execpath); | 420 | return NULL; |
427 | return NULL; | 421 | } |
428 | } | ||
429 | tmp = GNUNET_malloc (strlen (execpath) + strlen (dirname) + 1); | 422 | tmp = GNUNET_malloc (strlen (execpath) + strlen (dirname) + 1); |
430 | sprintf (tmp, "%s%s", execpath, dirname); | 423 | sprintf (tmp, "%s%s", execpath, dirname); |
431 | GNUNET_free (execpath); | 424 | GNUNET_free (execpath); |
diff --git a/src/lib/trayicon.c b/src/lib/trayicon.c index 200c9068..899f6db0 100644 --- a/src/lib/trayicon.c +++ b/src/lib/trayicon.c | |||
@@ -42,9 +42,8 @@ static GtkWindow *main_window; | |||
42 | * We got a click on our tray icon. Toggle visibility of the main | 42 | * We got a click on our tray icon. Toggle visibility of the main |
43 | * window. | 43 | * window. |
44 | */ | 44 | */ |
45 | static void | 45 | static void |
46 | tray_icon_on_click(GtkStatusIcon *status_icon, | 46 | tray_icon_on_click (GtkStatusIcon * status_icon, gpointer user_data) |
47 | gpointer user_data) | ||
48 | { | 47 | { |
49 | if (gtk_window_is_active (main_window)) | 48 | if (gtk_window_is_active (main_window)) |
50 | gtk_widget_hide (GTK_WIDGET (main_window)); | 49 | gtk_widget_hide (GTK_WIDGET (main_window)); |
@@ -57,28 +56,27 @@ tray_icon_on_click(GtkStatusIcon *status_icon, | |||
57 | * We got a right-click on the tray icon. Display the context | 56 | * We got a right-click on the tray icon. Display the context |
58 | * menu (which should have a 'quit' button). | 57 | * menu (which should have a 'quit' button). |
59 | */ | 58 | */ |
60 | static int | 59 | static int |
61 | tray_icon_on_menu(GtkWidget *widget, | 60 | tray_icon_on_menu (GtkWidget * widget, GdkEvent * event, gpointer user_data) |
62 | GdkEvent *event, | ||
63 | gpointer user_data) | ||
64 | { | 61 | { |
65 | GtkMenu *tray_menu; | 62 | GtkMenu *tray_menu; |
66 | GdkEventButton *event_button; | 63 | GdkEventButton *event_button; |
67 | GtkBuilder *builder; | 64 | GtkBuilder *builder; |
68 | 65 | ||
69 | if (event->type == GDK_BUTTON_PRESS) | 66 | if (event->type == GDK_BUTTON_PRESS) |
67 | { | ||
68 | event_button = (GdkEventButton *) event; | ||
69 | if (event_button->button == 3) | ||
70 | { | 70 | { |
71 | event_button = (GdkEventButton *) event; | 71 | builder = GNUNET_GTK_get_new_builder ("gnunet_gtk_status_bar_menu.glade"); |
72 | if (event_button->button == 3) | 72 | tray_menu = |
73 | { | 73 | GTK_MENU (gtk_builder_get_object |
74 | builder = GNUNET_GTK_get_new_builder ("gnunet_gtk_status_bar_menu.glade"); | 74 | (builder, "GNUNET_GTK_status_bar_popup_menu")); |
75 | tray_menu = GTK_MENU (gtk_builder_get_object (builder, | 75 | gtk_menu_popup (tray_menu, NULL, NULL, NULL, NULL, event_button->button, |
76 | "GNUNET_GTK_status_bar_popup_menu")); | 76 | event_button->time); |
77 | gtk_menu_popup (tray_menu, NULL, NULL, NULL, NULL, | 77 | g_object_unref (builder); |
78 | event_button->button, event_button->time); | ||
79 | g_object_unref (builder); | ||
80 | } | ||
81 | } | 78 | } |
79 | } | ||
82 | return FALSE; | 80 | return FALSE; |
83 | } | 81 | } |
84 | 82 | ||
@@ -91,35 +89,30 @@ tray_icon_on_menu(GtkWidget *widget, | |||
91 | * @param tooltip tooltip for the tray icon | 89 | * @param tooltip tooltip for the tray icon |
92 | */ | 90 | */ |
93 | void | 91 | void |
94 | GNUNET_GTK_tray_icon_create (GtkWindow *main, | 92 | GNUNET_GTK_tray_icon_create (GtkWindow * main, const char *icon_name, |
95 | const char *icon_name, | 93 | const char *tooltip) |
96 | const char *tooltip) | ||
97 | { | 94 | { |
98 | if (NULL != tray_icon) | 95 | if (NULL != tray_icon) |
99 | { | 96 | { |
100 | GNUNET_break (0); | 97 | GNUNET_break (0); |
101 | return; | 98 | return; |
102 | } | 99 | } |
103 | main_window = main; | 100 | main_window = main; |
104 | tray_icon = gtk_status_icon_new(); | 101 | tray_icon = gtk_status_icon_new (); |
105 | g_signal_connect(G_OBJECT(tray_icon), "activate", | 102 | g_signal_connect (G_OBJECT (tray_icon), "activate", |
106 | G_CALLBACK(tray_icon_on_click), NULL); | 103 | G_CALLBACK (tray_icon_on_click), NULL); |
107 | g_signal_connect (G_OBJECT(tray_icon), | 104 | g_signal_connect (G_OBJECT (tray_icon), "button_press_event", |
108 | "button_press_event", | 105 | G_CALLBACK (tray_icon_on_menu), tray_icon); |
109 | G_CALLBACK(tray_icon_on_menu), | 106 | gtk_status_icon_set_from_icon_name (tray_icon, icon_name); |
110 | tray_icon); | 107 | gtk_status_icon_set_tooltip (tray_icon, tooltip); |
111 | gtk_status_icon_set_from_icon_name (tray_icon, | 108 | gtk_status_icon_set_visible (tray_icon, TRUE); |
112 | icon_name); | ||
113 | gtk_status_icon_set_tooltip(tray_icon, | ||
114 | tooltip); | ||
115 | gtk_status_icon_set_visible(tray_icon, TRUE); | ||
116 | } | 109 | } |
117 | 110 | ||
118 | 111 | ||
119 | /** | 112 | /** |
120 | * Destroy the tray icon. | 113 | * Destroy the tray icon. |
121 | */ | 114 | */ |
122 | void | 115 | void |
123 | GNUNET_GTK_tray_icon_destroy () | 116 | GNUNET_GTK_tray_icon_destroy () |
124 | { | 117 | { |
125 | if (tray_icon == NULL) | 118 | if (tray_icon == NULL) |
diff --git a/src/peerinfo/gnunet-peerinfo-gtk.c b/src/peerinfo/gnunet-peerinfo-gtk.c index 75c664fc..32b0b92c 100644 --- a/src/peerinfo/gnunet-peerinfo-gtk.c +++ b/src/peerinfo/gnunet-peerinfo-gtk.c | |||
@@ -1,11 +1,11 @@ | |||
1 | mc->pnc = GNUNET_PEERINFO_notify (cfg, | 1 | mc->pnc = GNUNET_PEERINFO_notify (cfg, &GNUNET_GTK_peerinfo_processor, NULL); |
2 | &GNUNET_GTK_peerinfo_processor, | 2 | if (mc->pnc == NULL) |
3 | NULL); | 3 | { |
4 | if (mc->pnc == NULL) | 4 | gtk_widget_hide (GTK_WIDGET |
5 | { | 5 | (gtk_builder_get_object |
6 | gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (mc->builder, | 6 | (mc->builder, "GNUNET_GTK_main_window_peerinfo_treeview"))); |
7 | "GNUNET_GTK_main_window_peerinfo_treeview"))); | 7 | gtk_widget_hide (GTK_WIDGET |
8 | gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (mc->builder, | 8 | (gtk_builder_get_object |
9 | "GNUNET_GTK_main_menu_view_neighbours"))); | 9 | (mc->builder, "GNUNET_GTK_main_menu_view_neighbours"))); |
10 | /* FIXME: set warning in status bar... */ | 10 | /* FIXME: set warning in status bar... */ |
11 | } | 11 | } |
diff --git a/src/peerinfo/peerinfo.c b/src/peerinfo/peerinfo.c index 192f0458..17ef9504 100644 --- a/src/peerinfo/peerinfo.c +++ b/src/peerinfo/peerinfo.c | |||
@@ -35,9 +35,9 @@ | |||
35 | */ | 35 | */ |
36 | void | 36 | void |
37 | GNUNET_GTK_peerinfo_processor (void *cls, | 37 | GNUNET_GTK_peerinfo_processor (void *cls, |
38 | const struct GNUNET_PeerIdentity * peer, | 38 | const struct GNUNET_PeerIdentity *peer, |
39 | const struct GNUNET_HELLO_Message * hello, | 39 | const struct GNUNET_HELLO_Message *hello, |
40 | const char * err_msg) | 40 | const char *err_msg) |
41 | { | 41 | { |
42 | GtkListStore *ls; | 42 | GtkListStore *ls; |
43 | GtkTreeModel *tm; | 43 | GtkTreeModel *tm; |
@@ -47,44 +47,38 @@ GNUNET_GTK_peerinfo_processor (void *cls, | |||
47 | const char *npid; | 47 | const char *npid; |
48 | struct GNUNET_CRYPTO_HashAsciiEncoded enc; | 48 | struct GNUNET_CRYPTO_HashAsciiEncoded enc; |
49 | 49 | ||
50 | GNUNET_CRYPTO_hash_to_enc (&peer->hashPubKey, | 50 | GNUNET_CRYPTO_hash_to_enc (&peer->hashPubKey, &enc); |
51 | &enc); | 51 | npid = (const char *) &enc; |
52 | npid = (const char*) &enc; | 52 | ls = GTK_LIST_STORE (GNUNET_GTK_get_main_window_object |
53 | ls = GTK_LIST_STORE (GNUNET_GTK_get_main_window_object ("GNUNET_GTK_peer_info_list_store")); | 53 | ("GNUNET_GTK_peer_info_list_store")); |
54 | tm = GTK_TREE_MODEL (ls); | 54 | tm = GTK_TREE_MODEL (ls); |
55 | found = GNUNET_NO; | 55 | found = GNUNET_NO; |
56 | if (TRUE == gtk_tree_model_get_iter_first (tm, &iter)) | 56 | if (TRUE == gtk_tree_model_get_iter_first (tm, &iter)) |
57 | { | ||
58 | do | ||
57 | { | 59 | { |
58 | do | 60 | pid = NULL; |
61 | gtk_tree_model_get (tm, &iter, 0, &pid, -1); | ||
62 | if (pid != NULL) | ||
63 | { | ||
64 | if (0 == strcmp (pid, npid)) | ||
59 | { | 65 | { |
60 | pid = NULL; | 66 | found = GNUNET_YES; |
61 | gtk_tree_model_get (tm, | 67 | g_free (pid); |
62 | &iter, | 68 | break; |
63 | 0, &pid, -1); | ||
64 | if (pid != NULL) | ||
65 | { | ||
66 | if (0 == strcmp (pid, npid)) | ||
67 | { | ||
68 | found = GNUNET_YES; | ||
69 | g_free (pid); | ||
70 | break; | ||
71 | } | ||
72 | } | ||
73 | g_free (pid); | ||
74 | } | 69 | } |
75 | while ( (found == GNUNET_NO) && | 70 | } |
76 | (TRUE == gtk_tree_model_iter_next (tm, | 71 | g_free (pid); |
77 | &iter))); | ||
78 | } | 72 | } |
73 | while ((found == GNUNET_NO) && | ||
74 | (TRUE == gtk_tree_model_iter_next (tm, &iter))); | ||
75 | } | ||
79 | if (found == GNUNET_NO) | 76 | if (found == GNUNET_NO) |
80 | gtk_list_store_append (ls, &iter); | 77 | gtk_list_store_append (ls, &iter); |
81 | gtk_list_store_set (ls, | 78 | gtk_list_store_set (ls, &iter, 0, npid, 1, 0 /* number of known addresses */ , |
82 | &iter, | 79 | 2, "" /* country name */ , |
83 | 0, npid, | 80 | 3, NULL /* country flag */ , |
84 | 1, 0 /* number of known addresses */, | 81 | -1); |
85 | 2, "" /* country name */, | ||
86 | 3, NULL /* country flag */, | ||
87 | -1); | ||
88 | } | 82 | } |
89 | 83 | ||
90 | /* end of peerinfo.c */ | 84 | /* end of peerinfo.c */ |
diff --git a/src/setup/gnunet-setup-datacache-config.c b/src/setup/gnunet-setup-datacache-config.c index f779d8c4..c777f5ff 100644 --- a/src/setup/gnunet-setup-datacache-config.c +++ b/src/setup/gnunet-setup-datacache-config.c | |||
@@ -30,9 +30,7 @@ | |||
30 | * Stub implementation of the 'DeleteNotifyCallback' callback. | 30 | * Stub implementation of the 'DeleteNotifyCallback' callback. |
31 | */ | 31 | */ |
32 | static void | 32 | static void |
33 | dnc_dummy (void *cls, | 33 | dnc_dummy (void *cls, const GNUNET_HashCode * key, size_t size) |
34 | const GNUNET_HashCode *key, | ||
35 | size_t size) | ||
36 | { | 34 | { |
37 | /* do nothing */ | 35 | /* do nothing */ |
38 | } | 36 | } |
@@ -47,13 +45,12 @@ dnc_dummy (void *cls, | |||
47 | static int | 45 | static int |
48 | test_config (const char *name) | 46 | test_config (const char *name) |
49 | { | 47 | { |
50 | struct GNUNET_DATACACHE_PluginEnvironment env = | 48 | struct GNUNET_DATACACHE_PluginEnvironment env = { |
51 | { | 49 | cfg, |
52 | cfg, | 50 | "dhtcache", |
53 | "dhtcache", | 51 | NULL, &dnc_dummy, |
54 | NULL, &dnc_dummy, | 52 | 1024LL |
55 | 1024LL | 53 | }; |
56 | }; | ||
57 | void *ret; | 54 | void *ret; |
58 | 55 | ||
59 | ret = GNUNET_PLUGIN_load (name, &env); | 56 | ret = GNUNET_PLUGIN_load (name, &env); |
@@ -95,41 +92,38 @@ GNUNET_setup_datacache_postgres_invalidate_cb () | |||
95 | 92 | ||
96 | 93 | ||
97 | void | 94 | void |
98 | GNUNET_setup_datacache_mysql_tab_test_button_clicked_cb (GtkWidget *widget, | 95 | GNUNET_setup_datacache_mysql_tab_test_button_clicked_cb (GtkWidget * widget, |
99 | gpointer user_data) | 96 | gpointer user_data) |
100 | { | 97 | { |
101 | if (GNUNET_OK == | 98 | if (GNUNET_OK == test_config ("libgnunet_plugin_datacache_mysql")) |
102 | test_config ("libgnunet_plugin_datacache_mysql")) | 99 | { |
103 | { | 100 | show ("GNUNET_setup_datacache_mysql_tab_ok_image"); |
104 | show ("GNUNET_setup_datacache_mysql_tab_ok_image"); | 101 | hide ("GNUNET_setup_datacache_mysql_tab_error_image"); |
105 | hide ("GNUNET_setup_datacache_mysql_tab_error_image"); | 102 | } |
106 | } | ||
107 | else | 103 | else |
108 | { | 104 | { |
109 | hide ("GNUNET_setup_datacache_mysql_tab_ok_image"); | 105 | hide ("GNUNET_setup_datacache_mysql_tab_ok_image"); |
110 | show ("GNUNET_setup_datacache_mysql_tab_error_image"); | 106 | show ("GNUNET_setup_datacache_mysql_tab_error_image"); |
111 | } | 107 | } |
112 | } | 108 | } |
113 | 109 | ||
114 | 110 | ||
115 | void | 111 | void |
116 | GNUNET_setup_datacache_postgres_tab_test_button_clicked_cb (GtkWidget *widget, | 112 | GNUNET_setup_datacache_postgres_tab_test_button_clicked_cb (GtkWidget * widget, |
117 | gpointer user_data) | 113 | gpointer user_data) |
118 | { | 114 | { |
119 | if (GNUNET_OK == | 115 | if (GNUNET_OK == test_config ("libgnunet_plugin_datacache_postgres")) |
120 | test_config ("libgnunet_plugin_datacache_postgres")) | 116 | { |
121 | { | 117 | show ("GNUNET_setup_datacache_postgres_tab_ok_image"); |
122 | show ("GNUNET_setup_datacache_postgres_tab_ok_image"); | 118 | hide ("GNUNET_setup_datacache_postgres_tab_error_image"); |
123 | hide ("GNUNET_setup_datacache_postgres_tab_error_image"); | 119 | } |
124 | } | ||
125 | else | 120 | else |
126 | { | 121 | { |
127 | hide ("GNUNET_setup_datacache_postgres_tab_ok_image"); | 122 | hide ("GNUNET_setup_datacache_postgres_tab_ok_image"); |
128 | show ("GNUNET_setup_datacache_postgres_tab_error_image"); | 123 | show ("GNUNET_setup_datacache_postgres_tab_error_image"); |
129 | } | 124 | } |
130 | } | 125 | } |
131 | 126 | ||
132 | 127 | ||
133 | 128 | ||
134 | /* end of gnunet-setup-datacache-config.c */ | 129 | /* end of gnunet-setup-datacache-config.c */ |
135 | |||
diff --git a/src/setup/gnunet-setup-datacache-plugins.c b/src/setup/gnunet-setup-datacache-plugins.c index 4e53f6df..022345d3 100644 --- a/src/setup/gnunet-setup-datacache-plugins.c +++ b/src/setup/gnunet-setup-datacache-plugins.c | |||
@@ -34,45 +34,40 @@ | |||
34 | * @param name name of the plugin to check | 34 | * @param name name of the plugin to check |
35 | */ | 35 | */ |
36 | static void | 36 | static void |
37 | test_plugin (GtkWidget *widget, | 37 | test_plugin (GtkWidget * widget, const char *name) |
38 | const char *name) | ||
39 | { | 38 | { |
40 | if (GNUNET_YES == | 39 | if (GNUNET_YES == GNUNET_PLUGIN_test (name)) |
41 | GNUNET_PLUGIN_test (name)) | 40 | { |
42 | { | 41 | gtk_widget_set_sensitive (widget, TRUE); |
43 | gtk_widget_set_sensitive (widget, | 42 | } |
44 | TRUE); | ||
45 | } | ||
46 | else | 43 | else |
47 | { | 44 | { |
48 | gtk_widget_set_sensitive (widget, | 45 | gtk_widget_set_sensitive (widget, FALSE); |
49 | FALSE); | 46 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE); |
50 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), | 47 | } |
51 | FALSE); | ||
52 | } | ||
53 | } | 48 | } |
54 | 49 | ||
55 | 50 | ||
56 | 51 | ||
57 | void | 52 | void |
58 | GNUNET_setup_fs_datacache_sqlite_radiobutton_realize_cb (GtkWidget *widget, | 53 | GNUNET_setup_fs_datacache_sqlite_radiobutton_realize_cb (GtkWidget * widget, |
59 | gpointer user_data) | 54 | gpointer user_data) |
60 | { | 55 | { |
61 | test_plugin (widget, "libgnunet_plugin_datacache_sqlite"); | 56 | test_plugin (widget, "libgnunet_plugin_datacache_sqlite"); |
62 | } | 57 | } |
63 | 58 | ||
64 | 59 | ||
65 | void | 60 | void |
66 | GNUNET_setup_fs_datacache_mysql_radiobutton_realize_cb (GtkWidget *widget, | 61 | GNUNET_setup_fs_datacache_mysql_radiobutton_realize_cb (GtkWidget * widget, |
67 | gpointer user_data) | 62 | gpointer user_data) |
68 | { | 63 | { |
69 | test_plugin (widget, "libgnunet_plugin_datacache_mysql"); | 64 | test_plugin (widget, "libgnunet_plugin_datacache_mysql"); |
70 | } | 65 | } |
71 | 66 | ||
72 | 67 | ||
73 | void | 68 | void |
74 | GNUNET_setup_fs_datacache_postgres_radiobutton_realize_cb (GtkWidget *widget, | 69 | GNUNET_setup_fs_datacache_postgres_radiobutton_realize_cb (GtkWidget * widget, |
75 | gpointer user_data) | 70 | gpointer user_data) |
76 | { | 71 | { |
77 | test_plugin (widget, "libgnunet_plugin_datacache_postgres"); | 72 | test_plugin (widget, "libgnunet_plugin_datacache_postgres"); |
78 | } | 73 | } |
@@ -80,4 +75,3 @@ GNUNET_setup_fs_datacache_postgres_radiobutton_realize_cb (GtkWidget *widget, | |||
80 | 75 | ||
81 | 76 | ||
82 | /* end of gnunet-setup-transport-plugins.c */ | 77 | /* end of gnunet-setup-transport-plugins.c */ |
83 | |||
diff --git a/src/setup/gnunet-setup-datastore-config.c b/src/setup/gnunet-setup-datastore-config.c index 86925418..2c7ede51 100644 --- a/src/setup/gnunet-setup-datastore-config.c +++ b/src/setup/gnunet-setup-datastore-config.c | |||
@@ -45,11 +45,10 @@ duc_dummy (void *cls, int delta) | |||
45 | static int | 45 | static int |
46 | test_config (const char *name) | 46 | test_config (const char *name) |
47 | { | 47 | { |
48 | struct GNUNET_DATASTORE_PluginEnvironment env = | 48 | struct GNUNET_DATASTORE_PluginEnvironment env = { |
49 | { | 49 | cfg, |
50 | cfg, | 50 | &duc_dummy, NULL |
51 | &duc_dummy, NULL | 51 | }; |
52 | }; | ||
53 | void *ret; | 52 | void *ret; |
54 | 53 | ||
55 | ret = GNUNET_PLUGIN_load (name, &env); | 54 | ret = GNUNET_PLUGIN_load (name, &env); |
@@ -91,41 +90,38 @@ GNUNET_setup_datastore_postgres_invalidate_cb () | |||
91 | 90 | ||
92 | 91 | ||
93 | void | 92 | void |
94 | GNUNET_setup_datastore_mysql_tab_test_button_clicked_cb (GtkWidget *widget, | 93 | GNUNET_setup_datastore_mysql_tab_test_button_clicked_cb (GtkWidget * widget, |
95 | gpointer user_data) | 94 | gpointer user_data) |
96 | { | 95 | { |
97 | if (GNUNET_OK == | 96 | if (GNUNET_OK == test_config ("libgnunet_plugin_datastore_mysql")) |
98 | test_config ("libgnunet_plugin_datastore_mysql")) | 97 | { |
99 | { | 98 | show ("GNUNET_setup_datastore_mysql_tab_ok_image"); |
100 | show ("GNUNET_setup_datastore_mysql_tab_ok_image"); | 99 | hide ("GNUNET_setup_datastore_mysql_tab_error_image"); |
101 | hide ("GNUNET_setup_datastore_mysql_tab_error_image"); | 100 | } |
102 | } | ||
103 | else | 101 | else |
104 | { | 102 | { |
105 | hide ("GNUNET_setup_datastore_mysql_tab_ok_image"); | 103 | hide ("GNUNET_setup_datastore_mysql_tab_ok_image"); |
106 | show ("GNUNET_setup_datastore_mysql_tab_error_image"); | 104 | show ("GNUNET_setup_datastore_mysql_tab_error_image"); |
107 | } | 105 | } |
108 | } | 106 | } |
109 | 107 | ||
110 | 108 | ||
111 | void | 109 | void |
112 | GNUNET_setup_datastore_postgres_tab_test_button_clicked_cb (GtkWidget *widget, | 110 | GNUNET_setup_datastore_postgres_tab_test_button_clicked_cb (GtkWidget * widget, |
113 | gpointer user_data) | 111 | gpointer user_data) |
114 | { | 112 | { |
115 | if (GNUNET_OK == | 113 | if (GNUNET_OK == test_config ("libgnunet_plugin_datastore_postgres")) |
116 | test_config ("libgnunet_plugin_datastore_postgres")) | 114 | { |
117 | { | 115 | show ("GNUNET_setup_datastore_postgres_tab_ok_image"); |
118 | show ("GNUNET_setup_datastore_postgres_tab_ok_image"); | 116 | hide ("GNUNET_setup_datastore_postgres_tab_error_image"); |
119 | hide ("GNUNET_setup_datastore_postgres_tab_error_image"); | 117 | } |
120 | } | ||
121 | else | 118 | else |
122 | { | 119 | { |
123 | hide ("GNUNET_setup_datastore_postgres_tab_ok_image"); | 120 | hide ("GNUNET_setup_datastore_postgres_tab_ok_image"); |
124 | show ("GNUNET_setup_datastore_postgres_tab_error_image"); | 121 | show ("GNUNET_setup_datastore_postgres_tab_error_image"); |
125 | } | 122 | } |
126 | } | 123 | } |
127 | 124 | ||
128 | 125 | ||
129 | 126 | ||
130 | /* end of gnunet-setup-datastore-config.c */ | 127 | /* end of gnunet-setup-datastore-config.c */ |
131 | |||
diff --git a/src/setup/gnunet-setup-datastore-plugins.c b/src/setup/gnunet-setup-datastore-plugins.c index e7f448e6..7d55ba1e 100644 --- a/src/setup/gnunet-setup-datastore-plugins.c +++ b/src/setup/gnunet-setup-datastore-plugins.c | |||
@@ -33,44 +33,39 @@ | |||
33 | * @param name name of the plugin to check | 33 | * @param name name of the plugin to check |
34 | */ | 34 | */ |
35 | static void | 35 | static void |
36 | test_plugin (GtkWidget *widget, | 36 | test_plugin (GtkWidget * widget, const char *name) |
37 | const char *name) | ||
38 | { | 37 | { |
39 | if (GNUNET_YES == | 38 | if (GNUNET_YES == GNUNET_PLUGIN_test (name)) |
40 | GNUNET_PLUGIN_test (name)) | 39 | { |
41 | { | 40 | gtk_widget_set_sensitive (widget, TRUE); |
42 | gtk_widget_set_sensitive (widget, | 41 | } |
43 | TRUE); | ||
44 | } | ||
45 | else | 42 | else |
46 | { | 43 | { |
47 | gtk_widget_set_sensitive (widget, | 44 | gtk_widget_set_sensitive (widget, FALSE); |
48 | FALSE); | 45 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE); |
49 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), | 46 | } |
50 | FALSE); | ||
51 | } | ||
52 | } | 47 | } |
53 | 48 | ||
54 | 49 | ||
55 | void | 50 | void |
56 | GNUNET_setup_fs_datastore_sqlite_radiobutton_realize_cb (GtkWidget *widget, | 51 | GNUNET_setup_fs_datastore_sqlite_radiobutton_realize_cb (GtkWidget * widget, |
57 | gpointer user_data) | 52 | gpointer user_data) |
58 | { | 53 | { |
59 | test_plugin (widget, "libgnunet_plugin_datastore_sqlite"); | 54 | test_plugin (widget, "libgnunet_plugin_datastore_sqlite"); |
60 | } | 55 | } |
61 | 56 | ||
62 | 57 | ||
63 | void | 58 | void |
64 | GNUNET_setup_fs_datastore_mysql_radiobutton_realize_cb (GtkWidget *widget, | 59 | GNUNET_setup_fs_datastore_mysql_radiobutton_realize_cb (GtkWidget * widget, |
65 | gpointer user_data) | 60 | gpointer user_data) |
66 | { | 61 | { |
67 | test_plugin (widget, "libgnunet_plugin_datastore_mysql"); | 62 | test_plugin (widget, "libgnunet_plugin_datastore_mysql"); |
68 | } | 63 | } |
69 | 64 | ||
70 | 65 | ||
71 | void | 66 | void |
72 | GNUNET_setup_fs_datastore_postgres_radiobutton_realize_cb (GtkWidget *widget, | 67 | GNUNET_setup_fs_datastore_postgres_radiobutton_realize_cb (GtkWidget * widget, |
73 | gpointer user_data) | 68 | gpointer user_data) |
74 | { | 69 | { |
75 | test_plugin (widget, "libgnunet_plugin_datastore_postgres"); | 70 | test_plugin (widget, "libgnunet_plugin_datastore_postgres"); |
76 | } | 71 | } |
@@ -78,4 +73,3 @@ GNUNET_setup_fs_datastore_postgres_radiobutton_realize_cb (GtkWidget *widget, | |||
78 | 73 | ||
79 | 74 | ||
80 | /* end of gnunet-setup-datastore-plugins.c */ | 75 | /* end of gnunet-setup-datastore-plugins.c */ |
81 | |||
diff --git a/src/setup/gnunet-setup-hostlist-editing.c b/src/setup/gnunet-setup-hostlist-editing.c index 98e6e136..02056b0d 100644 --- a/src/setup/gnunet-setup-hostlist-editing.c +++ b/src/setup/gnunet-setup-hostlist-editing.c | |||
@@ -36,36 +36,31 @@ | |||
36 | * @param user_data not used | 36 | * @param user_data not used |
37 | */ | 37 | */ |
38 | void | 38 | void |
39 | GNUNET_setup_hostlist_url_cellrenderertext_edited_cb (GtkCellRendererText *renderer, | 39 | GNUNET_setup_hostlist_url_cellrenderertext_edited_cb (GtkCellRendererText * |
40 | gchar *path, | 40 | renderer, gchar * path, |
41 | gchar *new_text, | 41 | gchar * new_text, |
42 | gpointer user_data) | 42 | gpointer user_data) |
43 | { | 43 | { |
44 | GtkListStore *ls; | 44 | GtkListStore *ls; |
45 | GtkTreeIter old; | 45 | GtkTreeIter old; |
46 | GtkTreeIter iter; | 46 | GtkTreeIter iter; |
47 | 47 | ||
48 | ls = GTK_LIST_STORE (GNUNET_SETUP_get_object ("GNUNET_setup_hostlist_url_liststore")); | 48 | ls = GTK_LIST_STORE (GNUNET_SETUP_get_object |
49 | ("GNUNET_setup_hostlist_url_liststore")); | ||
49 | if (ls == NULL) | 50 | if (ls == NULL) |
50 | { | 51 | { |
51 | GNUNET_break (0); | 52 | GNUNET_break (0); |
52 | return; | 53 | return; |
53 | } | 54 | } |
54 | if (TRUE != | 55 | if (TRUE != |
55 | gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ls), | 56 | gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ls), &old, path)) |
56 | &old, | 57 | { |
57 | path)) | 58 | GNUNET_break (0); |
58 | { | 59 | return; |
59 | GNUNET_break (0); | 60 | } |
60 | return; | 61 | |
61 | } | ||
62 | |||
63 | gtk_list_store_insert_before (ls, &iter, &old); | 62 | gtk_list_store_insert_before (ls, &iter, &old); |
64 | gtk_list_store_set (ls, | 63 | gtk_list_store_set (ls, &iter, 0, new_text, 1, FALSE, -1); |
65 | &iter, | ||
66 | 0, new_text, | ||
67 | 1, FALSE, | ||
68 | -1); | ||
69 | } | 64 | } |
70 | 65 | ||
71 | /* end of gnunet-setup-hostlist-editing.c */ | 66 | /* end of gnunet-setup-hostlist-editing.c */ |
diff --git a/src/setup/gnunet-setup-options.c b/src/setup/gnunet-setup-options.c index fe896892..d031f46c 100644 --- a/src/setup/gnunet-setup-options.c +++ b/src/setup/gnunet-setup-options.c | |||
@@ -50,12 +50,9 @@ | |||
50 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem | 50 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem |
51 | */ | 51 | */ |
52 | static int | 52 | static int |
53 | load_yes_no (const void *cls, | 53 | load_yes_no (const void *cls, const char *section, const char *option, |
54 | const char *section, | 54 | const char *value, GObject * widget, |
55 | const char *option, | 55 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
56 | const char *value, | ||
57 | GObject *widget, | ||
58 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
59 | { | 56 | { |
60 | GtkToggleButton *button; | 57 | GtkToggleButton *button; |
61 | 58 | ||
@@ -63,7 +60,8 @@ load_yes_no (const void *cls, | |||
63 | if (button == NULL) | 60 | if (button == NULL) |
64 | return GNUNET_SYSERR; | 61 | return GNUNET_SYSERR; |
65 | gtk_toggle_button_set_active (button, | 62 | gtk_toggle_button_set_active (button, |
66 | (0 == strcasecmp (value, "YES")) ? TRUE : FALSE); | 63 | (0 == |
64 | strcasecmp (value, "YES")) ? TRUE : FALSE); | ||
67 | return GNUNET_OK; | 65 | return GNUNET_OK; |
68 | } | 66 | } |
69 | 67 | ||
@@ -79,22 +77,18 @@ load_yes_no (const void *cls, | |||
79 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem | 77 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem |
80 | */ | 78 | */ |
81 | static int | 79 | static int |
82 | save_yes_no (const void *cls, | 80 | save_yes_no (const void *cls, const char *section, const char *option, |
83 | const char *section, | 81 | GObject * widget, struct GNUNET_CONFIGURATION_Handle *cfg) |
84 | const char *option, | ||
85 | GObject *widget, | ||
86 | struct GNUNET_CONFIGURATION_Handle *cfg) | ||
87 | { | 82 | { |
88 | GtkToggleButton *button; | 83 | GtkToggleButton *button; |
89 | gboolean mode; | 84 | gboolean mode; |
90 | 85 | ||
91 | button = GTK_TOGGLE_BUTTON (widget); | 86 | button = GTK_TOGGLE_BUTTON (widget); |
92 | if (button == NULL) | 87 | if (button == NULL) |
93 | return GNUNET_SYSERR; | 88 | return GNUNET_SYSERR; |
94 | mode = gtk_toggle_button_get_active (button); | 89 | mode = gtk_toggle_button_get_active (button); |
95 | GNUNET_CONFIGURATION_set_value_string (cfg, | 90 | GNUNET_CONFIGURATION_set_value_string (cfg, section, option, |
96 | section, option, | 91 | mode == TRUE ? "YES" : "NO"); |
97 | mode == TRUE ? "YES" : "NO"); | ||
98 | return GNUNET_OK; | 92 | return GNUNET_OK; |
99 | } | 93 | } |
100 | 94 | ||
@@ -111,20 +105,16 @@ save_yes_no (const void *cls, | |||
111 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem | 105 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem |
112 | */ | 106 | */ |
113 | static int | 107 | static int |
114 | load_filename (const void *cls, | 108 | load_filename (const void *cls, const char *section, const char *option, |
115 | const char *section, | 109 | const char *value, GObject * widget, |
116 | const char *option, | 110 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
117 | const char *value, | ||
118 | GObject *widget, | ||
119 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
120 | { | 111 | { |
121 | GtkFileChooser *chooser; | 112 | GtkFileChooser *chooser; |
122 | 113 | ||
123 | chooser = GTK_FILE_CHOOSER (widget); | 114 | chooser = GTK_FILE_CHOOSER (widget); |
124 | if (chooser == NULL) | 115 | if (chooser == NULL) |
125 | return GNUNET_SYSERR; | 116 | return GNUNET_SYSERR; |
126 | gtk_file_chooser_set_filename (chooser, | 117 | gtk_file_chooser_set_filename (chooser, value); |
127 | value); | ||
128 | return GNUNET_OK; | 118 | return GNUNET_OK; |
129 | } | 119 | } |
130 | 120 | ||
@@ -140,11 +130,8 @@ load_filename (const void *cls, | |||
140 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem | 130 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem |
141 | */ | 131 | */ |
142 | static int | 132 | static int |
143 | save_filename (const void *cls, | 133 | save_filename (const void *cls, const char *section, const char *option, |
144 | const char *section, | 134 | GObject * widget, struct GNUNET_CONFIGURATION_Handle *cfg) |
145 | const char *option, | ||
146 | GObject *widget, | ||
147 | struct GNUNET_CONFIGURATION_Handle *cfg) | ||
148 | { | 135 | { |
149 | GtkFileChooser *chooser; | 136 | GtkFileChooser *chooser; |
150 | gchar *fn; | 137 | gchar *fn; |
@@ -155,9 +142,7 @@ save_filename (const void *cls, | |||
155 | fn = gtk_file_chooser_get_filename (chooser); | 142 | fn = gtk_file_chooser_get_filename (chooser); |
156 | if (fn == NULL) | 143 | if (fn == NULL) |
157 | fn = g_strdup (""); | 144 | fn = g_strdup (""); |
158 | GNUNET_CONFIGURATION_set_value_string (cfg, | 145 | GNUNET_CONFIGURATION_set_value_string (cfg, section, option, fn); |
159 | section, option, | ||
160 | fn); | ||
161 | g_free (fn); | 146 | g_free (fn); |
162 | return GNUNET_OK; | 147 | return GNUNET_OK; |
163 | } | 148 | } |
@@ -175,20 +160,16 @@ save_filename (const void *cls, | |||
175 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem | 160 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem |
176 | */ | 161 | */ |
177 | static int | 162 | static int |
178 | load_text (const void *cls, | 163 | load_text (const void *cls, const char *section, const char *option, |
179 | const char *section, | 164 | const char *value, GObject * widget, |
180 | const char *option, | 165 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
181 | const char *value, | ||
182 | GObject *widget, | ||
183 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
184 | { | 166 | { |
185 | GtkEntry *entry; | 167 | GtkEntry *entry; |
186 | 168 | ||
187 | entry = GTK_ENTRY (widget); | 169 | entry = GTK_ENTRY (widget); |
188 | if (entry == NULL) | 170 | if (entry == NULL) |
189 | return GNUNET_SYSERR; | 171 | return GNUNET_SYSERR; |
190 | gtk_entry_set_text (entry, | 172 | gtk_entry_set_text (entry, value); |
191 | value); | ||
192 | return GNUNET_OK; | 173 | return GNUNET_OK; |
193 | } | 174 | } |
194 | 175 | ||
@@ -204,11 +185,8 @@ load_text (const void *cls, | |||
204 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem | 185 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem |
205 | */ | 186 | */ |
206 | static int | 187 | static int |
207 | save_text (const void *cls, | 188 | save_text (const void *cls, const char *section, const char *option, |
208 | const char *section, | 189 | GObject * widget, struct GNUNET_CONFIGURATION_Handle *cfg) |
209 | const char *option, | ||
210 | GObject *widget, | ||
211 | struct GNUNET_CONFIGURATION_Handle *cfg) | ||
212 | { | 190 | { |
213 | GtkEntry *entry; | 191 | GtkEntry *entry; |
214 | const gchar *txt; | 192 | const gchar *txt; |
@@ -217,9 +195,7 @@ save_text (const void *cls, | |||
217 | if (entry == NULL) | 195 | if (entry == NULL) |
218 | return GNUNET_SYSERR; | 196 | return GNUNET_SYSERR; |
219 | txt = gtk_entry_get_text (entry); | 197 | txt = gtk_entry_get_text (entry); |
220 | GNUNET_CONFIGURATION_set_value_string (cfg, | 198 | GNUNET_CONFIGURATION_set_value_string (cfg, section, option, txt); |
221 | section, option, | ||
222 | txt); | ||
223 | return GNUNET_OK; | 199 | return GNUNET_OK; |
224 | } | 200 | } |
225 | 201 | ||
@@ -237,12 +213,9 @@ save_text (const void *cls, | |||
237 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem | 213 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem |
238 | */ | 214 | */ |
239 | static int | 215 | static int |
240 | load_combo_text (const void *cls, | 216 | load_combo_text (const void *cls, const char *section, const char *option, |
241 | const char *section, | 217 | const char *value, GObject * widget, |
242 | const char *option, | 218 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
243 | const char *value, | ||
244 | GObject *widget, | ||
245 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
246 | { | 219 | { |
247 | GtkComboBoxText *cb; | 220 | GtkComboBoxText *cb; |
248 | 221 | ||
@@ -265,11 +238,8 @@ load_combo_text (const void *cls, | |||
265 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem | 238 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem |
266 | */ | 239 | */ |
267 | static int | 240 | static int |
268 | save_combo_text (const void *cls, | 241 | save_combo_text (const void *cls, const char *section, const char *option, |
269 | const char *section, | 242 | GObject * widget, struct GNUNET_CONFIGURATION_Handle *cfg) |
270 | const char *option, | ||
271 | GObject *widget, | ||
272 | struct GNUNET_CONFIGURATION_Handle *cfg) | ||
273 | { | 243 | { |
274 | GtkComboBox *cb; | 244 | GtkComboBox *cb; |
275 | gchar *c; | 245 | gchar *c; |
@@ -297,12 +267,9 @@ save_combo_text (const void *cls, | |||
297 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem | 267 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem |
298 | */ | 268 | */ |
299 | static int | 269 | static int |
300 | load_number (const void *cls, | 270 | load_number (const void *cls, const char *section, const char *option, |
301 | const char *section, | 271 | const char *value, GObject * widget, |
302 | const char *option, | 272 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
303 | const char *value, | ||
304 | GObject *widget, | ||
305 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
306 | { | 273 | { |
307 | GtkSpinButton *spin; | 274 | GtkSpinButton *spin; |
308 | unsigned int number; | 275 | unsigned int number; |
@@ -312,8 +279,7 @@ load_number (const void *cls, | |||
312 | return GNUNET_SYSERR; | 279 | return GNUNET_SYSERR; |
313 | if (1 != sscanf (value, "%u", &number)) | 280 | if (1 != sscanf (value, "%u", &number)) |
314 | return GNUNET_SYSERR; | 281 | return GNUNET_SYSERR; |
315 | gtk_spin_button_set_value (spin, | 282 | gtk_spin_button_set_value (spin, number); |
316 | number); | ||
317 | return GNUNET_OK; | 283 | return GNUNET_OK; |
318 | } | 284 | } |
319 | 285 | ||
@@ -329,20 +295,17 @@ load_number (const void *cls, | |||
329 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem | 295 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem |
330 | */ | 296 | */ |
331 | static int | 297 | static int |
332 | save_number (const void *cls, | 298 | save_number (const void *cls, const char *section, const char *option, |
333 | const char *section, | 299 | GObject * widget, struct GNUNET_CONFIGURATION_Handle *cfg) |
334 | const char *option, | ||
335 | GObject *widget, | ||
336 | struct GNUNET_CONFIGURATION_Handle *cfg) | ||
337 | { | 300 | { |
338 | GtkSpinButton *spin; | 301 | GtkSpinButton *spin; |
339 | 302 | ||
340 | spin = GTK_SPIN_BUTTON (widget); | 303 | spin = GTK_SPIN_BUTTON (widget); |
341 | if (spin == NULL) | 304 | if (spin == NULL) |
342 | return GNUNET_SYSERR; | 305 | return GNUNET_SYSERR; |
343 | GNUNET_CONFIGURATION_set_value_number (cfg, | 306 | GNUNET_CONFIGURATION_set_value_number (cfg, section, option, |
344 | section, option, | 307 | gtk_spin_button_get_value_as_int |
345 | gtk_spin_button_get_value_as_int (spin)); | 308 | (spin)); |
346 | return GNUNET_OK; | 309 | return GNUNET_OK; |
347 | } | 310 | } |
348 | 311 | ||
@@ -360,12 +323,9 @@ save_number (const void *cls, | |||
360 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem | 323 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem |
361 | */ | 324 | */ |
362 | static int | 325 | static int |
363 | load_option_list (const void *cls, | 326 | load_option_list (const void *cls, const char *section, const char *option, |
364 | const char *section, | 327 | const char *value, GObject * widget, |
365 | const char *option, | 328 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
366 | const char *value, | ||
367 | GObject *widget, | ||
368 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
369 | { | 329 | { |
370 | const char *word = cls; | 330 | const char *word = cls; |
371 | char *t; | 331 | char *t; |
@@ -380,17 +340,16 @@ load_option_list (const void *cls, | |||
380 | t = GNUNET_strdup (value); | 340 | t = GNUNET_strdup (value); |
381 | w = strtok (t, " "); | 341 | w = strtok (t, " "); |
382 | while (w != NULL) | 342 | while (w != NULL) |
343 | { | ||
344 | if (0 == strcmp (w, word)) | ||
383 | { | 345 | { |
384 | if (0 == strcmp (w, word)) | 346 | found = GNUNET_YES; |
385 | { | 347 | break; |
386 | found = GNUNET_YES; | ||
387 | break; | ||
388 | } | ||
389 | w = strtok (NULL, " "); | ||
390 | } | 348 | } |
349 | w = strtok (NULL, " "); | ||
350 | } | ||
391 | GNUNET_free (t); | 351 | GNUNET_free (t); |
392 | gtk_toggle_button_set_active (button, | 352 | gtk_toggle_button_set_active (button, found); |
393 | found); | ||
394 | return GNUNET_OK; | 353 | return GNUNET_OK; |
395 | } | 354 | } |
396 | 355 | ||
@@ -406,11 +365,8 @@ load_option_list (const void *cls, | |||
406 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem | 365 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem |
407 | */ | 366 | */ |
408 | static int | 367 | static int |
409 | save_option_list (const void *cls, | 368 | save_option_list (const void *cls, const char *section, const char *option, |
410 | const char *section, | 369 | GObject * widget, struct GNUNET_CONFIGURATION_Handle *cfg) |
411 | const char *option, | ||
412 | GObject *widget, | ||
413 | struct GNUNET_CONFIGURATION_Handle *cfg) | ||
414 | { | 370 | { |
415 | const char *word = cls; | 371 | const char *word = cls; |
416 | GtkToggleButton *button; | 372 | GtkToggleButton *button; |
@@ -421,15 +377,9 @@ save_option_list (const void *cls, | |||
421 | return GNUNET_SYSERR; | 377 | return GNUNET_SYSERR; |
422 | mode = gtk_toggle_button_get_active (button); | 378 | mode = gtk_toggle_button_get_active (button); |
423 | if (mode == TRUE) | 379 | if (mode == TRUE) |
424 | GNUNET_CONFIGURATION_append_value_filename (cfg, | 380 | GNUNET_CONFIGURATION_append_value_filename (cfg, section, option, word); |
425 | section, | ||
426 | option, | ||
427 | word); | ||
428 | else | 381 | else |
429 | GNUNET_CONFIGURATION_remove_value_filename (cfg, | 382 | GNUNET_CONFIGURATION_remove_value_filename (cfg, section, option, word); |
430 | section, | ||
431 | option, | ||
432 | word); | ||
433 | return GNUNET_OK; | 383 | return GNUNET_OK; |
434 | } | 384 | } |
435 | 385 | ||
@@ -445,9 +395,8 @@ save_option_list (const void *cls, | |||
445 | * @return TRUE to stop other handlers from being invoked | 395 | * @return TRUE to stop other handlers from being invoked |
446 | */ | 396 | */ |
447 | gboolean | 397 | gboolean |
448 | GNUNET_setup_treeview_key_press_event_cb (GtkTreeView *tv, | 398 | GNUNET_setup_treeview_key_press_event_cb (GtkTreeView * tv, GdkEventKey * event, |
449 | GdkEventKey *event, | 399 | gpointer user_data) |
450 | gpointer user_data) | ||
451 | { | 400 | { |
452 | GtkListStore *ls; | 401 | GtkListStore *ls; |
453 | GtkTreeModel *tm; | 402 | GtkTreeModel *tm; |
@@ -455,25 +404,21 @@ GNUNET_setup_treeview_key_press_event_cb (GtkTreeView *tv, | |||
455 | GtkTreeIter iter; | 404 | GtkTreeIter iter; |
456 | gboolean editable; | 405 | gboolean editable; |
457 | 406 | ||
458 | if ( (event->type != GDK_KEY_PRESS) || | 407 | if ((event->type != GDK_KEY_PRESS) || (event->state != 0) || |
459 | (event->state != 0) || | 408 | (event->keyval != GDK_Delete)) |
460 | (event->keyval != GDK_Delete) ) | ||
461 | return FALSE; | 409 | return FALSE; |
462 | ls = GTK_LIST_STORE (gtk_tree_view_get_model (tv)); | 410 | ls = GTK_LIST_STORE (gtk_tree_view_get_model (tv)); |
463 | if (ls == NULL) | 411 | if (ls == NULL) |
464 | { | 412 | { |
465 | GNUNET_break (0); | 413 | GNUNET_break (0); |
466 | return FALSE; | 414 | return FALSE; |
467 | } | 415 | } |
468 | sel = gtk_tree_view_get_selection (tv); | 416 | sel = gtk_tree_view_get_selection (tv); |
469 | if (TRUE != | 417 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
470 | gtk_tree_selection_get_selected (sel, | ||
471 | &tm, | ||
472 | &iter)) | ||
473 | return FALSE; | 418 | return FALSE; |
474 | gtk_tree_model_get (tm, &iter, 1, &editable, -1); | 419 | gtk_tree_model_get (tm, &iter, 1, &editable, -1); |
475 | if (TRUE == editable) | 420 | if (TRUE == editable) |
476 | return FALSE; /* likely currently editing... */ | 421 | return FALSE; /* likely currently editing... */ |
477 | gtk_list_store_remove (ls, &iter); | 422 | gtk_list_store_remove (ls, &iter); |
478 | gtk_tree_model_get_iter_first (tm, &iter); | 423 | gtk_tree_model_get_iter_first (tm, &iter); |
479 | gtk_tree_selection_select_iter (sel, &iter); | 424 | gtk_tree_selection_select_iter (sel, &iter); |
@@ -493,12 +438,9 @@ GNUNET_setup_treeview_key_press_event_cb (GtkTreeView *tv, | |||
493 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem | 438 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem |
494 | */ | 439 | */ |
495 | static int | 440 | static int |
496 | load_string_list_store (const void *cls, | 441 | load_string_list_store (const void *cls, const char *section, |
497 | const char *section, | 442 | const char *option, const char *value, GObject * widget, |
498 | const char *option, | 443 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
499 | const char *value, | ||
500 | GObject *widget, | ||
501 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
502 | { | 444 | { |
503 | char *t; | 445 | char *t; |
504 | char *w; | 446 | char *w; |
@@ -511,22 +453,12 @@ load_string_list_store (const void *cls, | |||
511 | t = GNUNET_strdup (value); | 453 | t = GNUNET_strdup (value); |
512 | w = strtok (t, " "); | 454 | w = strtok (t, " "); |
513 | while (w != NULL) | 455 | while (w != NULL) |
514 | { | 456 | { |
515 | gtk_list_store_insert_with_values (ls, | 457 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, 0, w, 1, FALSE, -1); |
516 | &iter, | 458 | w = strtok (NULL, " "); |
517 | G_MAXINT, | 459 | } |
518 | 0, w, | ||
519 | 1, FALSE, | ||
520 | -1); | ||
521 | w = strtok (NULL, " "); | ||
522 | } | ||
523 | GNUNET_free (t); | 460 | GNUNET_free (t); |
524 | gtk_list_store_insert_with_values (ls, | 461 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, 0, "", 1, TRUE, -1); |
525 | &iter, | ||
526 | G_MAXINT, | ||
527 | 0, "", | ||
528 | 1, TRUE, | ||
529 | -1); | ||
530 | return GNUNET_OK; | 462 | return GNUNET_OK; |
531 | } | 463 | } |
532 | 464 | ||
@@ -543,11 +475,9 @@ load_string_list_store (const void *cls, | |||
543 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem | 475 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem |
544 | */ | 476 | */ |
545 | static int | 477 | static int |
546 | save_string_list_store (const void *cls, | 478 | save_string_list_store (const void *cls, const char *section, |
547 | const char *section, | 479 | const char *option, GObject * widget, |
548 | const char *option, | 480 | struct GNUNET_CONFIGURATION_Handle *cfg) |
549 | GObject *widget, | ||
550 | struct GNUNET_CONFIGURATION_Handle *cfg) | ||
551 | { | 481 | { |
552 | GtkTreeModel *tm; | 482 | GtkTreeModel *tm; |
553 | GtkTreeIter iter; | 483 | GtkTreeIter iter; |
@@ -560,37 +490,28 @@ save_string_list_store (const void *cls, | |||
560 | return GNUNET_SYSERR; | 490 | return GNUNET_SYSERR; |
561 | value = NULL; | 491 | value = NULL; |
562 | if (TRUE == gtk_tree_model_get_iter_first (tm, &iter)) | 492 | if (TRUE == gtk_tree_model_get_iter_first (tm, &iter)) |
493 | { | ||
494 | do | ||
563 | { | 495 | { |
564 | do | 496 | gtk_tree_model_get (tm, &iter, 0, &val, -1); |
565 | { | 497 | if (value == NULL) |
566 | gtk_tree_model_get (tm, | 498 | { |
567 | &iter, | 499 | value = GNUNET_strdup (val); |
568 | 0, &val, | 500 | } |
569 | -1); | 501 | else |
570 | if (value == NULL) | 502 | { |
571 | { | 503 | GNUNET_asprintf (&n, "%s %s", value, val); |
572 | value = GNUNET_strdup (val); | 504 | GNUNET_free (value); |
573 | } | 505 | value = n; |
574 | else | 506 | } |
575 | { | 507 | g_free (val); |
576 | GNUNET_asprintf (&n, | ||
577 | "%s %s", | ||
578 | value, | ||
579 | val); | ||
580 | GNUNET_free (value); | ||
581 | value = n; | ||
582 | } | ||
583 | g_free (val); | ||
584 | } | ||
585 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | ||
586 | } | 508 | } |
509 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | ||
510 | } | ||
587 | if (value == NULL) | 511 | if (value == NULL) |
588 | value = GNUNET_strdup (""); | 512 | value = GNUNET_strdup (""); |
589 | GNUNET_CONFIGURATION_set_value_string (cfg, | 513 | GNUNET_CONFIGURATION_set_value_string (cfg, section, option, value); |
590 | section, | 514 | GNUNET_free (value); |
591 | option, | ||
592 | value); | ||
593 | GNUNET_free (value); | ||
594 | return GNUNET_OK; | 515 | return GNUNET_OK; |
595 | } | 516 | } |
596 | 517 | ||
@@ -613,88 +534,74 @@ add_dns_entry_to_list_store (void *cls, const char *section) | |||
613 | char *redirect; | 534 | char *redirect; |
614 | char *cpy; | 535 | char *cpy; |
615 | gboolean udp; | 536 | gboolean udp; |
616 | 537 | ||
617 | if (NULL == section) | 538 | if (NULL == section) |
618 | { | 539 | { |
619 | gtk_list_store_insert_with_values (ls, | 540 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, 0, "", 1, |
620 | &iter, | 541 | (guint) 80, 2, (guint) 8080, 3, |
621 | G_MAXINT, | 542 | "localhost", 4, "tcp", -1); |
622 | 0, "", | 543 | return; |
623 | 1, (guint) 80, | 544 | } |
624 | 2, (guint) 8080, | ||
625 | 3, "localhost", | ||
626 | 4, "tcp", | ||
627 | -1); | ||
628 | return; | ||
629 | } | ||
630 | 545 | ||
631 | if ( (8 > strlen (section)) || | 546 | if ((8 > strlen (section)) || |
632 | (0 != strcmp (".gnunet.", section + ((strlen (section) - 8)))) ) | 547 | (0 != strcmp (".gnunet.", section + ((strlen (section) - 8))))) |
633 | return; | 548 | return; |
634 | sld = GNUNET_strdup (section); | 549 | sld = GNUNET_strdup (section); |
635 | sld[strlen (section) - 8] = '\0'; | 550 | sld[strlen (section) - 8] = '\0'; |
636 | udp = FALSE; | 551 | udp = FALSE; |
637 | do | 552 | do |
638 | { | 553 | { |
639 | if (GNUNET_OK == | 554 | if (GNUNET_OK == |
640 | GNUNET_CONFIGURATION_get_value_string (cfg, section, | 555 | GNUNET_CONFIGURATION_get_value_string (cfg, section, |
641 | (TRUE == udp) | 556 | (TRUE == |
642 | ? "UDP_REDIRECTS" | 557 | udp) ? "UDP_REDIRECTS" : |
643 | : "TCP_REDIRECTS", | 558 | "TCP_REDIRECTS", &cpy)) |
644 | &cpy)) | 559 | { |
645 | { | 560 | for (redirect = strtok (cpy, " "); redirect != NULL; |
646 | for (redirect = strtok (cpy, " "); redirect != NULL; | 561 | redirect = strtok (NULL, " ")) |
647 | redirect = strtok (NULL, " ")) | 562 | { |
648 | { | 563 | if (NULL == (hostname = strstr (redirect, ":"))) |
649 | if (NULL == (hostname = strstr (redirect, ":"))) | 564 | { |
650 | { | 565 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
651 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 566 | _("Option `%s' is not formatted correctly!\n"), redirect); |
652 | _("Option `%s' is not formatted correctly!\n"), | 567 | continue; |
653 | redirect); | 568 | } |
654 | continue; | 569 | hostname[0] = '\0'; |
655 | } | 570 | hostname++; |
656 | hostname[0] = '\0'; | 571 | if (NULL == (hostport = strstr (hostname, ":"))) |
657 | hostname++; | 572 | { |
658 | if (NULL == (hostport = strstr (hostname, ":"))) | 573 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
659 | { | 574 | _("Option `%s' is not formatted correctly!\n"), redirect); |
660 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 575 | continue; |
661 | _("Option `%s' is not formatted correctly!\n"), | 576 | } |
662 | redirect); | 577 | hostport[0] = '\0'; |
663 | continue; | 578 | hostport++; |
664 | } | 579 | |
665 | hostport[0] = '\0'; | 580 | int local_port = atoi (redirect); |
666 | hostport++; | 581 | |
667 | 582 | if (!((local_port > 0) && (local_port < 65536))) | |
668 | int local_port = atoi (redirect); | 583 | { |
669 | if (!((local_port > 0) && (local_port < 65536))) | 584 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
670 | { | 585 | _("`%s' is not a valid port number!\n"), redirect); |
671 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 586 | continue; |
672 | _("`%s' is not a valid port number!\n"), | 587 | } |
673 | redirect); | 588 | int host_port = atoi (hostport); |
674 | continue; | 589 | |
675 | } | 590 | if (!((host_port > 0) && (host_port < 65536))) |
676 | int host_port = atoi (hostport); | 591 | { |
677 | if (!((host_port > 0) && (host_port < 65536))) | 592 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
678 | { | 593 | _("`%s' is not a valid port number!\n"), hostport); |
679 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 594 | continue; |
680 | _("`%s' is not a valid port number!\n"), | 595 | } |
681 | hostport); | 596 | gtk_list_store_insert_with_values (ls, &iter, 0, 0, sld, 1, |
682 | continue; | 597 | (guint) local_port, 2, |
683 | } | 598 | (guint) host_port, 3, hostname, 4, |
684 | gtk_list_store_insert_with_values (ls, | 599 | (TRUE == udp) ? "udp" : "tcp", -1); |
685 | &iter, | 600 | } |
686 | 0, | 601 | GNUNET_free (cpy); |
687 | 0, sld, | ||
688 | 1, (guint) local_port, | ||
689 | 2, (guint) host_port, | ||
690 | 3, hostname, | ||
691 | 4, (TRUE == udp) ? "udp" : "tcp", | ||
692 | -1); | ||
693 | } | ||
694 | GNUNET_free (cpy); | ||
695 | } | ||
696 | udp = !udp; | ||
697 | } | 602 | } |
603 | udp = !udp; | ||
604 | } | ||
698 | while (udp != FALSE); | 605 | while (udp != FALSE); |
699 | GNUNET_free (sld); | 606 | GNUNET_free (sld); |
700 | } | 607 | } |
@@ -712,26 +619,22 @@ add_dns_entry_to_list_store (void *cls, const char *section) | |||
712 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem | 619 | * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem |
713 | */ | 620 | */ |
714 | static int | 621 | static int |
715 | load_vpn_dns_configuration (const void *cls, | 622 | load_vpn_dns_configuration (const void *cls, const char *section, |
716 | const char *section, | 623 | const char *option, const char *value, |
717 | const char *option, | 624 | GObject * widget, |
718 | const char *value, | 625 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
719 | GObject *widget, | ||
720 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
721 | { | 626 | { |
722 | GtkTreeView *tv; | 627 | GtkTreeView *tv; |
723 | GtkListStore *ls; | 628 | GtkListStore *ls; |
724 | 629 | ||
725 | tv = GTK_TREE_VIEW (widget); | 630 | tv = GTK_TREE_VIEW (widget); |
726 | if (tv == NULL) | 631 | if (tv == NULL) |
727 | { | 632 | { |
728 | GNUNET_break (0); | 633 | GNUNET_break (0); |
729 | return GNUNET_SYSERR; | 634 | return GNUNET_SYSERR; |
730 | } | 635 | } |
731 | ls = GTK_LIST_STORE (gtk_tree_view_get_model (tv)); | 636 | ls = GTK_LIST_STORE (gtk_tree_view_get_model (tv)); |
732 | GNUNET_CONFIGURATION_iterate_sections (cfg, | 637 | GNUNET_CONFIGURATION_iterate_sections (cfg, &add_dns_entry_to_list_store, ls); |
733 | &add_dns_entry_to_list_store, | ||
734 | ls); | ||
735 | /* finally, add empty entry */ | 638 | /* finally, add empty entry */ |
736 | add_dns_entry_to_list_store (ls, NULL); | 639 | add_dns_entry_to_list_store (ls, NULL); |
737 | return GNUNET_OK; | 640 | return GNUNET_OK; |
@@ -741,14 +644,14 @@ load_vpn_dns_configuration (const void *cls, | |||
741 | /** | 644 | /** |
742 | * Records we use to build DNS information lists. | 645 | * Records we use to build DNS information lists. |
743 | */ | 646 | */ |
744 | struct DnsInfo | 647 | struct DnsInfo |
745 | { | 648 | { |
746 | struct DnsInfo *next; | 649 | struct DnsInfo *next; |
747 | char *section; | 650 | char *section; |
748 | char *altnames; | 651 | char *altnames; |
749 | char *tcpred; | 652 | char *tcpred; |
750 | char *udpred; | 653 | char *udpred; |
751 | unsigned long long ttl; | 654 | unsigned long long ttl; |
752 | }; | 655 | }; |
753 | 656 | ||
754 | 657 | ||
@@ -760,14 +663,13 @@ struct DnsInfo | |||
760 | * @param section name of a section in the configuration | 663 | * @param section name of a section in the configuration |
761 | */ | 664 | */ |
762 | static void | 665 | static void |
763 | collect_dns_sections (void *cls, | 666 | collect_dns_sections (void *cls, const char *section) |
764 | const char *section) | ||
765 | { | 667 | { |
766 | struct DnsInfo **base = cls; | 668 | struct DnsInfo **base = cls; |
767 | struct DnsInfo *pos; | 669 | struct DnsInfo *pos; |
768 | 670 | ||
769 | if ( (8 > strlen (section)) || | 671 | if ((8 > strlen (section)) || |
770 | (0 != strcmp (".gnunet.", section + ((strlen (section) - 8)))) ) | 672 | (0 != strcmp (".gnunet.", section + ((strlen (section) - 8))))) |
771 | return; | 673 | return; |
772 | pos = GNUNET_malloc (sizeof (struct DnsInfo)); | 674 | pos = GNUNET_malloc (sizeof (struct DnsInfo)); |
773 | pos->section = GNUNET_strdup (section); | 675 | pos->section = GNUNET_strdup (section); |
@@ -775,7 +677,8 @@ collect_dns_sections (void *cls, | |||
775 | GNUNET_CONFIGURATION_get_value_number (cfg, section, "TTL", &pos->ttl)) | 677 | GNUNET_CONFIGURATION_get_value_number (cfg, section, "TTL", &pos->ttl)) |
776 | pos->ttl = 3600000; | 678 | pos->ttl = 3600000; |
777 | if (GNUNET_OK != | 679 | if (GNUNET_OK != |
778 | GNUNET_CONFIGURATION_get_value_string (cfg, section, "ALTERNATIVE_NAMES", &pos->altnames)) | 680 | GNUNET_CONFIGURATION_get_value_string (cfg, section, "ALTERNATIVE_NAMES", |
681 | &pos->altnames)) | ||
779 | pos->altnames = NULL; | 682 | pos->altnames = NULL; |
780 | pos->tcpred = GNUNET_strdup (""); | 683 | pos->tcpred = GNUNET_strdup (""); |
781 | pos->udpred = GNUNET_strdup (""); | 684 | pos->udpred = GNUNET_strdup (""); |
@@ -792,11 +695,10 @@ collect_dns_sections (void *cls, | |||
792 | * @param section name of a section in the configuration | 695 | * @param section name of a section in the configuration |
793 | */ | 696 | */ |
794 | static void | 697 | static void |
795 | remove_dns_sections (void *cls, | 698 | remove_dns_sections (void *cls, const char *section) |
796 | const char *section) | ||
797 | { | 699 | { |
798 | if ( (8 > strlen (section)) || | 700 | if ((8 > strlen (section)) || |
799 | (0 != strcmp (".gnunet.", section + ((strlen (section) - 8)))) ) | 701 | (0 != strcmp (".gnunet.", section + ((strlen (section) - 8))))) |
800 | return; | 702 | return; |
801 | GNUNET_CONFIGURATION_remove_section (cfg, section); | 703 | GNUNET_CONFIGURATION_remove_section (cfg, section); |
802 | } | 704 | } |
@@ -809,7 +711,7 @@ remove_dns_sections (void *cls, | |||
809 | * @param tm model to use | 711 | * @param tm model to use |
810 | */ | 712 | */ |
811 | static void | 713 | static void |
812 | update_vpn_dns_configuration (GtkTreeModel *tm) | 714 | update_vpn_dns_configuration (GtkTreeModel * tm) |
813 | { | 715 | { |
814 | GtkTreeIter iter; | 716 | GtkTreeIter iter; |
815 | gchar *hostname; | 717 | gchar *hostname; |
@@ -822,99 +724,76 @@ update_vpn_dns_configuration (GtkTreeModel *tm) | |||
822 | struct DnsInfo *pos; | 724 | struct DnsInfo *pos; |
823 | 725 | ||
824 | head = NULL; | 726 | head = NULL; |
825 | GNUNET_CONFIGURATION_iterate_sections (cfg, | 727 | GNUNET_CONFIGURATION_iterate_sections (cfg, &collect_dns_sections, &head); |
826 | &collect_dns_sections, | 728 | if (TRUE == gtk_tree_model_get_iter_first (tm, &iter)) |
827 | &head); | ||
828 | if (TRUE == | ||
829 | gtk_tree_model_get_iter_first (tm, &iter)) | ||
830 | do | 729 | do |
831 | { | 730 | { |
832 | gtk_tree_model_get (tm, &iter, | 731 | gtk_tree_model_get (tm, &iter, 0, &hostname, 1, &srcport, 2, &targetport, |
833 | 0, &hostname, | 732 | 3, &targethost, 4, &tcpudp, -1); |
834 | 1, &srcport, | 733 | if (0 != strlen (hostname)) |
835 | 2, &targetport, | 734 | { |
836 | 3, &targethost, | 735 | pos = head; |
837 | 4, &tcpudp, | 736 | GNUNET_asprintf (&tmp, "%s.gnunet.", hostname); |
838 | -1); | 737 | while ((NULL != pos) && (0 != strcasecmp (tmp, pos->section))) |
839 | if (0 != strlen (hostname)) | 738 | pos = pos->next; |
840 | { | 739 | if (pos == NULL) |
841 | pos = head; | 740 | { |
842 | GNUNET_asprintf (&tmp, | 741 | pos = GNUNET_malloc (sizeof (struct DnsInfo)); |
843 | "%s.gnunet.", | 742 | pos->section = tmp; |
844 | hostname); | 743 | pos->ttl = 3600000; |
845 | while ( (NULL != pos) && | 744 | pos->altnames = NULL; |
846 | (0 != strcasecmp (tmp, pos->section)) ) | 745 | pos->tcpred = GNUNET_strdup (""); |
847 | pos = pos->next; | 746 | pos->udpred = GNUNET_strdup (""); |
848 | if (pos == NULL) | 747 | pos->next = head; |
849 | { | 748 | head = pos; |
850 | pos = GNUNET_malloc (sizeof (struct DnsInfo)); | 749 | } |
851 | pos->section = tmp; | 750 | else |
852 | pos->ttl = 3600000; | 751 | { |
853 | pos->altnames = NULL; | 752 | GNUNET_free (tmp); |
854 | pos->tcpred = GNUNET_strdup (""); | 753 | } |
855 | pos->udpred = GNUNET_strdup (""); | 754 | |
856 | pos->next = head; | 755 | GNUNET_asprintf (&tmp, "%u:%s:%u %s", srcport, targethost, targetport, |
857 | head = pos; | 756 | (0 == |
858 | } | 757 | strcasecmp ("tcp", |
859 | else | 758 | tcpudp)) ? pos->tcpred : pos->udpred); |
860 | { | 759 | if (0 == strcasecmp ("tcp", tcpudp)) |
861 | GNUNET_free (tmp); | 760 | { |
862 | } | 761 | GNUNET_free (pos->tcpred); |
863 | 762 | pos->tcpred = tmp; | |
864 | GNUNET_asprintf (&tmp, | 763 | } |
865 | "%u:%s:%u %s", | 764 | else |
866 | srcport, | 765 | { |
867 | targethost, | 766 | GNUNET_free (pos->udpred); |
868 | targetport, | 767 | pos->udpred = tmp; |
869 | (0 == strcasecmp ("tcp", tcpudp)) ? pos->tcpred : pos->udpred); | 768 | } |
870 | if (0 == strcasecmp ("tcp", tcpudp)) | ||
871 | { | ||
872 | GNUNET_free (pos->tcpred); | ||
873 | pos->tcpred = tmp; | ||
874 | } | ||
875 | else | ||
876 | { | ||
877 | GNUNET_free (pos->udpred); | ||
878 | pos->udpred = tmp; | ||
879 | } | ||
880 | } | ||
881 | g_free (tcpudp); | ||
882 | g_free (hostname); | ||
883 | g_free (targethost); | ||
884 | } | 769 | } |
770 | g_free (tcpudp); | ||
771 | g_free (hostname); | ||
772 | g_free (targethost); | ||
773 | } | ||
885 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | 774 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); |
886 | GNUNET_CONFIGURATION_iterate_sections (cfg, | 775 | GNUNET_CONFIGURATION_iterate_sections (cfg, &remove_dns_sections, NULL); |
887 | &remove_dns_sections, | ||
888 | NULL); | ||
889 | while (NULL != head) | 776 | while (NULL != head) |
890 | { | 777 | { |
891 | pos = head; | 778 | pos = head; |
892 | head = pos->next; | 779 | head = pos->next; |
893 | if (pos->altnames != NULL) | 780 | if (pos->altnames != NULL) |
894 | GNUNET_CONFIGURATION_set_value_string (cfg, | 781 | GNUNET_CONFIGURATION_set_value_string (cfg, pos->section, |
895 | pos->section, | 782 | "ALTERNATIVE_NAMES", |
896 | "ALTERNATIVE_NAMES", | 783 | pos->altnames); |
897 | pos->altnames); | 784 | if (strlen (pos->udpred) > 0) |
898 | if (strlen (pos->udpred) > 0) | 785 | GNUNET_CONFIGURATION_set_value_string (cfg, pos->section, "UDP_REDIRECTS", |
899 | GNUNET_CONFIGURATION_set_value_string (cfg, | 786 | pos->udpred); |
900 | pos->section, | 787 | if (strlen (pos->tcpred) > 0) |
901 | "UDP_REDIRECTS", | 788 | GNUNET_CONFIGURATION_set_value_string (cfg, pos->section, "TCP_REDIRECTS", |
902 | pos->udpred); | 789 | pos->tcpred); |
903 | if (strlen (pos->tcpred) > 0) | 790 | GNUNET_CONFIGURATION_set_value_number (cfg, pos->section, "TTL", pos->ttl); |
904 | GNUNET_CONFIGURATION_set_value_string (cfg, | 791 | GNUNET_free_non_null (pos->altnames); |
905 | pos->section, | 792 | GNUNET_free (pos->tcpred); |
906 | "TCP_REDIRECTS", | 793 | GNUNET_free (pos->udpred); |
907 | pos->tcpred); | 794 | GNUNET_free (pos->section); |
908 | GNUNET_CONFIGURATION_set_value_number (cfg, | 795 | GNUNET_free (pos); |
909 | pos->section, | 796 | } |
910 | "TTL", | ||
911 | pos->ttl); | ||
912 | GNUNET_free_non_null (pos->altnames); | ||
913 | GNUNET_free (pos->tcpred); | ||
914 | GNUNET_free (pos->udpred); | ||
915 | GNUNET_free (pos->section); | ||
916 | GNUNET_free (pos); | ||
917 | } | ||
918 | } | 797 | } |
919 | 798 | ||
920 | 799 | ||
@@ -932,10 +811,8 @@ update_vpn_dns_configuration (GtkTreeModel *tm) | |||
932 | * @param user_data NULL | 811 | * @param user_data NULL |
933 | */ | 812 | */ |
934 | static void | 813 | static void |
935 | save_vpn_dns_service_dnsname (GtkCellRendererText *renderer, | 814 | save_vpn_dns_service_dnsname (GtkCellRendererText * renderer, gchar * path, |
936 | gchar *path, | 815 | gchar * new_text, gpointer user_data) |
937 | gchar *new_text, | ||
938 | gpointer user_data) | ||
939 | { | 816 | { |
940 | GtkTreeModel *tm; | 817 | GtkTreeModel *tm; |
941 | GtkListStore *ls; | 818 | GtkListStore *ls; |
@@ -944,44 +821,38 @@ save_vpn_dns_service_dnsname (GtkCellRendererText *renderer, | |||
944 | 821 | ||
945 | tm = GTK_TREE_MODEL (GNUNET_SETUP_get_object ("vpn_dns_config_liststore")); | 822 | tm = GTK_TREE_MODEL (GNUNET_SETUP_get_object ("vpn_dns_config_liststore")); |
946 | if (NULL == tm) | 823 | if (NULL == tm) |
947 | { | 824 | { |
948 | GNUNET_break (0); | 825 | GNUNET_break (0); |
949 | return; | 826 | return; |
950 | } | 827 | } |
951 | ls = GTK_LIST_STORE (tm); | 828 | ls = GTK_LIST_STORE (tm); |
952 | if (NULL == ls) | 829 | if (NULL == ls) |
953 | { | 830 | { |
954 | GNUNET_break (0); | 831 | GNUNET_break (0); |
955 | return; | 832 | return; |
956 | } | 833 | } |
957 | if (TRUE != gtk_tree_model_get_iter_from_string (tm, &iter, path)) | 834 | if (TRUE != gtk_tree_model_get_iter_from_string (tm, &iter, path)) |
958 | { | 835 | { |
959 | GNUNET_break (0); | 836 | GNUNET_break (0); |
960 | return; | 837 | return; |
961 | } | 838 | } |
962 | gtk_tree_model_get (tm, &iter, | 839 | gtk_tree_model_get (tm, &iter, 0, &old, -1); |
963 | 0, &old, | 840 | if ((0 != strlen (old)) && (0 == strlen (new_text))) |
964 | -1); | 841 | { |
965 | if ( (0 != strlen (old)) && | 842 | /* deletion */ |
966 | (0 == strlen (new_text)) ) | 843 | gtk_list_store_remove (ls, &iter); |
967 | { | 844 | g_free (old); |
968 | /* deletion */ | 845 | return; |
969 | gtk_list_store_remove (ls, &iter); | 846 | } |
970 | g_free (old); | ||
971 | return; | ||
972 | } | ||
973 | /* update model */ | 847 | /* update model */ |
974 | gtk_list_store_set (ls, &iter, | 848 | gtk_list_store_set (ls, &iter, 0, new_text, -1); |
975 | 0, new_text, | ||
976 | -1); | ||
977 | /* update configuration */ | 849 | /* update configuration */ |
978 | update_vpn_dns_configuration (tm); | 850 | update_vpn_dns_configuration (tm); |
979 | if ( (0 == strlen (old)) && | 851 | if ((0 == strlen (old)) && (0 != strlen (new_text))) |
980 | (0 != strlen (new_text)) ) | 852 | { |
981 | { | 853 | /* need another empty entry at the end for future expansion */ |
982 | /* need another empty entry at the end for future expansion */ | 854 | add_dns_entry_to_list_store (GTK_LIST_STORE (tm), NULL); |
983 | add_dns_entry_to_list_store (GTK_LIST_STORE (tm), NULL); | 855 | } |
984 | } | ||
985 | g_free (old); | 856 | g_free (old); |
986 | } | 857 | } |
987 | 858 | ||
@@ -998,23 +869,23 @@ save_vpn_dns_service_dnsname (GtkCellRendererText *renderer, | |||
998 | */ | 869 | */ |
999 | static int | 870 | static int |
1000 | vpn_dns_service_dnsname_install_edited_handler (const void *cls, | 871 | vpn_dns_service_dnsname_install_edited_handler (const void *cls, |
1001 | const char *section, | 872 | const char *section, |
1002 | const char *option, | 873 | const char *option, |
1003 | GObject *widget, | 874 | GObject * widget, |
1004 | struct GNUNET_CONFIGURATION_Handle *cfg) | 875 | struct |
876 | GNUNET_CONFIGURATION_Handle | ||
877 | *cfg) | ||
1005 | { | 878 | { |
1006 | static int once; | 879 | static int once; |
1007 | GtkCellRendererText *rt; | 880 | GtkCellRendererText *rt; |
1008 | 881 | ||
1009 | rt = GTK_CELL_RENDERER_TEXT(widget); | 882 | rt = GTK_CELL_RENDERER_TEXT (widget); |
1010 | if (NULL == rt) | 883 | if (NULL == rt) |
1011 | return GNUNET_SYSERR; | 884 | return GNUNET_SYSERR; |
1012 | if (0 != once++) | 885 | if (0 != once++) |
1013 | return GNUNET_OK; | 886 | return GNUNET_OK; |
1014 | g_signal_connect (rt, | 887 | g_signal_connect (rt, "edited", G_CALLBACK (&save_vpn_dns_service_dnsname), |
1015 | "edited", | 888 | NULL); |
1016 | G_CALLBACK (&save_vpn_dns_service_dnsname), | ||
1017 | NULL); | ||
1018 | return GNUNET_OK; | 889 | return GNUNET_OK; |
1019 | } | 890 | } |
1020 | 891 | ||
@@ -1033,42 +904,38 @@ vpn_dns_service_dnsname_install_edited_handler (const void *cls, | |||
1033 | * @param user_data NULL | 904 | * @param user_data NULL |
1034 | */ | 905 | */ |
1035 | static void | 906 | static void |
1036 | save_vpn_dns_service_tcpudp (GtkCellRendererText *renderer, | 907 | save_vpn_dns_service_tcpudp (GtkCellRendererText * renderer, gchar * path, |
1037 | gchar *path, | 908 | gchar * new_text, gpointer user_data) |
1038 | gchar *new_text, | ||
1039 | gpointer user_data) | ||
1040 | { | 909 | { |
1041 | GtkTreeModel *tm; | 910 | GtkTreeModel *tm; |
1042 | GtkListStore *ls; | 911 | GtkListStore *ls; |
1043 | GtkTreeIter iter; | 912 | GtkTreeIter iter; |
1044 | 913 | ||
1045 | if ( (0 != strcasecmp ("tcp", new_text)) && | 914 | if ((0 != strcasecmp ("tcp", new_text)) && |
1046 | (0 != strcasecmp ("udp", new_text)) ) | 915 | (0 != strcasecmp ("udp", new_text))) |
1047 | { | 916 | { |
1048 | /* FIXME: warn... */ | 917 | /* FIXME: warn... */ |
1049 | return; | 918 | return; |
1050 | } | 919 | } |
1051 | tm = GTK_TREE_MODEL (GNUNET_SETUP_get_object ("vpn_dns_config_liststore")); | 920 | tm = GTK_TREE_MODEL (GNUNET_SETUP_get_object ("vpn_dns_config_liststore")); |
1052 | if (NULL == tm) | 921 | if (NULL == tm) |
1053 | { | 922 | { |
1054 | GNUNET_break (0); | 923 | GNUNET_break (0); |
1055 | return; | 924 | return; |
1056 | } | 925 | } |
1057 | ls = GTK_LIST_STORE (tm); | 926 | ls = GTK_LIST_STORE (tm); |
1058 | if (NULL == ls) | 927 | if (NULL == ls) |
1059 | { | 928 | { |
1060 | GNUNET_break (0); | 929 | GNUNET_break (0); |
1061 | return; | 930 | return; |
1062 | } | 931 | } |
1063 | if (TRUE != gtk_tree_model_get_iter_from_string (tm, &iter, path)) | 932 | if (TRUE != gtk_tree_model_get_iter_from_string (tm, &iter, path)) |
1064 | { | 933 | { |
1065 | GNUNET_break (0); | 934 | GNUNET_break (0); |
1066 | return; | 935 | return; |
1067 | } | 936 | } |
1068 | /* update model */ | 937 | /* update model */ |
1069 | gtk_list_store_set (ls, &iter, | 938 | gtk_list_store_set (ls, &iter, 4, new_text, -1); |
1070 | 4, new_text, | ||
1071 | -1); | ||
1072 | /* update configuration */ | 939 | /* update configuration */ |
1073 | update_vpn_dns_configuration (tm); | 940 | update_vpn_dns_configuration (tm); |
1074 | } | 941 | } |
@@ -1086,23 +953,22 @@ save_vpn_dns_service_tcpudp (GtkCellRendererText *renderer, | |||
1086 | */ | 953 | */ |
1087 | static int | 954 | static int |
1088 | vpn_dns_service_tcpudp_install_edited_handler (const void *cls, | 955 | vpn_dns_service_tcpudp_install_edited_handler (const void *cls, |
1089 | const char *section, | 956 | const char *section, |
1090 | const char *option, | 957 | const char *option, |
1091 | GObject *widget, | 958 | GObject * widget, |
1092 | struct GNUNET_CONFIGURATION_Handle *cfg) | 959 | struct |
960 | GNUNET_CONFIGURATION_Handle *cfg) | ||
1093 | { | 961 | { |
1094 | static int once; | 962 | static int once; |
1095 | GtkCellRendererText *rt; | 963 | GtkCellRendererText *rt; |
1096 | 964 | ||
1097 | rt = GTK_CELL_RENDERER_TEXT(widget); | 965 | rt = GTK_CELL_RENDERER_TEXT (widget); |
1098 | if (NULL == rt) | 966 | if (NULL == rt) |
1099 | return GNUNET_SYSERR; | 967 | return GNUNET_SYSERR; |
1100 | if (0 != once++) | 968 | if (0 != once++) |
1101 | return GNUNET_OK; | 969 | return GNUNET_OK; |
1102 | g_signal_connect (rt, | 970 | g_signal_connect (rt, "edited", G_CALLBACK (&save_vpn_dns_service_tcpudp), |
1103 | "edited", | 971 | NULL); |
1104 | G_CALLBACK (&save_vpn_dns_service_tcpudp), | ||
1105 | NULL); | ||
1106 | return GNUNET_OK; | 972 | return GNUNET_OK; |
1107 | } | 973 | } |
1108 | 974 | ||
@@ -1121,10 +987,8 @@ vpn_dns_service_tcpudp_install_edited_handler (const void *cls, | |||
1121 | * @param user_data NULL | 987 | * @param user_data NULL |
1122 | */ | 988 | */ |
1123 | static void | 989 | static void |
1124 | save_vpn_dns_service_sourceport (GtkCellRendererText *renderer, | 990 | save_vpn_dns_service_sourceport (GtkCellRendererText * renderer, gchar * path, |
1125 | gchar *path, | 991 | gchar * new_text, gpointer user_data) |
1126 | gchar *new_text, | ||
1127 | gpointer user_data) | ||
1128 | { | 992 | { |
1129 | GtkTreeModel *tm; | 993 | GtkTreeModel *tm; |
1130 | GtkListStore *ls; | 994 | GtkListStore *ls; |
@@ -1132,32 +996,30 @@ save_vpn_dns_service_sourceport (GtkCellRendererText *renderer, | |||
1132 | int port; | 996 | int port; |
1133 | 997 | ||
1134 | port = atoi (new_text); | 998 | port = atoi (new_text); |
1135 | if ( (port < 1) || (port > UINT16_MAX) ) | 999 | if ((port < 1) || (port > UINT16_MAX)) |
1136 | { | 1000 | { |
1137 | /* invalid port, FIXME: warn */ | 1001 | /* invalid port, FIXME: warn */ |
1138 | return; | 1002 | return; |
1139 | } | 1003 | } |
1140 | tm = GTK_TREE_MODEL (GNUNET_SETUP_get_object ("vpn_dns_config_liststore")); | 1004 | tm = GTK_TREE_MODEL (GNUNET_SETUP_get_object ("vpn_dns_config_liststore")); |
1141 | if (NULL == tm) | 1005 | if (NULL == tm) |
1142 | { | 1006 | { |
1143 | GNUNET_break (0); | 1007 | GNUNET_break (0); |
1144 | return; | 1008 | return; |
1145 | } | 1009 | } |
1146 | ls = GTK_LIST_STORE (tm); | 1010 | ls = GTK_LIST_STORE (tm); |
1147 | if (NULL == ls) | 1011 | if (NULL == ls) |
1148 | { | 1012 | { |
1149 | GNUNET_break (0); | 1013 | GNUNET_break (0); |
1150 | return; | 1014 | return; |
1151 | } | 1015 | } |
1152 | if (TRUE != gtk_tree_model_get_iter_from_string (tm, &iter, path)) | 1016 | if (TRUE != gtk_tree_model_get_iter_from_string (tm, &iter, path)) |
1153 | { | 1017 | { |
1154 | GNUNET_break (0); | 1018 | GNUNET_break (0); |
1155 | return; | 1019 | return; |
1156 | } | 1020 | } |
1157 | /* update model */ | 1021 | /* update model */ |
1158 | gtk_list_store_set (ls, &iter, | 1022 | gtk_list_store_set (ls, &iter, 1, (guint) port, -1); |
1159 | 1, (guint) port, | ||
1160 | -1); | ||
1161 | /* update configuration */ | 1023 | /* update configuration */ |
1162 | update_vpn_dns_configuration (tm); | 1024 | update_vpn_dns_configuration (tm); |
1163 | } | 1025 | } |
@@ -1175,23 +1037,23 @@ save_vpn_dns_service_sourceport (GtkCellRendererText *renderer, | |||
1175 | */ | 1037 | */ |
1176 | static int | 1038 | static int |
1177 | vpn_dns_service_sourceport_install_edited_handler (const void *cls, | 1039 | vpn_dns_service_sourceport_install_edited_handler (const void *cls, |
1178 | const char *section, | 1040 | const char *section, |
1179 | const char *option, | 1041 | const char *option, |
1180 | GObject *widget, | 1042 | GObject * widget, |
1181 | struct GNUNET_CONFIGURATION_Handle *cfg) | 1043 | struct |
1044 | GNUNET_CONFIGURATION_Handle | ||
1045 | *cfg) | ||
1182 | { | 1046 | { |
1183 | static int once; | 1047 | static int once; |
1184 | GtkCellRendererText *rt; | 1048 | GtkCellRendererText *rt; |
1185 | 1049 | ||
1186 | rt = GTK_CELL_RENDERER_TEXT(widget); | 1050 | rt = GTK_CELL_RENDERER_TEXT (widget); |
1187 | if (NULL == rt) | 1051 | if (NULL == rt) |
1188 | return GNUNET_SYSERR; | 1052 | return GNUNET_SYSERR; |
1189 | if (0 != once++) | 1053 | if (0 != once++) |
1190 | return GNUNET_OK; | 1054 | return GNUNET_OK; |
1191 | g_signal_connect (rt, | 1055 | g_signal_connect (rt, "edited", G_CALLBACK (&save_vpn_dns_service_sourceport), |
1192 | "edited", | 1056 | NULL); |
1193 | G_CALLBACK (&save_vpn_dns_service_sourceport), | ||
1194 | NULL); | ||
1195 | return GNUNET_OK; | 1057 | return GNUNET_OK; |
1196 | } | 1058 | } |
1197 | 1059 | ||
@@ -1210,10 +1072,9 @@ vpn_dns_service_sourceport_install_edited_handler (const void *cls, | |||
1210 | * @param user_data NULL | 1072 | * @param user_data NULL |
1211 | */ | 1073 | */ |
1212 | static void | 1074 | static void |
1213 | save_vpn_dns_service_targethostname (GtkCellRendererText *renderer, | 1075 | save_vpn_dns_service_targethostname (GtkCellRendererText * renderer, |
1214 | gchar *path, | 1076 | gchar * path, gchar * new_text, |
1215 | gchar *new_text, | 1077 | gpointer user_data) |
1216 | gpointer user_data) | ||
1217 | { | 1078 | { |
1218 | GtkTreeModel *tm; | 1079 | GtkTreeModel *tm; |
1219 | GtkListStore *ls; | 1080 | GtkListStore *ls; |
@@ -1221,25 +1082,23 @@ save_vpn_dns_service_targethostname (GtkCellRendererText *renderer, | |||
1221 | 1082 | ||
1222 | tm = GTK_TREE_MODEL (GNUNET_SETUP_get_object ("vpn_dns_config_liststore")); | 1083 | tm = GTK_TREE_MODEL (GNUNET_SETUP_get_object ("vpn_dns_config_liststore")); |
1223 | if (NULL == tm) | 1084 | if (NULL == tm) |
1224 | { | 1085 | { |
1225 | GNUNET_break (0); | 1086 | GNUNET_break (0); |
1226 | return; | 1087 | return; |
1227 | } | 1088 | } |
1228 | ls = GTK_LIST_STORE (tm); | 1089 | ls = GTK_LIST_STORE (tm); |
1229 | if (NULL == ls) | 1090 | if (NULL == ls) |
1230 | { | 1091 | { |
1231 | GNUNET_break (0); | 1092 | GNUNET_break (0); |
1232 | return; | 1093 | return; |
1233 | } | 1094 | } |
1234 | if (TRUE != gtk_tree_model_get_iter_from_string (tm, &iter, path)) | 1095 | if (TRUE != gtk_tree_model_get_iter_from_string (tm, &iter, path)) |
1235 | { | 1096 | { |
1236 | GNUNET_break (0); | 1097 | GNUNET_break (0); |
1237 | return; | 1098 | return; |
1238 | } | 1099 | } |
1239 | /* update model */ | 1100 | /* update model */ |
1240 | gtk_list_store_set (ls, &iter, | 1101 | gtk_list_store_set (ls, &iter, 3, new_text, -1); |
1241 | 3, new_text, | ||
1242 | -1); | ||
1243 | /* update configuration */ | 1102 | /* update configuration */ |
1244 | update_vpn_dns_configuration (tm); | 1103 | update_vpn_dns_configuration (tm); |
1245 | } | 1104 | } |
@@ -1257,23 +1116,23 @@ save_vpn_dns_service_targethostname (GtkCellRendererText *renderer, | |||
1257 | */ | 1116 | */ |
1258 | static int | 1117 | static int |
1259 | vpn_dns_service_targethostname_install_edited_handler (const void *cls, | 1118 | vpn_dns_service_targethostname_install_edited_handler (const void *cls, |
1260 | const char *section, | 1119 | const char *section, |
1261 | const char *option, | 1120 | const char *option, |
1262 | GObject *widget, | 1121 | GObject * widget, |
1263 | struct GNUNET_CONFIGURATION_Handle *cfg) | 1122 | struct |
1123 | GNUNET_CONFIGURATION_Handle | ||
1124 | *cfg) | ||
1264 | { | 1125 | { |
1265 | static int once; | 1126 | static int once; |
1266 | GtkCellRendererText *rt; | 1127 | GtkCellRendererText *rt; |
1267 | 1128 | ||
1268 | rt = GTK_CELL_RENDERER_TEXT(widget); | 1129 | rt = GTK_CELL_RENDERER_TEXT (widget); |
1269 | if (NULL == rt) | 1130 | if (NULL == rt) |
1270 | return GNUNET_SYSERR; | 1131 | return GNUNET_SYSERR; |
1271 | if (0 != once++) | 1132 | if (0 != once++) |
1272 | return GNUNET_OK; | 1133 | return GNUNET_OK; |
1273 | g_signal_connect (rt, | 1134 | g_signal_connect (rt, "edited", |
1274 | "edited", | 1135 | G_CALLBACK (&save_vpn_dns_service_targethostname), NULL); |
1275 | G_CALLBACK (&save_vpn_dns_service_targethostname), | ||
1276 | NULL); | ||
1277 | return GNUNET_OK; | 1136 | return GNUNET_OK; |
1278 | } | 1137 | } |
1279 | 1138 | ||
@@ -1292,10 +1151,8 @@ vpn_dns_service_targethostname_install_edited_handler (const void *cls, | |||
1292 | * @param user_data NULL | 1151 | * @param user_data NULL |
1293 | */ | 1152 | */ |
1294 | static void | 1153 | static void |
1295 | save_vpn_dns_service_targetport (GtkCellRendererText *renderer, | 1154 | save_vpn_dns_service_targetport (GtkCellRendererText * renderer, gchar * path, |
1296 | gchar *path, | 1155 | gchar * new_text, gpointer user_data) |
1297 | gchar *new_text, | ||
1298 | gpointer user_data) | ||
1299 | { | 1156 | { |
1300 | GtkTreeModel *tm; | 1157 | GtkTreeModel *tm; |
1301 | GtkListStore *ls; | 1158 | GtkListStore *ls; |
@@ -1303,32 +1160,30 @@ save_vpn_dns_service_targetport (GtkCellRendererText *renderer, | |||
1303 | int port; | 1160 | int port; |
1304 | 1161 | ||
1305 | port = atoi (new_text); | 1162 | port = atoi (new_text); |
1306 | if ( (port < 1) || (port > UINT16_MAX) ) | 1163 | if ((port < 1) || (port > UINT16_MAX)) |
1307 | { | 1164 | { |
1308 | /* invalid port, FIXME: warn */ | 1165 | /* invalid port, FIXME: warn */ |
1309 | return; | 1166 | return; |
1310 | } | 1167 | } |
1311 | tm = GTK_TREE_MODEL (GNUNET_SETUP_get_object ("vpn_dns_config_liststore")); | 1168 | tm = GTK_TREE_MODEL (GNUNET_SETUP_get_object ("vpn_dns_config_liststore")); |
1312 | if (NULL == tm) | 1169 | if (NULL == tm) |
1313 | { | 1170 | { |
1314 | GNUNET_break (0); | 1171 | GNUNET_break (0); |
1315 | return; | 1172 | return; |
1316 | } | 1173 | } |
1317 | ls = GTK_LIST_STORE (tm); | 1174 | ls = GTK_LIST_STORE (tm); |
1318 | if (NULL == ls) | 1175 | if (NULL == ls) |
1319 | { | 1176 | { |
1320 | GNUNET_break (0); | 1177 | GNUNET_break (0); |
1321 | return; | 1178 | return; |
1322 | } | 1179 | } |
1323 | if (TRUE != gtk_tree_model_get_iter_from_string (tm, &iter, path)) | 1180 | if (TRUE != gtk_tree_model_get_iter_from_string (tm, &iter, path)) |
1324 | { | 1181 | { |
1325 | GNUNET_break (0); | 1182 | GNUNET_break (0); |
1326 | return; | 1183 | return; |
1327 | } | 1184 | } |
1328 | /* update model */ | 1185 | /* update model */ |
1329 | gtk_list_store_set (ls, &iter, | 1186 | gtk_list_store_set (ls, &iter, 2, (guint) port, -1); |
1330 | 2, (guint) port, | ||
1331 | -1); | ||
1332 | /* update configuration */ | 1187 | /* update configuration */ |
1333 | update_vpn_dns_configuration (tm); | 1188 | update_vpn_dns_configuration (tm); |
1334 | } | 1189 | } |
@@ -1346,23 +1201,23 @@ save_vpn_dns_service_targetport (GtkCellRendererText *renderer, | |||
1346 | */ | 1201 | */ |
1347 | static int | 1202 | static int |
1348 | vpn_dns_service_targetport_install_edited_handler (const void *cls, | 1203 | vpn_dns_service_targetport_install_edited_handler (const void *cls, |
1349 | const char *section, | 1204 | const char *section, |
1350 | const char *option, | 1205 | const char *option, |
1351 | GObject *widget, | 1206 | GObject * widget, |
1352 | struct GNUNET_CONFIGURATION_Handle *cfg) | 1207 | struct |
1208 | GNUNET_CONFIGURATION_Handle | ||
1209 | *cfg) | ||
1353 | { | 1210 | { |
1354 | static int once; | 1211 | static int once; |
1355 | GtkCellRendererText *rt; | 1212 | GtkCellRendererText *rt; |
1356 | 1213 | ||
1357 | rt = GTK_CELL_RENDERER_TEXT(widget); | 1214 | rt = GTK_CELL_RENDERER_TEXT (widget); |
1358 | if (NULL == rt) | 1215 | if (NULL == rt) |
1359 | return GNUNET_SYSERR; | 1216 | return GNUNET_SYSERR; |
1360 | if (0 != once++) | 1217 | if (0 != once++) |
1361 | return GNUNET_OK; | 1218 | return GNUNET_OK; |
1362 | g_signal_connect (rt, | 1219 | g_signal_connect (rt, "edited", G_CALLBACK (&save_vpn_dns_service_targetport), |
1363 | "edited", | 1220 | NULL); |
1364 | G_CALLBACK (&save_vpn_dns_service_targetport), | ||
1365 | NULL); | ||
1366 | return GNUNET_OK; | 1221 | return GNUNET_OK; |
1367 | } | 1222 | } |
1368 | 1223 | ||
@@ -1370,47 +1225,47 @@ vpn_dns_service_targetport_install_edited_handler (const void *cls, | |||
1370 | /** | 1225 | /** |
1371 | * Hide "min connected friends" option if in F2F-only mode. | 1226 | * Hide "min connected friends" option if in F2F-only mode. |
1372 | */ | 1227 | */ |
1373 | static struct GNUNET_SETUP_VisibilitySpecification hide_min_connected_friends[] = | 1228 | static struct GNUNET_SETUP_VisibilitySpecification hide_min_connected_friends[] |
1374 | { | 1229 | = { |
1375 | { "GNUNET_setup_minimum_friends_label", NULL, REX_YES }, | 1230 | {"GNUNET_setup_minimum_friends_label", NULL, REX_YES}, |
1376 | { "GNUNET_setup_minimum_friends_spinbutton", NULL, REX_YES }, | 1231 | {"GNUNET_setup_minimum_friends_spinbutton", NULL, REX_YES}, |
1377 | { NULL, NULL, NULL } | 1232 | {NULL, NULL, NULL} |
1378 | }; | 1233 | }; |
1379 | 1234 | ||
1380 | 1235 | ||
1381 | /** | 1236 | /** |
1382 | * Hide "hostlist" options if hostlist is not in use. | 1237 | * Hide "hostlist" options if hostlist is not in use. |
1383 | */ | 1238 | */ |
1384 | static struct GNUNET_SETUP_VisibilitySpecification hide_hostlist_options[] = | 1239 | static struct GNUNET_SETUP_VisibilitySpecification hide_hostlist_options[] = { |
1385 | { | 1240 | {"GNUNET_setup_hostlist_client_enable_checkbutton", "(^| )hostlist($| )", |
1386 | { "GNUNET_setup_hostlist_client_enable_checkbutton", "(^| )hostlist($| )", NULL }, | 1241 | NULL}, |
1387 | { "GNUNET_setup_hostlist_client_learn_checkbutton", "(^| )hostlist($| )", NULL }, | 1242 | {"GNUNET_setup_hostlist_client_learn_checkbutton", "(^| )hostlist($| )", |
1388 | { "GNUNET_setup_hostlist_options_hbox", "(^| )hostlist($| )", NULL }, | 1243 | NULL}, |
1389 | { "GNUNET_setup_hostlist_frame", "(^| )hostlist($| )", NULL }, | 1244 | {"GNUNET_setup_hostlist_options_hbox", "(^| )hostlist($| )", NULL}, |
1390 | { NULL, NULL, NULL } | 1245 | {"GNUNET_setup_hostlist_frame", "(^| )hostlist($| )", NULL}, |
1246 | {NULL, NULL, NULL} | ||
1391 | }; | 1247 | }; |
1392 | 1248 | ||
1393 | 1249 | ||
1394 | /** | 1250 | /** |
1395 | * Hide "exit" options if VPN exit is not in use. | 1251 | * Hide "exit" options if VPN exit is not in use. |
1396 | */ | 1252 | */ |
1397 | static struct GNUNET_SETUP_VisibilitySpecification hide_exit_options[] = | 1253 | static struct GNUNET_SETUP_VisibilitySpecification hide_exit_options[] = { |
1398 | { | 1254 | {"GNUNET_setup_vpn_exit_frame", "(^| )exit($| )", NULL}, |
1399 | { "GNUNET_setup_vpn_exit_frame", "(^| )exit($| )", NULL }, | 1255 | {"GNUNET_setup_vpn_service_configuration_frame", "(^| )exit($| )", NULL}, |
1400 | { "GNUNET_setup_vpn_service_configuration_frame", "(^| )exit($| )", NULL }, | 1256 | {NULL, NULL, NULL} |
1401 | { NULL, NULL, NULL } | ||
1402 | }; | 1257 | }; |
1403 | 1258 | ||
1404 | 1259 | ||
1405 | /** | 1260 | /** |
1406 | * Hide "hostlist" server options if hostlist server is not in use. | 1261 | * Hide "hostlist" server options if hostlist server is not in use. |
1407 | */ | 1262 | */ |
1408 | static struct GNUNET_SETUP_VisibilitySpecification hide_hostlist_server_options[] = | 1263 | static struct GNUNET_SETUP_VisibilitySpecification |
1409 | { | 1264 | hide_hostlist_server_options[] = { |
1410 | { "GNUNET_setup_hostlist_advertise_checkbutton", "(^| )-p($| )", NULL }, | 1265 | {"GNUNET_setup_hostlist_advertise_checkbutton", "(^| )-p($| )", NULL}, |
1411 | { "GNUNET_setup_hostlist_port_label", "(^| )-p($| )", NULL }, | 1266 | {"GNUNET_setup_hostlist_port_label", "(^| )-p($| )", NULL}, |
1412 | { "GNUNET_setup_hostlist_server_port_spin_button", "(^| )-p($| )", NULL }, | 1267 | {"GNUNET_setup_hostlist_server_port_spin_button", "(^| )-p($| )", NULL}, |
1413 | { NULL, NULL, NULL } | 1268 | {NULL, NULL, NULL} |
1414 | }; | 1269 | }; |
1415 | 1270 | ||
1416 | 1271 | ||
@@ -1418,10 +1273,9 @@ static struct GNUNET_SETUP_VisibilitySpecification hide_hostlist_server_options[ | |||
1418 | /** | 1273 | /** |
1419 | * Hide "fs tab" if FS not active. | 1274 | * Hide "fs tab" if FS not active. |
1420 | */ | 1275 | */ |
1421 | static struct GNUNET_SETUP_VisibilitySpecification hide_fs_tab[] = | 1276 | static struct GNUNET_SETUP_VisibilitySpecification hide_fs_tab[] = { |
1422 | { | 1277 | {"GNUNET_setup_fs_main_vbox", "(^| )fs($| )", NULL}, |
1423 | { "GNUNET_setup_fs_main_vbox", "(^| )fs($| )", NULL }, | 1278 | {NULL, NULL, NULL} |
1424 | { NULL, NULL, NULL } | ||
1425 | }; | 1279 | }; |
1426 | 1280 | ||
1427 | 1281 | ||
@@ -1429,10 +1283,9 @@ static struct GNUNET_SETUP_VisibilitySpecification hide_fs_tab[] = | |||
1429 | /** | 1283 | /** |
1430 | * Hide "vpn tab" if VPN not active. | 1284 | * Hide "vpn tab" if VPN not active. |
1431 | */ | 1285 | */ |
1432 | static struct GNUNET_SETUP_VisibilitySpecification hide_vpn_tab[] = | 1286 | static struct GNUNET_SETUP_VisibilitySpecification hide_vpn_tab[] = { |
1433 | { | 1287 | {"GNUNET_setup_vpn_vbox", "(^| )vpn($| )", NULL}, |
1434 | { "GNUNET_setup_vpn_vbox", "(^| )vpn($| )", NULL }, | 1288 | {NULL, NULL, NULL} |
1435 | { NULL, NULL, NULL } | ||
1436 | }; | 1289 | }; |
1437 | 1290 | ||
1438 | 1291 | ||
@@ -1440,1136 +1293,1055 @@ static struct GNUNET_SETUP_VisibilitySpecification hide_vpn_tab[] = | |||
1440 | /** | 1293 | /** |
1441 | * Hide "tcp tab" if TCP not active. | 1294 | * Hide "tcp tab" if TCP not active. |
1442 | */ | 1295 | */ |
1443 | static struct GNUNET_SETUP_VisibilitySpecification hide_tcp_tab[] = | 1296 | static struct GNUNET_SETUP_VisibilitySpecification hide_tcp_tab[] = { |
1444 | { | 1297 | {"GNUNET_setup_transport_tcp_vbox", "(^| )tcp($| )", NULL}, |
1445 | { "GNUNET_setup_transport_tcp_vbox", "(^| )tcp($| )", NULL }, | 1298 | {NULL, NULL, NULL} |
1446 | { NULL, NULL, NULL } | ||
1447 | }; | 1299 | }; |
1448 | 1300 | ||
1449 | 1301 | ||
1450 | /** | 1302 | /** |
1451 | * Hide "udp tab" if UDP not active. | 1303 | * Hide "udp tab" if UDP not active. |
1452 | */ | 1304 | */ |
1453 | static struct GNUNET_SETUP_VisibilitySpecification hide_udp_tab[] = | 1305 | static struct GNUNET_SETUP_VisibilitySpecification hide_udp_tab[] = { |
1454 | { | 1306 | {"GNUNET_setup_transport_udp_vbox", "(^| )udp($| )", NULL}, |
1455 | { "GNUNET_setup_transport_udp_vbox", "(^| )udp($| )", NULL }, | 1307 | {NULL, NULL, NULL} |
1456 | { NULL, NULL, NULL } | ||
1457 | }; | 1308 | }; |
1458 | 1309 | ||
1459 | 1310 | ||
1460 | /** | 1311 | /** |
1461 | * Hide "http tab" if HTTP not active. | 1312 | * Hide "http tab" if HTTP not active. |
1462 | */ | 1313 | */ |
1463 | static struct GNUNET_SETUP_VisibilitySpecification hide_http_tab[] = | 1314 | static struct GNUNET_SETUP_VisibilitySpecification hide_http_tab[] = { |
1464 | { | 1315 | {"GNUNET_setup_transport_http_vbox", "(^| )http($| )", NULL}, |
1465 | { "GNUNET_setup_transport_http_vbox", "(^| )http($| )", NULL }, | 1316 | {NULL, NULL, NULL} |
1466 | { NULL, NULL, NULL } | ||
1467 | }; | 1317 | }; |
1468 | 1318 | ||
1469 | 1319 | ||
1470 | /** | 1320 | /** |
1471 | * Hide "https tab" if HTTPS not active. | 1321 | * Hide "https tab" if HTTPS not active. |
1472 | */ | 1322 | */ |
1473 | static struct GNUNET_SETUP_VisibilitySpecification hide_https_tab[] = | 1323 | static struct GNUNET_SETUP_VisibilitySpecification hide_https_tab[] = { |
1474 | { | 1324 | {"GNUNET_setup_transport_https_vbox", "(^| )https($| )", NULL}, |
1475 | { "GNUNET_setup_transport_https_vbox", "(^| )https($| )", NULL }, | 1325 | {NULL, NULL, NULL} |
1476 | { NULL, NULL, NULL } | ||
1477 | }; | 1326 | }; |
1478 | 1327 | ||
1479 | 1328 | ||
1480 | /** | 1329 | /** |
1481 | * Hide "dv tab" if DV not active. | 1330 | * Hide "dv tab" if DV not active. |
1482 | */ | 1331 | */ |
1483 | static struct GNUNET_SETUP_VisibilitySpecification hide_dv_tab[] = | 1332 | static struct GNUNET_SETUP_VisibilitySpecification hide_dv_tab[] = { |
1484 | { | 1333 | {"GNUNET_setup_transport_dv_vbox", "(^| )dv($| )", NULL}, |
1485 | { "GNUNET_setup_transport_dv_vbox", "(^| )dv($| )", NULL }, | 1334 | {NULL, NULL, NULL} |
1486 | { NULL, NULL, NULL } | ||
1487 | }; | 1335 | }; |
1488 | 1336 | ||
1489 | 1337 | ||
1490 | /** | 1338 | /** |
1491 | * Hide "wlan tab" if WLAN not active. | 1339 | * Hide "wlan tab" if WLAN not active. |
1492 | */ | 1340 | */ |
1493 | static struct GNUNET_SETUP_VisibilitySpecification hide_wlan_tab[] = | 1341 | static struct GNUNET_SETUP_VisibilitySpecification hide_wlan_tab[] = { |
1494 | { | 1342 | {"GNUNET_setup_transport_wlan_vbox", "(^| )wlan($| )", NULL}, |
1495 | { "GNUNET_setup_transport_wlan_vbox", "(^| )wlan($| )", NULL }, | 1343 | {NULL, NULL, NULL} |
1496 | { NULL, NULL, NULL } | ||
1497 | }; | 1344 | }; |
1498 | 1345 | ||
1499 | 1346 | ||
1500 | /** | 1347 | /** |
1501 | * Hide "sqlite datastore" tab if sqlite not active. | 1348 | * Hide "sqlite datastore" tab if sqlite not active. |
1502 | */ | 1349 | */ |
1503 | static struct GNUNET_SETUP_VisibilitySpecification hide_sqlite_datastore_tab[] = | 1350 | static struct GNUNET_SETUP_VisibilitySpecification hide_sqlite_datastore_tab[] = { |
1504 | { | 1351 | {"GNUNET_setup_fs_datastore_sqlite_label", "^sqlite$", NULL}, |
1505 | { "GNUNET_setup_fs_datastore_sqlite_label", "^sqlite$", NULL }, | 1352 | {NULL, NULL, NULL} |
1506 | { NULL, NULL, NULL } | ||
1507 | }; | 1353 | }; |
1508 | 1354 | ||
1509 | 1355 | ||
1510 | /** | 1356 | /** |
1511 | * Hide "mysql datastore" tab if mysql not active. | 1357 | * Hide "mysql datastore" tab if mysql not active. |
1512 | */ | 1358 | */ |
1513 | static struct GNUNET_SETUP_VisibilitySpecification hide_mysql_datastore_tab[] = | 1359 | static struct GNUNET_SETUP_VisibilitySpecification hide_mysql_datastore_tab[] = { |
1514 | { | 1360 | {"GNUNET_setup_datastore_mysql_vbox", "^mysql$", NULL}, |
1515 | { "GNUNET_setup_datastore_mysql_vbox", "^mysql$", NULL }, | 1361 | {NULL, NULL, NULL} |
1516 | { NULL, NULL, NULL } | ||
1517 | }; | 1362 | }; |
1518 | 1363 | ||
1519 | 1364 | ||
1520 | /** | 1365 | /** |
1521 | * Hide "postgres datastore" tab if postgres not active. | 1366 | * Hide "postgres datastore" tab if postgres not active. |
1522 | */ | 1367 | */ |
1523 | static struct GNUNET_SETUP_VisibilitySpecification hide_postgres_datastore_tab[] = | 1368 | static struct GNUNET_SETUP_VisibilitySpecification hide_postgres_datastore_tab[] |
1524 | { | 1369 | = { |
1525 | { "GNUNET_setup_datastore_postgres_hbox", "^postgres$", NULL }, | 1370 | {"GNUNET_setup_datastore_postgres_hbox", "^postgres$", NULL}, |
1526 | { NULL, NULL, NULL } | 1371 | {NULL, NULL, NULL} |
1527 | }; | 1372 | }; |
1528 | 1373 | ||
1529 | 1374 | ||
1530 | /** | 1375 | /** |
1531 | * Hide "sqlite datacache" tab if sqlite not active. | 1376 | * Hide "sqlite datacache" tab if sqlite not active. |
1532 | */ | 1377 | */ |
1533 | static struct GNUNET_SETUP_VisibilitySpecification hide_sqlite_datacache_tab[] = | 1378 | static struct GNUNET_SETUP_VisibilitySpecification hide_sqlite_datacache_tab[] = { |
1534 | { | 1379 | {"GNUNET_setup_fs_datacache_sqlite_label", "^sqlite$", NULL}, |
1535 | { "GNUNET_setup_fs_datacache_sqlite_label", "^sqlite$", NULL }, | 1380 | {NULL, NULL, NULL} |
1536 | { NULL, NULL, NULL } | ||
1537 | }; | 1381 | }; |
1538 | 1382 | ||
1539 | 1383 | ||
1540 | /** | 1384 | /** |
1541 | * Hide "mysql datacache" tab if mysql not active. | 1385 | * Hide "mysql datacache" tab if mysql not active. |
1542 | */ | 1386 | */ |
1543 | static struct GNUNET_SETUP_VisibilitySpecification hide_mysql_datacache_tab[] = | 1387 | static struct GNUNET_SETUP_VisibilitySpecification hide_mysql_datacache_tab[] = { |
1544 | { | 1388 | {"GNUNET_setup_datacache_mysql_vbox", "^mysql$", NULL}, |
1545 | { "GNUNET_setup_datacache_mysql_vbox", "^mysql$", NULL }, | 1389 | {NULL, NULL, NULL} |
1546 | { NULL, NULL, NULL } | ||
1547 | }; | 1390 | }; |
1548 | 1391 | ||
1549 | 1392 | ||
1550 | /** | 1393 | /** |
1551 | * Hide "postgres datacache" tab if postgres not active. | 1394 | * Hide "postgres datacache" tab if postgres not active. |
1552 | */ | 1395 | */ |
1553 | static struct GNUNET_SETUP_VisibilitySpecification hide_postgres_datacache_tab[] = | 1396 | static struct GNUNET_SETUP_VisibilitySpecification hide_postgres_datacache_tab[] |
1554 | { | 1397 | = { |
1555 | { "GNUNET_setup_datacache_postgres_hbox", "^postgres$", NULL }, | 1398 | {"GNUNET_setup_datacache_postgres_hbox", "^postgres$", NULL}, |
1556 | { NULL, NULL, NULL } | 1399 | {NULL, NULL, NULL} |
1557 | }; | 1400 | }; |
1558 | 1401 | ||
1559 | 1402 | ||
1560 | /** | 1403 | /** |
1561 | * Hide advertised TCP port if port is zero. | 1404 | * Hide advertised TCP port if port is zero. |
1562 | */ | 1405 | */ |
1563 | static struct GNUNET_SETUP_VisibilitySpecification hide_all_tcp_options[] = | 1406 | static struct GNUNET_SETUP_VisibilitySpecification hide_all_tcp_options[] = { |
1564 | { | 1407 | {"GNUNET_setup_transport_tcp_adv_port_hbox", NULL, "^0$"}, |
1565 | { "GNUNET_setup_transport_tcp_adv_port_hbox", NULL, "^0$" }, | 1408 | {NULL, NULL, NULL} |
1566 | { NULL, NULL, NULL } | ||
1567 | }; | 1409 | }; |
1568 | 1410 | ||
1569 | 1411 | ||
1570 | /** | 1412 | /** |
1571 | * Hide NATed peer options. | 1413 | * Hide NATed peer options. |
1572 | */ | 1414 | */ |
1573 | static struct GNUNET_SETUP_VisibilitySpecification toggle_nat_options[] = | 1415 | static struct GNUNET_SETUP_VisibilitySpecification toggle_nat_options[] = { |
1574 | { | 1416 | {"GNUNET_setup_transport_hole_punched_checkbutton", "^YES$", NULL}, |
1575 | { "GNUNET_setup_transport_hole_punched_checkbutton", "^YES$", NULL }, | 1417 | {"GNUNET_setup_transport_upnp_enable_checkbutton", "^YES$", NULL}, |
1576 | { "GNUNET_setup_transport_upnp_enable_checkbutton", "^YES$", NULL }, | 1418 | {"GNUNET_setup_transport_icmp_server_enable_checkbutton", "^YES$", NULL}, |
1577 | { "GNUNET_setup_transport_icmp_server_enable_checkbutton", "^YES$", NULL }, | 1419 | {"GNUNET_setup_transport_external_ip_hbox", "^YES$", NULL}, |
1578 | { "GNUNET_setup_transport_external_ip_hbox", "^YES$", NULL }, | 1420 | {NULL, NULL, NULL} |
1579 | { NULL, NULL, NULL } | ||
1580 | }; | 1421 | }; |
1581 | 1422 | ||
1582 | /** | 1423 | /** |
1583 | * Hide hole-punched NATed peer options. | 1424 | * Hide hole-punched NATed peer options. |
1584 | */ | 1425 | */ |
1585 | static struct GNUNET_SETUP_VisibilitySpecification toggle_nat_punched_options[] = | 1426 | static struct GNUNET_SETUP_VisibilitySpecification toggle_nat_punched_options[] |
1586 | { | 1427 | = { |
1587 | { "GNUNET_setup_transport_upnp_enable_checkbutton", "^NO$", NULL }, | 1428 | {"GNUNET_setup_transport_upnp_enable_checkbutton", "^NO$", NULL}, |
1588 | { "GNUNET_setup_transport_icmp_server_enable_checkbutton", "^NO$", NULL }, | 1429 | {"GNUNET_setup_transport_icmp_server_enable_checkbutton", "^NO$", NULL}, |
1589 | { NULL, NULL, NULL } | 1430 | {NULL, NULL, NULL} |
1590 | }; | 1431 | }; |
1591 | 1432 | ||
1592 | 1433 | ||
1593 | /** | 1434 | /** |
1594 | * Hide internal IP options. | 1435 | * Hide internal IP options. |
1595 | */ | 1436 | */ |
1596 | static struct GNUNET_SETUP_VisibilitySpecification toggle_internal_ip[] = | 1437 | static struct GNUNET_SETUP_VisibilitySpecification toggle_internal_ip[] = { |
1597 | { | 1438 | {"GNUNET_setup_transport_internal_ip_hbox", "^YES$", NULL}, |
1598 | { "GNUNET_setup_transport_internal_ip_hbox", "^YES$", NULL }, | 1439 | {NULL, NULL, NULL} |
1599 | { NULL, NULL, NULL } | ||
1600 | }; | 1440 | }; |
1601 | 1441 | ||
1602 | 1442 | ||
1603 | /** | 1443 | /** |
1604 | * Option specification data. | 1444 | * Option specification data. |
1605 | */ | 1445 | */ |
1606 | const struct GNUNET_SETUP_OptionSpecification option_specifications[] = | 1446 | const struct GNUNET_SETUP_OptionSpecification option_specifications[] = { |
1607 | { | ||
1608 | |||
1609 | /* GENERAL TAB */ | ||
1610 | |||
1611 | { | ||
1612 | "GNUNET_setup_friends_only_checkbutton", | ||
1613 | "toggled", | ||
1614 | "topology", | ||
1615 | "FRIENDS-ONLY", | ||
1616 | gettext_noop ("Should GNUnet exclusively connect to friends?"), | ||
1617 | "https://gnunet.org/configuration-f2f", | ||
1618 | &load_yes_no, | ||
1619 | &save_yes_no, NULL, | ||
1620 | hide_min_connected_friends | ||
1621 | }, | ||
1622 | |||
1623 | { | ||
1624 | "GNUNET_setup_friends_filechooserbutton", | ||
1625 | "selection-changed", | ||
1626 | "topology", | ||
1627 | "FRIENDS", | ||
1628 | gettext_noop ("Friends file containing the list of friendly peers"), | ||
1629 | "https://gnunet.org/configuration-f2f", | ||
1630 | &load_filename, | ||
1631 | &save_filename, NULL, | ||
1632 | NULL | ||
1633 | }, | ||
1634 | |||
1635 | { | ||
1636 | "GNUNET_setup_minimum_friends_spinbutton", | ||
1637 | "value-changed", | ||
1638 | "topology", | ||
1639 | "MINIMUM-FRIENDS", | ||
1640 | gettext_noop ("Minimum number of friendly connections"), | ||
1641 | "https://gnunet.org/configuration-f2f", | ||
1642 | &load_number, | ||
1643 | &save_number, NULL, | ||
1644 | NULL | ||
1645 | }, | ||
1646 | 1447 | ||
1647 | { | 1448 | /* GENERAL TAB */ |
1648 | "GNUNET_setup_general_services_topology_checkbutton", | ||
1649 | "toggled", | ||
1650 | "arm", | ||
1651 | "DEFAULTSERVICES", | ||
1652 | gettext_noop ("Topology should always be loaded"), | ||
1653 | "https://gnunet.org/configuration-topology", | ||
1654 | &load_option_list, | ||
1655 | &save_option_list, "topology", | ||
1656 | NULL | ||
1657 | }, | ||
1658 | 1449 | ||
1659 | { | 1450 | { |
1660 | "GNUNET_setup_general_services_hostlist_checkbutton", | 1451 | "GNUNET_setup_friends_only_checkbutton", |
1661 | "toggled", | 1452 | "toggled", |
1662 | "arm", | 1453 | "topology", |
1663 | "DEFAULTSERVICES", | 1454 | "FRIENDS-ONLY", |
1664 | gettext_noop ("Should hostlist support be started automatically on startup?"), | 1455 | gettext_noop ("Should GNUnet exclusively connect to friends?"), |
1665 | "https://gnunet.org/configuration-hostlist", | 1456 | "https://gnunet.org/configuration-f2f", |
1666 | &load_option_list, | 1457 | &load_yes_no, |
1667 | &save_option_list, "hostlist", | 1458 | &save_yes_no, NULL, |
1668 | hide_hostlist_options | 1459 | hide_min_connected_friends}, |
1669 | }, | ||
1670 | 1460 | ||
1461 | { | ||
1462 | "GNUNET_setup_friends_filechooserbutton", | ||
1463 | "selection-changed", | ||
1464 | "topology", | ||
1465 | "FRIENDS", | ||
1466 | gettext_noop ("Friends file containing the list of friendly peers"), | ||
1467 | "https://gnunet.org/configuration-f2f", | ||
1468 | &load_filename, | ||
1469 | &save_filename, NULL, | ||
1470 | NULL}, | ||
1671 | 1471 | ||
1672 | { | 1472 | { |
1673 | "GNUNET_setup_general_services_fs_checkbutton", | 1473 | "GNUNET_setup_minimum_friends_spinbutton", |
1674 | "toggled", | 1474 | "value-changed", |
1675 | "arm", | 1475 | "topology", |
1676 | "DEFAULTSERVICES", | 1476 | "MINIMUM-FRIENDS", |
1677 | gettext_noop ("Should file-sharing be started automatically on startup?"), | 1477 | gettext_noop ("Minimum number of friendly connections"), |
1678 | "https://gnunet.org/configuration-fs", | 1478 | "https://gnunet.org/configuration-f2f", |
1679 | &load_option_list, | 1479 | &load_number, |
1680 | &save_option_list, "fs", | 1480 | &save_number, NULL, |
1681 | hide_fs_tab | 1481 | NULL}, |
1682 | }, | ||
1683 | 1482 | ||
1684 | { | 1483 | { |
1685 | "GNUNET_setup_general_services_vpn_checkbutton", | 1484 | "GNUNET_setup_general_services_topology_checkbutton", |
1686 | "toggled", | 1485 | "toggled", |
1687 | "arm", | 1486 | "arm", |
1688 | "DEFAULTSERVICES", | 1487 | "DEFAULTSERVICES", |
1689 | gettext_noop ("Should the VPN be started automatically on startup?"), | 1488 | gettext_noop ("Topology should always be loaded"), |
1690 | "https://gnunet.org/configuration-vpn", | 1489 | "https://gnunet.org/configuration-topology", |
1691 | &load_option_list, | 1490 | &load_option_list, |
1692 | &save_option_list, "vpn", | 1491 | &save_option_list, "topology", |
1693 | hide_vpn_tab | 1492 | NULL}, |
1694 | }, | ||
1695 | 1493 | ||
1696 | { | 1494 | { |
1697 | "GNUNET_setup_hostlist_client_enable_checkbutton", | 1495 | "GNUNET_setup_general_services_hostlist_checkbutton", |
1698 | "toggled", | 1496 | "toggled", |
1699 | "hostlist", | 1497 | "arm", |
1700 | "OPTIONS", | 1498 | "DEFAULTSERVICES", |
1701 | gettext_noop ("Should GNUnet learn about other peers using hostlists"), | 1499 | gettext_noop |
1702 | "https://gnunet.org/configuration-hostlist", | 1500 | ("Should hostlist support be started automatically on startup?"), |
1703 | &load_option_list, | 1501 | "https://gnunet.org/configuration-hostlist", |
1704 | &save_option_list, "-b", | 1502 | &load_option_list, |
1705 | NULL | 1503 | &save_option_list, "hostlist", |
1706 | }, | 1504 | hide_hostlist_options}, |
1707 | 1505 | ||
1708 | { | ||
1709 | "GNUNET_setup_hostlist_client_learn_checkbutton", | ||
1710 | "toggled", | ||
1711 | "hostlist", | ||
1712 | "OPTIONS", | ||
1713 | gettext_noop ("Should GNUnet learn hostlists from other peers"), | ||
1714 | "https://gnunet.org/configuration-hostlist", | ||
1715 | &load_option_list, | ||
1716 | &save_option_list, "-e", | ||
1717 | NULL | ||
1718 | }, | ||
1719 | 1506 | ||
1720 | { | 1507 | { |
1721 | "GNUNET_setup_hostlist_offer_hostlist_checkbutton", | 1508 | "GNUNET_setup_general_services_fs_checkbutton", |
1722 | "toggled", | 1509 | "toggled", |
1723 | "hostlist", | 1510 | "arm", |
1724 | "OPTIONS", | 1511 | "DEFAULTSERVICES", |
1725 | gettext_noop ("Should this peer offer a hostlist to other peers"), | 1512 | gettext_noop ("Should file-sharing be started automatically on startup?"), |
1726 | "https://gnunet.org/configuration-hostlist-server", | 1513 | "https://gnunet.org/configuration-fs", |
1727 | &load_option_list, | 1514 | &load_option_list, |
1728 | &save_option_list, "-p", | 1515 | &save_option_list, "fs", |
1729 | hide_hostlist_server_options | 1516 | hide_fs_tab}, |
1730 | }, | ||
1731 | 1517 | ||
1732 | { | 1518 | { |
1733 | "GNUNET_setup_hostlist_advertise_checkbutton", | 1519 | "GNUNET_setup_general_services_vpn_checkbutton", |
1734 | "toggled", | 1520 | "toggled", |
1735 | "hostlist", | 1521 | "arm", |
1736 | "OPTIONS", | 1522 | "DEFAULTSERVICES", |
1737 | gettext_noop ("Should this peer advertise its hostlist to other peers"), | 1523 | gettext_noop ("Should the VPN be started automatically on startup?"), |
1738 | "https://gnunet.org/configuration-hostlist-server", | 1524 | "https://gnunet.org/configuration-vpn", |
1739 | &load_option_list, | 1525 | &load_option_list, |
1740 | &save_option_list, "-a", | 1526 | &save_option_list, "vpn", |
1741 | NULL | 1527 | hide_vpn_tab}, |
1742 | }, | ||
1743 | 1528 | ||
1744 | { | 1529 | { |
1745 | "GNUNET_setup_hostlist_server_port_spin_button", | 1530 | "GNUNET_setup_hostlist_client_enable_checkbutton", |
1746 | "value-changed", | 1531 | "toggled", |
1747 | "hostlist", | 1532 | "hostlist", |
1748 | "HTTPPORT", | 1533 | "OPTIONS", |
1749 | gettext_noop ("Port this peers hostlist should be offered on"), | 1534 | gettext_noop ("Should GNUnet learn about other peers using hostlists"), |
1750 | "https://gnunet.org/configuration-hostlist-server", | 1535 | "https://gnunet.org/configuration-hostlist", |
1751 | &load_number, | 1536 | &load_option_list, |
1752 | &save_number, NULL, | 1537 | &save_option_list, "-b", |
1753 | NULL | 1538 | NULL}, |
1754 | }, | ||
1755 | 1539 | ||
1756 | { | 1540 | { |
1757 | "GNUNET_setup_hostlist_url_liststore", | 1541 | "GNUNET_setup_hostlist_client_learn_checkbutton", |
1758 | "row-changed", | 1542 | "toggled", |
1759 | "hostlist", | 1543 | "hostlist", |
1760 | "SERVERS", | 1544 | "OPTIONS", |
1761 | NULL, NULL, | 1545 | gettext_noop ("Should GNUnet learn hostlists from other peers"), |
1762 | &load_string_list_store, | 1546 | "https://gnunet.org/configuration-hostlist", |
1763 | &save_string_list_store, NULL, | 1547 | &load_option_list, |
1764 | NULL | 1548 | &save_option_list, "-e", |
1765 | }, | 1549 | NULL}, |
1766 | 1550 | ||
1767 | { | 1551 | { |
1768 | "GNUNET_setup_hostlist_url_treeview", | 1552 | "GNUNET_setup_hostlist_offer_hostlist_checkbutton", |
1769 | NULL, NULL, NULL, /* FIXME */ | 1553 | "toggled", |
1770 | gettext_noop ("Known hostlist URLs"), | 1554 | "hostlist", |
1771 | "https://gnunet.org/configuration-hostlist", | 1555 | "OPTIONS", |
1772 | NULL, NULL, NULL, /* FIXME */ | 1556 | gettext_noop ("Should this peer offer a hostlist to other peers"), |
1773 | NULL | 1557 | "https://gnunet.org/configuration-hostlist-server", |
1774 | }, | 1558 | &load_option_list, |
1559 | &save_option_list, "-p", | ||
1560 | hide_hostlist_server_options}, | ||
1775 | 1561 | ||
1776 | { | 1562 | { |
1777 | "GNUNET_setup_bandwidth_out_spinbutton", | 1563 | "GNUNET_setup_hostlist_advertise_checkbutton", |
1778 | "value-changed", | 1564 | "toggled", |
1779 | "core", | 1565 | "hostlist", |
1780 | "TOTAL_QUOTA_OUT", | 1566 | "OPTIONS", |
1781 | gettext_noop ("How many bytes per second are we allowed to transmit?"), | 1567 | gettext_noop ("Should this peer advertise its hostlist to other peers"), |
1782 | "https://gnunet.org/configuration-bandwidth", | 1568 | "https://gnunet.org/configuration-hostlist-server", |
1783 | &load_number, | 1569 | &load_option_list, |
1784 | &save_number, NULL, | 1570 | &save_option_list, "-a", |
1785 | NULL | 1571 | NULL}, |
1786 | }, | ||
1787 | 1572 | ||
1788 | { | 1573 | { |
1789 | "GNUNET_setup_bandwidth_in_spinbutton", | 1574 | "GNUNET_setup_hostlist_server_port_spin_button", |
1790 | "value-changed", | 1575 | "value-changed", |
1791 | "core", | 1576 | "hostlist", |
1792 | "TOTAL_QUOTA_IN", | 1577 | "HTTPPORT", |
1793 | gettext_noop ("How many bytes per second are we allowed to receive?"), | 1578 | gettext_noop ("Port this peers hostlist should be offered on"), |
1794 | "https://gnunet.org/configuration-bandwidth", | 1579 | "https://gnunet.org/configuration-hostlist-server", |
1795 | &load_number, | 1580 | &load_number, |
1796 | &save_number, NULL, | 1581 | &save_number, NULL, |
1797 | NULL | 1582 | NULL}, |
1798 | }, | ||
1799 | |||
1800 | /* Transport TAB */ | ||
1801 | 1583 | ||
1802 | { | 1584 | { |
1803 | "GNUNET_setup_transport_tcp_checkbutton", | 1585 | "GNUNET_setup_hostlist_url_liststore", |
1804 | "toggled", | 1586 | "row-changed", |
1805 | "transport", | 1587 | "hostlist", |
1806 | "PLUGINS", | 1588 | "SERVERS", |
1807 | gettext_noop ("Enable communication via TCP"), | 1589 | NULL, NULL, |
1808 | "https://gnunet.org/configuration-tcp", | 1590 | &load_string_list_store, |
1809 | &load_option_list, | 1591 | &save_string_list_store, NULL, |
1810 | &save_option_list, "tcp", | 1592 | NULL}, |
1811 | hide_tcp_tab | ||
1812 | }, | ||
1813 | 1593 | ||
1814 | { | 1594 | { |
1815 | "GNUNET_setup_transport_udp_checkbutton", | 1595 | "GNUNET_setup_hostlist_url_treeview", |
1816 | "toggled", | 1596 | NULL, NULL, NULL, /* FIXME */ |
1817 | "transport", | 1597 | gettext_noop ("Known hostlist URLs"), |
1818 | "PLUGINS", | 1598 | "https://gnunet.org/configuration-hostlist", |
1819 | gettext_noop ("Enable communication via UDP"), | 1599 | NULL, NULL, NULL, /* FIXME */ |
1820 | "https://gnunet.org/configuration-udp", | 1600 | NULL}, |
1821 | &load_option_list, | ||
1822 | &save_option_list, "udp", | ||
1823 | hide_udp_tab | ||
1824 | }, | ||
1825 | 1601 | ||
1826 | { | 1602 | { |
1827 | "GNUNET_setup_transport_http_checkbutton", | 1603 | "GNUNET_setup_bandwidth_out_spinbutton", |
1828 | "toggled", | 1604 | "value-changed", |
1829 | "transport", | 1605 | "core", |
1830 | "PLUGINS", | 1606 | "TOTAL_QUOTA_OUT", |
1831 | gettext_noop ("Enable communication via HTTP"), | 1607 | gettext_noop ("How many bytes per second are we allowed to transmit?"), |
1832 | "https://gnunet.org/configuration-http", | 1608 | "https://gnunet.org/configuration-bandwidth", |
1833 | &load_option_list, | 1609 | &load_number, |
1834 | &save_option_list, "http", | 1610 | &save_number, NULL, |
1835 | hide_http_tab | 1611 | NULL}, |
1836 | }, | ||
1837 | 1612 | ||
1838 | { | 1613 | { |
1839 | "GNUNET_setup_transport_https_checkbutton", | 1614 | "GNUNET_setup_bandwidth_in_spinbutton", |
1840 | "toggled", | 1615 | "value-changed", |
1841 | "transport", | 1616 | "core", |
1842 | "PLUGINS", | 1617 | "TOTAL_QUOTA_IN", |
1843 | gettext_noop ("Enable communication via HTTPS"), | 1618 | gettext_noop ("How many bytes per second are we allowed to receive?"), |
1844 | "https://gnunet.org/configuration-https", | 1619 | "https://gnunet.org/configuration-bandwidth", |
1845 | &load_option_list, | 1620 | &load_number, |
1846 | &save_option_list, "https", | 1621 | &save_number, NULL, |
1847 | hide_https_tab | 1622 | NULL}, |
1848 | }, | 1623 | |
1624 | /* Transport TAB */ | ||
1849 | 1625 | ||
1850 | { | 1626 | { |
1851 | "GNUNET_setup_transport_dv_checkbutton", | 1627 | "GNUNET_setup_transport_tcp_checkbutton", |
1852 | "toggled", | 1628 | "toggled", |
1853 | "transport", | 1629 | "transport", |
1854 | "PLUGINS", | 1630 | "PLUGINS", |
1855 | gettext_noop ("Enable communication via DV"), | 1631 | gettext_noop ("Enable communication via TCP"), |
1856 | "https://gnunet.org/configuration-dv", | 1632 | "https://gnunet.org/configuration-tcp", |
1857 | &load_option_list, | 1633 | &load_option_list, |
1858 | &save_option_list, "dv", | 1634 | &save_option_list, "tcp", |
1859 | hide_dv_tab | 1635 | hide_tcp_tab}, |
1860 | }, | ||
1861 | 1636 | ||
1862 | { | 1637 | { |
1863 | "GNUNET_setup_transport_wlan_checkbutton", | 1638 | "GNUNET_setup_transport_udp_checkbutton", |
1864 | "toggled", | 1639 | "toggled", |
1865 | "transport", | 1640 | "transport", |
1866 | "PLUGINS", | 1641 | "PLUGINS", |
1867 | gettext_noop ("Enable communication via WLAN"), | 1642 | gettext_noop ("Enable communication via UDP"), |
1868 | "https://gnunet.org/configuration-wlan", | 1643 | "https://gnunet.org/configuration-udp", |
1869 | &load_option_list, | 1644 | &load_option_list, |
1870 | &save_option_list, "wlan", | 1645 | &save_option_list, "udp", |
1871 | hide_wlan_tab | 1646 | hide_udp_tab}, |
1872 | }, | ||
1873 | 1647 | ||
1874 | { | 1648 | { |
1875 | "GNUNET_setup_transport_tcp_port_spinbutton", | 1649 | "GNUNET_setup_transport_http_checkbutton", |
1876 | "value-changed", | 1650 | "toggled", |
1877 | "transport-tcp", | 1651 | "transport", |
1878 | "PORT", | 1652 | "PLUGINS", |
1879 | gettext_noop ("Port we bind to for TCP"), | 1653 | gettext_noop ("Enable communication via HTTP"), |
1880 | "https://gnunet.org/configuration-tcp", | 1654 | "https://gnunet.org/configuration-http", |
1881 | &load_number, | 1655 | &load_option_list, |
1882 | &save_number, NULL, | 1656 | &save_option_list, "http", |
1883 | hide_all_tcp_options | 1657 | hide_http_tab}, |
1884 | }, | ||
1885 | 1658 | ||
1886 | { | 1659 | { |
1887 | "GNUNET_setup_transport_tcp_adv_port_spinbutton", | 1660 | "GNUNET_setup_transport_https_checkbutton", |
1888 | "value-changed", | 1661 | "toggled", |
1889 | "transport-tcp", | 1662 | "transport", |
1890 | "ADVERTISED_PORT", | 1663 | "PLUGINS", |
1891 | gettext_noop ("Port visible to other peers"), | 1664 | gettext_noop ("Enable communication via HTTPS"), |
1892 | "https://gnunet.org/configuration-tcp", | 1665 | "https://gnunet.org/configuration-https", |
1893 | &load_number, | 1666 | &load_option_list, |
1894 | &save_number, NULL, | 1667 | &save_option_list, "https", |
1895 | NULL | 1668 | hide_https_tab}, |
1896 | }, | ||
1897 | 1669 | ||
1898 | { | 1670 | { |
1899 | "GNUNET_setup_transport_nat_checkbutton", | 1671 | "GNUNET_setup_transport_dv_checkbutton", |
1900 | "toggled", | 1672 | "toggled", |
1901 | "nat", | 1673 | "transport", |
1902 | "BEHIND_NAT", | 1674 | "PLUGINS", |
1903 | gettext_noop ("Check if this peer is behind a NAT"), | 1675 | gettext_noop ("Enable communication via DV"), |
1904 | "https://gnunet.org/configuration-nat", | 1676 | "https://gnunet.org/configuration-dv", |
1905 | &load_yes_no, | 1677 | &load_option_list, |
1906 | &save_yes_no, NULL, | 1678 | &save_option_list, "dv", |
1907 | toggle_nat_options | 1679 | hide_dv_tab}, |
1908 | }, | ||
1909 | 1680 | ||
1910 | { | 1681 | { |
1911 | "GNUNET_setup_transport_hole_punched_checkbutton", | 1682 | "GNUNET_setup_transport_wlan_checkbutton", |
1912 | "toggled", | 1683 | "toggled", |
1913 | "nat", | 1684 | "transport", |
1914 | "PUNCHED_NAT", | 1685 | "PLUGINS", |
1915 | gettext_noop ("Check if the NAT has been hole-punched manually"), | 1686 | gettext_noop ("Enable communication via WLAN"), |
1916 | "https://gnunet.org/configuration-nat", | 1687 | "https://gnunet.org/configuration-wlan", |
1917 | &load_yes_no, | 1688 | &load_option_list, |
1918 | &save_yes_no, NULL, | 1689 | &save_option_list, "wlan", |
1919 | toggle_nat_punched_options | 1690 | hide_wlan_tab}, |
1920 | }, | ||
1921 | 1691 | ||
1922 | { | 1692 | { |
1923 | "GNUNET_setup_transport_upnp_enable_checkbutton", | 1693 | "GNUNET_setup_transport_tcp_port_spinbutton", |
1924 | "toggled", | 1694 | "value-changed", |
1925 | "nat", | 1695 | "transport-tcp", |
1926 | "ENABLE_UPNP", | 1696 | "PORT", |
1927 | gettext_noop ("Enable NAT traversal with UPnP/PMP"), | 1697 | gettext_noop ("Port we bind to for TCP"), |
1928 | "https://gnunet.org/configuration-nat", | 1698 | "https://gnunet.org/configuration-tcp", |
1929 | &load_yes_no, | 1699 | &load_number, |
1930 | &save_yes_no, NULL, | 1700 | &save_number, NULL, |
1931 | NULL, | 1701 | hide_all_tcp_options}, |
1932 | }, | ||
1933 | 1702 | ||
1934 | { | 1703 | { |
1935 | "GNUNET_setup_transport_icmp_server_enable_checkbutton", | 1704 | "GNUNET_setup_transport_tcp_adv_port_spinbutton", |
1936 | "toggled", | 1705 | "value-changed", |
1937 | "nat", | 1706 | "transport-tcp", |
1938 | "ENABLE_ICMP_SERVER", | 1707 | "ADVERTISED_PORT", |
1939 | gettext_noop ("Enable NAT traversal with ICMP as server"), | 1708 | gettext_noop ("Port visible to other peers"), |
1940 | "https://gnunet.org/configuration-nat", | 1709 | "https://gnunet.org/configuration-tcp", |
1941 | &load_yes_no, | 1710 | &load_number, |
1942 | &save_yes_no, NULL, | 1711 | &save_number, NULL, |
1943 | NULL, | 1712 | NULL}, |
1944 | }, | ||
1945 | 1713 | ||
1946 | { | 1714 | { |
1947 | "GNUNET_setup_transport_external_ip_address_entry", | 1715 | "GNUNET_setup_transport_nat_checkbutton", |
1948 | "changed", | 1716 | "toggled", |
1949 | "nat", | 1717 | "nat", |
1950 | "EXTERNAL_ADDRESS", | 1718 | "BEHIND_NAT", |
1951 | gettext_noop ("External (public) IP address of the NAT"), | 1719 | gettext_noop ("Check if this peer is behind a NAT"), |
1952 | "https://gnunet.org/configuration-nat", | 1720 | "https://gnunet.org/configuration-nat", |
1953 | &load_text, | 1721 | &load_yes_no, |
1954 | &save_text, NULL, | 1722 | &save_yes_no, NULL, |
1955 | NULL | 1723 | toggle_nat_options}, |
1956 | }, | ||
1957 | 1724 | ||
1958 | { | 1725 | { |
1959 | "GNUNET_setup_transport_icmp_client_enable_checkbutton", | 1726 | "GNUNET_setup_transport_hole_punched_checkbutton", |
1960 | "toggled", | 1727 | "toggled", |
1961 | "nat", | 1728 | "nat", |
1962 | "ENABLE_ICMP_CLIENT", | 1729 | "PUNCHED_NAT", |
1963 | gettext_noop ("Enable NAT traversal with ICMP as client"), | 1730 | gettext_noop ("Check if the NAT has been hole-punched manually"), |
1964 | "https://gnunet.org/configuration-nat", | 1731 | "https://gnunet.org/configuration-nat", |
1965 | &load_yes_no, | 1732 | &load_yes_no, |
1966 | &save_yes_no, NULL, | 1733 | &save_yes_no, NULL, |
1967 | toggle_internal_ip | 1734 | toggle_nat_punched_options}, |
1968 | }, | ||
1969 | 1735 | ||
1970 | { | 1736 | { |
1971 | "GNUNET_setup_transport_internal_ip_entry", | 1737 | "GNUNET_setup_transport_upnp_enable_checkbutton", |
1972 | "changed", | 1738 | "toggled", |
1973 | "nat", | 1739 | "nat", |
1974 | "INTERNAL_ADDRESS", | 1740 | "ENABLE_UPNP", |
1975 | gettext_noop ("Internal (private) IP address of the NAT"), | 1741 | gettext_noop ("Enable NAT traversal with UPnP/PMP"), |
1976 | "https://gnunet.org/configuration-nat", | 1742 | "https://gnunet.org/configuration-nat", |
1977 | &load_text, | 1743 | &load_yes_no, |
1978 | &save_text, NULL, | 1744 | &save_yes_no, NULL, |
1979 | NULL | 1745 | NULL, |
1980 | }, | 1746 | }, |
1981 | 1747 | ||
1982 | { | 1748 | { |
1983 | "GNUNET_setup_transport_disable_ipv6_checkbutton", | 1749 | "GNUNET_setup_transport_icmp_server_enable_checkbutton", |
1984 | "toggled", | 1750 | "toggled", |
1985 | "nat", | 1751 | "nat", |
1986 | "DISABLEV6", | 1752 | "ENABLE_ICMP_SERVER", |
1987 | gettext_noop ("Disable IPv6 support"), | 1753 | gettext_noop ("Enable NAT traversal with ICMP as server"), |
1988 | "https://gnunet.org/configuration-ipv6", | 1754 | "https://gnunet.org/configuration-nat", |
1989 | &load_yes_no, | 1755 | &load_yes_no, |
1990 | &save_yes_no, NULL, | 1756 | &save_yes_no, NULL, |
1991 | NULL, | 1757 | NULL, |
1992 | }, | 1758 | }, |
1993 | 1759 | ||
1994 | { | 1760 | { |
1995 | "GNUNET_setup_transport_udp_port_spinbutton", | 1761 | "GNUNET_setup_transport_external_ip_address_entry", |
1996 | "value-changed", | 1762 | "changed", |
1997 | "transport-udp", | 1763 | "nat", |
1998 | "PORT", | 1764 | "EXTERNAL_ADDRESS", |
1999 | gettext_noop ("Port for inbound UDP packets, use 0 if behind NAT"), | 1765 | gettext_noop ("External (public) IP address of the NAT"), |
2000 | "https://gnunet.org/configuration-udp", | 1766 | "https://gnunet.org/configuration-nat", |
2001 | &load_number, | 1767 | &load_text, |
2002 | &save_number, NULL, | 1768 | &save_text, NULL, |
2003 | NULL | 1769 | NULL}, |
2004 | }, | ||
2005 | 1770 | ||
2006 | { | 1771 | { |
2007 | "GNUNET_setup_transport_http_port_spinbutton", | 1772 | "GNUNET_setup_transport_icmp_client_enable_checkbutton", |
2008 | "value-changed", | 1773 | "toggled", |
2009 | "transport-http", | 1774 | "nat", |
2010 | "PORT", | 1775 | "ENABLE_ICMP_CLIENT", |
2011 | gettext_noop ("Port for inbound HTTP connections, use 0 if behind NAT"), | 1776 | gettext_noop ("Enable NAT traversal with ICMP as client"), |
2012 | "https://gnunet.org/configuration-http", | 1777 | "https://gnunet.org/configuration-nat", |
2013 | &load_number, | 1778 | &load_yes_no, |
2014 | &save_number, NULL, | 1779 | &save_yes_no, NULL, |
2015 | NULL | 1780 | toggle_internal_ip}, |
2016 | }, | ||
2017 | 1781 | ||
2018 | { | 1782 | { |
2019 | "GNUNET_setup_transport_https_port_spinbutton", | 1783 | "GNUNET_setup_transport_internal_ip_entry", |
2020 | "value-changed", | 1784 | "changed", |
2021 | "transport-https", | 1785 | "nat", |
2022 | "PORT", | 1786 | "INTERNAL_ADDRESS", |
2023 | gettext_noop ("Port for inbound HTTPS connections, use 0 if behind NAT"), | 1787 | gettext_noop ("Internal (private) IP address of the NAT"), |
2024 | "https://gnunet.org/configuration-https", | 1788 | "https://gnunet.org/configuration-nat", |
2025 | &load_number, | 1789 | &load_text, |
2026 | &save_number, NULL, | 1790 | &save_text, NULL, |
2027 | NULL | 1791 | NULL}, |
2028 | }, | ||
2029 | |||
2030 | /* FS TAB */ | ||
2031 | |||
2032 | { | ||
2033 | "GNUNET_setup_fs_datastore_sqlite_radiobutton", | ||
2034 | "toggled", | ||
2035 | "datastore", | ||
2036 | "DATABASE", | ||
2037 | gettext_noop ("Use sqLite to store file-sharing content"), | ||
2038 | "https://gnunet.org/configuration-datastore", | ||
2039 | &load_option_list /* abuse! */, | ||
2040 | &save_option_list /* abuse! */, "sqlite", | ||
2041 | hide_sqlite_datastore_tab | ||
2042 | }, | ||
2043 | 1792 | ||
2044 | { | 1793 | { |
2045 | "GNUNET_setup_fs_datastore_mysql_radiobutton", | 1794 | "GNUNET_setup_transport_disable_ipv6_checkbutton", |
2046 | "toggled", | 1795 | "toggled", |
2047 | "datastore", | 1796 | "nat", |
2048 | "DATABASE", | 1797 | "DISABLEV6", |
2049 | gettext_noop ("Use MySQL to store file-sharing content"), | 1798 | gettext_noop ("Disable IPv6 support"), |
2050 | "https://gnunet.org/configuration-datastore", | 1799 | "https://gnunet.org/configuration-ipv6", |
2051 | &load_option_list /* abuse! */, | 1800 | &load_yes_no, |
2052 | &save_option_list /* abuse! */, "mysql", | 1801 | &save_yes_no, NULL, |
2053 | hide_mysql_datastore_tab | 1802 | NULL, |
2054 | }, | 1803 | }, |
2055 | 1804 | ||
2056 | { | 1805 | { |
2057 | "GNUNET_setup_fs_datastore_postgres_radiobutton", | 1806 | "GNUNET_setup_transport_udp_port_spinbutton", |
2058 | "toggled", | 1807 | "value-changed", |
2059 | "datastore", | 1808 | "transport-udp", |
2060 | "DATABASE", | 1809 | "PORT", |
2061 | gettext_noop ("Use Postgres to store file-sharing content"), | 1810 | gettext_noop ("Port for inbound UDP packets, use 0 if behind NAT"), |
2062 | "https://gnunet.org/configuration-datastore", | 1811 | "https://gnunet.org/configuration-udp", |
2063 | &load_option_list /* abuse! */, | 1812 | &load_number, |
2064 | &save_option_list /* abuse! */, "postgres", | 1813 | &save_number, NULL, |
2065 | hide_postgres_datastore_tab | 1814 | NULL}, |
2066 | }, | ||
2067 | 1815 | ||
2068 | { | 1816 | { |
2069 | "GNUNET_setup_datastore_mysql_database_name_entry", | 1817 | "GNUNET_setup_transport_http_port_spinbutton", |
2070 | "changed", | 1818 | "value-changed", |
2071 | "datastore-mysql", | 1819 | "transport-http", |
2072 | "DATABASE", | 1820 | "PORT", |
2073 | gettext_noop ("Name for the MySQL database"), | 1821 | gettext_noop ("Port for inbound HTTP connections, use 0 if behind NAT"), |
2074 | "https://gnunet.org/configuration-datastore", | 1822 | "https://gnunet.org/configuration-http", |
2075 | &load_text, | 1823 | &load_number, |
2076 | &save_text, NULL, | 1824 | &save_number, NULL, |
2077 | NULL | 1825 | NULL}, |
2078 | }, | ||
2079 | |||
2080 | { | ||
2081 | "GNUNET_setup_datastore_mysql_config_file_filechooserbutton", | ||
2082 | "selection-changed", | ||
2083 | "datastore-mysql", | ||
2084 | "CONFIG", | ||
2085 | gettext_noop ("Configuration file for MySQL access"), | ||
2086 | "http://dev.mysql.com/doc/refman/5.5/en/option-files.html", | ||
2087 | &load_filename, | ||
2088 | &save_filename, NULL, | ||
2089 | NULL | ||
2090 | }, | ||
2091 | 1826 | ||
2092 | { | 1827 | { |
2093 | "GNUNET_setup_datastore_mysql_username_entry", | 1828 | "GNUNET_setup_transport_https_port_spinbutton", |
2094 | "changed", | 1829 | "value-changed", |
2095 | "datastore-mysql", | 1830 | "transport-https", |
2096 | "USER", | 1831 | "PORT", |
2097 | gettext_noop ("Username for MySQL access"), | 1832 | gettext_noop ("Port for inbound HTTPS connections, use 0 if behind NAT"), |
2098 | "https://gnunet.org/configuration-datastore", | 1833 | "https://gnunet.org/configuration-https", |
2099 | &load_text, | 1834 | &load_number, |
2100 | &save_text, NULL, | 1835 | &save_number, NULL, |
2101 | NULL | 1836 | NULL}, |
2102 | }, | 1837 | |
1838 | /* FS TAB */ | ||
2103 | 1839 | ||
2104 | { | 1840 | { |
2105 | "GNUNET_setup_datastore_mysql_password_entry", | 1841 | "GNUNET_setup_fs_datastore_sqlite_radiobutton", |
2106 | "changed", | 1842 | "toggled", |
2107 | "datastore-mysql", | 1843 | "datastore", |
2108 | "PASSWORD", | 1844 | "DATABASE", |
2109 | gettext_noop ("Password for MySQL access"), | 1845 | gettext_noop ("Use sqLite to store file-sharing content"), |
2110 | "https://gnunet.org/configuration-datastore", | 1846 | "https://gnunet.org/configuration-datastore", |
2111 | &load_text, | 1847 | &load_option_list /* abuse! */ , |
2112 | &save_text, NULL, | 1848 | &save_option_list /* abuse! */ , "sqlite", |
2113 | NULL | 1849 | hide_sqlite_datastore_tab}, |
2114 | }, | ||
2115 | 1850 | ||
2116 | { | 1851 | { |
2117 | "GNUNET_setup_datastore_mysql_hostname_entry", | 1852 | "GNUNET_setup_fs_datastore_mysql_radiobutton", |
2118 | "changed", | 1853 | "toggled", |
2119 | "datastore-mysql", | 1854 | "datastore", |
2120 | "HOST", | 1855 | "DATABASE", |
2121 | gettext_noop ("Name of host running MySQL database"), | 1856 | gettext_noop ("Use MySQL to store file-sharing content"), |
2122 | "https://gnunet.org/configuration-datastore", | 1857 | "https://gnunet.org/configuration-datastore", |
2123 | &load_text, | 1858 | &load_option_list /* abuse! */ , |
2124 | &save_text, NULL, | 1859 | &save_option_list /* abuse! */ , "mysql", |
2125 | NULL | 1860 | hide_mysql_datastore_tab}, |
2126 | }, | ||
2127 | 1861 | ||
2128 | { | 1862 | { |
2129 | "GNUNET_setup_datastore_mysql_port_spinbutton", | 1863 | "GNUNET_setup_fs_datastore_postgres_radiobutton", |
2130 | "value-changed", | 1864 | "toggled", |
2131 | "datastore-mysql", | 1865 | "datastore", |
2132 | "PORT", | 1866 | "DATABASE", |
2133 | gettext_noop ("Port of MySQL database"), | 1867 | gettext_noop ("Use Postgres to store file-sharing content"), |
2134 | "https://gnunet.org/configuration-datastore", | 1868 | "https://gnunet.org/configuration-datastore", |
2135 | &load_number, | 1869 | &load_option_list /* abuse! */ , |
2136 | &save_number, NULL, | 1870 | &save_option_list /* abuse! */ , "postgres", |
2137 | NULL | 1871 | hide_postgres_datastore_tab}, |
2138 | }, | ||
2139 | 1872 | ||
2140 | { | 1873 | { |
2141 | "GNUNET_setup_datastore_postgres_config_entry", | 1874 | "GNUNET_setup_datastore_mysql_database_name_entry", |
2142 | "changed", | 1875 | "changed", |
2143 | "datastore-postgres", | 1876 | "datastore-mysql", |
2144 | "CONFIG", | 1877 | "DATABASE", |
2145 | gettext_noop ("Configuration for Postgres (passed to PQconnectdb)"), | 1878 | gettext_noop ("Name for the MySQL database"), |
2146 | "http://www.postgresql.org/docs/8.1/static/libpq.html#LIBPQ-CONNECT", | 1879 | "https://gnunet.org/configuration-datastore", |
2147 | &load_text, | 1880 | &load_text, |
2148 | &save_text, NULL, | 1881 | &save_text, NULL, |
2149 | NULL | 1882 | NULL}, |
2150 | }, | ||
2151 | |||
2152 | |||
2153 | { | ||
2154 | "GNUNET_setup_fs_migration_from_checkbutton", | ||
2155 | "toggled", | ||
2156 | "fs", | ||
2157 | "CONTENT_PUSHING", | ||
2158 | gettext_noop ("Should we try to push our content to other peers?"), | ||
2159 | "https://gnunet.org/configuration-fs", | ||
2160 | &load_yes_no, | ||
2161 | &save_yes_no, NULL, | ||
2162 | NULL | ||
2163 | }, | ||
2164 | |||
2165 | { | ||
2166 | "GNUNET_setup_fs_migration_to_checkbutton", | ||
2167 | "toggled", | ||
2168 | "fs", | ||
2169 | "CONTENT_CACHING", | ||
2170 | gettext_noop ("Are we allowed to cache content received from other peers?"), | ||
2171 | "https://gnunet.org/configuration-fs", | ||
2172 | &load_yes_no, | ||
2173 | &save_yes_no, NULL, | ||
2174 | NULL | ||
2175 | }, | ||
2176 | |||
2177 | { | ||
2178 | "GNUNET_setup_fs_datacache_sqlite_radiobutton", | ||
2179 | "toggled", | ||
2180 | "dhtcache", | ||
2181 | "DATABASE", | ||
2182 | gettext_noop ("Use sqLite to cache DHT data"), | ||
2183 | "https://gnunet.org/configuration-datacache", | ||
2184 | &load_option_list /* abuse! */, | ||
2185 | &save_option_list /* abuse! */, "sqlite", | ||
2186 | hide_sqlite_datacache_tab | ||
2187 | }, | ||
2188 | 1883 | ||
2189 | { | 1884 | { |
2190 | "GNUNET_setup_fs_datacache_mysql_radiobutton", | 1885 | "GNUNET_setup_datastore_mysql_config_file_filechooserbutton", |
2191 | "toggled", | 1886 | "selection-changed", |
2192 | "dhtcache", | 1887 | "datastore-mysql", |
2193 | "DATABASE", | 1888 | "CONFIG", |
2194 | gettext_noop ("Use MySQL to cache DHT data"), | 1889 | gettext_noop ("Configuration file for MySQL access"), |
2195 | "https://gnunet.org/configuration-datacache", | 1890 | "http://dev.mysql.com/doc/refman/5.5/en/option-files.html", |
2196 | &load_option_list /* abuse! */, | 1891 | &load_filename, |
2197 | &save_option_list /* abuse! */, "mysql", | 1892 | &save_filename, NULL, |
2198 | hide_mysql_datacache_tab | 1893 | NULL}, |
2199 | }, | ||
2200 | 1894 | ||
2201 | { | 1895 | { |
2202 | "GNUNET_setup_fs_datacache_postgres_radiobutton", | 1896 | "GNUNET_setup_datastore_mysql_username_entry", |
2203 | "toggled", | 1897 | "changed", |
2204 | "dhtcache", | 1898 | "datastore-mysql", |
2205 | "DATABASE", | 1899 | "USER", |
2206 | gettext_noop ("Use Postgres to cache DHT data"), | 1900 | gettext_noop ("Username for MySQL access"), |
2207 | "https://gnunet.org/configuration-datacache", | 1901 | "https://gnunet.org/configuration-datastore", |
2208 | &load_option_list /* abuse! */, | 1902 | &load_text, |
2209 | &save_option_list /* abuse! */, "postgres", | 1903 | &save_text, NULL, |
2210 | hide_postgres_datacache_tab | 1904 | NULL}, |
2211 | }, | ||
2212 | |||
2213 | { | ||
2214 | "GNUNET_setup_datacache_mysql_database_name_entry", | ||
2215 | "changed", | ||
2216 | "datacache-mysql", | ||
2217 | "DATABASE", | ||
2218 | gettext_noop ("Name for the MySQL database"), | ||
2219 | "https://gnunet.org/configuration-datacache", | ||
2220 | &load_text, | ||
2221 | &save_text, NULL, | ||
2222 | NULL | ||
2223 | }, | ||
2224 | |||
2225 | { | ||
2226 | "GNUNET_setup_datacache_mysql_config_file_filechooserbutton", | ||
2227 | "selection-changed", | ||
2228 | "datacache-mysql", | ||
2229 | "CONFIG", | ||
2230 | gettext_noop ("Configuration file for MySQL access"), | ||
2231 | "http://dev.mysql.com/doc/refman/5.5/en/option-files.html", | ||
2232 | &load_filename, | ||
2233 | &save_filename, NULL, | ||
2234 | NULL | ||
2235 | }, | ||
2236 | 1905 | ||
2237 | { | 1906 | { |
2238 | "GNUNET_setup_datacache_mysql_username_entry", | 1907 | "GNUNET_setup_datastore_mysql_password_entry", |
2239 | "changed", | 1908 | "changed", |
2240 | "datacache-mysql", | 1909 | "datastore-mysql", |
2241 | "USER", | 1910 | "PASSWORD", |
2242 | gettext_noop ("Username for MySQL access"), | 1911 | gettext_noop ("Password for MySQL access"), |
2243 | "https://gnunet.org/configuration-datacache", | 1912 | "https://gnunet.org/configuration-datastore", |
2244 | &load_text, | 1913 | &load_text, |
2245 | &save_text, NULL, | 1914 | &save_text, NULL, |
2246 | NULL | 1915 | NULL}, |
2247 | }, | ||
2248 | 1916 | ||
2249 | { | 1917 | { |
2250 | "GNUNET_setup_datacache_mysql_password_entry", | 1918 | "GNUNET_setup_datastore_mysql_hostname_entry", |
2251 | "changed", | 1919 | "changed", |
2252 | "datacache-mysql", | 1920 | "datastore-mysql", |
2253 | "PASSWORD", | 1921 | "HOST", |
2254 | gettext_noop ("Password for MySQL access"), | 1922 | gettext_noop ("Name of host running MySQL database"), |
2255 | "https://gnunet.org/configuration-datacache", | 1923 | "https://gnunet.org/configuration-datastore", |
2256 | &load_text, | 1924 | &load_text, |
2257 | &save_text, NULL, | 1925 | &save_text, NULL, |
2258 | NULL | 1926 | NULL}, |
2259 | }, | ||
2260 | 1927 | ||
2261 | { | 1928 | { |
2262 | "GNUNET_setup_datacache_mysql_hostname_entry", | 1929 | "GNUNET_setup_datastore_mysql_port_spinbutton", |
2263 | "changed", | 1930 | "value-changed", |
2264 | "datacache-mysql", | 1931 | "datastore-mysql", |
2265 | "HOST", | 1932 | "PORT", |
2266 | gettext_noop ("Name of host running MySQL database"), | 1933 | gettext_noop ("Port of MySQL database"), |
2267 | "https://gnunet.org/configuration-datacache", | 1934 | "https://gnunet.org/configuration-datastore", |
2268 | &load_text, | 1935 | &load_number, |
2269 | &save_text, NULL, | 1936 | &save_number, NULL, |
2270 | NULL | 1937 | NULL}, |
2271 | }, | ||
2272 | 1938 | ||
2273 | { | 1939 | { |
2274 | "GNUNET_setup_transport_wlan_interface_entry", | 1940 | "GNUNET_setup_datastore_postgres_config_entry", |
2275 | "changed", | 1941 | "changed", |
2276 | "transport-wlan", | 1942 | "datastore-postgres", |
2277 | "INTERFACE", | 1943 | "CONFIG", |
2278 | gettext_noop ("Name of monitoring interface to use (monX)"), | 1944 | gettext_noop ("Configuration for Postgres (passed to PQconnectdb)"), |
2279 | "https://gnunet.org/configuration-wlan", | 1945 | "http://www.postgresql.org/docs/8.1/static/libpq.html#LIBPQ-CONNECT", |
2280 | &load_text, | 1946 | &load_text, |
2281 | &save_text, NULL, | 1947 | &save_text, NULL, |
2282 | NULL | 1948 | NULL}, |
2283 | }, | ||
2284 | 1949 | ||
2285 | { | ||
2286 | "GNUNET_setup_datacache_mysql_port_spinbutton", | ||
2287 | "value-changed", | ||
2288 | "datacache-mysql", | ||
2289 | "PORT", | ||
2290 | gettext_noop ("Port of MySQL database"), | ||
2291 | "https://gnunet.org/configuration-datacache", | ||
2292 | &load_number, | ||
2293 | &save_number, NULL, | ||
2294 | NULL | ||
2295 | }, | ||
2296 | 1950 | ||
2297 | { | 1951 | { |
2298 | "GNUNET_setup_datacache_postgres_config_entry", | 1952 | "GNUNET_setup_fs_migration_from_checkbutton", |
2299 | "changed", | 1953 | "toggled", |
2300 | "datacache-postgres", | 1954 | "fs", |
2301 | "CONFIG", | 1955 | "CONTENT_PUSHING", |
2302 | gettext_noop ("Configuration for Postgres (passed to PQconnectdb)"), | 1956 | gettext_noop ("Should we try to push our content to other peers?"), |
2303 | "http://www.postgresql.org/docs/8.1/static/libpq.html#LIBPQ-CONNECT", | 1957 | "https://gnunet.org/configuration-fs", |
2304 | &load_text, | 1958 | &load_yes_no, |
2305 | &save_text, NULL, | 1959 | &save_yes_no, NULL, |
2306 | NULL | 1960 | NULL}, |
2307 | }, | ||
2308 | |||
2309 | { | ||
2310 | "GNUNET_setup_vpn_master_interface_entry", | ||
2311 | "changed", | ||
2312 | "vpn", | ||
2313 | "IFNAME", | ||
2314 | gettext_noop ("Name of the virtual interface the GNUnet VPN should create"), | ||
2315 | "https://gnunet.org/configuration-vpn", | ||
2316 | &load_text, | ||
2317 | &save_text, NULL, | ||
2318 | NULL | ||
2319 | }, | ||
2320 | |||
2321 | { | ||
2322 | "GNUNET_setup_vpn_master_interface_v4_ip_entry", | ||
2323 | "changed", | ||
2324 | "vpn", | ||
2325 | "IPV4ADDR", | ||
2326 | gettext_noop ("IPv4 address to use for the VPN interface"), | ||
2327 | "https://gnunet.org/configuration-vpn", | ||
2328 | &load_text, | ||
2329 | &save_text, NULL, | ||
2330 | NULL | ||
2331 | }, | ||
2332 | |||
2333 | { | ||
2334 | "GNUNET_setup_vpn_master_interface_v4_mask_entry", | ||
2335 | "changed", | ||
2336 | "vpn", | ||
2337 | "IPV4MASK", | ||
2338 | gettext_noop ("IPv4 network mask to use for the VPN interface"), | ||
2339 | "https://gnunet.org/configuration-vpn", | ||
2340 | &load_text, | ||
2341 | &save_text, NULL, | ||
2342 | NULL | ||
2343 | }, | ||
2344 | |||
2345 | { | ||
2346 | "GNUNET_setup_vpn_master_interface_v6_ip_entry", | ||
2347 | "changed", | ||
2348 | "vpn", | ||
2349 | "IPV6ADDR", | ||
2350 | gettext_noop ("IPv6 address to use for the VPN interface"), | ||
2351 | "https://gnunet.org/configuration-vpn", | ||
2352 | &load_text, | ||
2353 | &save_text, NULL, | ||
2354 | NULL | ||
2355 | }, | ||
2356 | |||
2357 | { | ||
2358 | "GNUNET_setup_vpn_master_interface_v6_mask_spinbutton", | ||
2359 | "value-changed", | ||
2360 | "vpn", | ||
2361 | "IPV6MASK", | ||
2362 | gettext_noop ("IPv6 network prefix length to use for the VPN interface"), | ||
2363 | "https://gnunet.org/configuration-vpn", | ||
2364 | &load_number, | ||
2365 | &save_number, NULL, | ||
2366 | NULL | ||
2367 | }, | ||
2368 | 1961 | ||
2369 | { | 1962 | { |
2370 | "GNUNET_setup_vpn_master_vdns_server_entry", | 1963 | "GNUNET_setup_fs_migration_to_checkbutton", |
2371 | "changed", | 1964 | "toggled", |
2372 | "vpn", | 1965 | "fs", |
2373 | "VIRTDNS", | 1966 | "CONTENT_CACHING", |
2374 | gettext_noop ("IP address of the virtual DNS server that resolves through GNUnet (use in resolve.conf if you want to resolve through some GNUnet DNS Exit)"), | 1967 | gettext_noop ("Are we allowed to cache content received from other peers?"), |
2375 | "https://gnunet.org/configuration-vpn", | 1968 | "https://gnunet.org/configuration-fs", |
2376 | &load_text, | 1969 | &load_yes_no, |
2377 | &save_text, NULL, | 1970 | &save_yes_no, NULL, |
2378 | NULL | 1971 | NULL}, |
2379 | }, | ||
2380 | 1972 | ||
2381 | { | 1973 | { |
2382 | "GNUNET_setup_vpn_enable_vpn_exit_checkbutton", | 1974 | "GNUNET_setup_fs_datacache_sqlite_radiobutton", |
2383 | "toggled", | 1975 | "toggled", |
2384 | "arm", | 1976 | "dhtcache", |
2385 | "DEFAULTSERVICES", | 1977 | "DATABASE", |
2386 | gettext_noop ("Activate the VPN exit to provide services and/or to enable others to use your Internet connection"), | 1978 | gettext_noop ("Use sqLite to cache DHT data"), |
2387 | "https://gnunet.org/configuration-exit", | 1979 | "https://gnunet.org/configuration-datacache", |
2388 | &load_option_list, | 1980 | &load_option_list /* abuse! */ , |
2389 | &save_option_list, "exit", | 1981 | &save_option_list /* abuse! */ , "sqlite", |
2390 | hide_exit_options | 1982 | hide_sqlite_datacache_tab}, |
2391 | }, | ||
2392 | 1983 | ||
2393 | { | 1984 | { |
2394 | "GNUNET_setup_vpn_enable_dns_exit_checkbutton", | 1985 | "GNUNET_setup_fs_datacache_mysql_radiobutton", |
2395 | "toggled", | 1986 | "toggled", |
2396 | "dns", | 1987 | "dhtcache", |
2397 | "PROVIDE_EXIT", | 1988 | "DATABASE", |
2398 | gettext_noop ("Allow other peers to perform DNS resolutions using your Internet connection"), | 1989 | gettext_noop ("Use MySQL to cache DHT data"), |
2399 | "https://gnunet.org/configuration-dns", | 1990 | "https://gnunet.org/configuration-datacache", |
2400 | &load_yes_no, | 1991 | &load_option_list /* abuse! */ , |
2401 | &save_yes_no, NULL, | 1992 | &save_option_list /* abuse! */ , "mysql", |
2402 | NULL | 1993 | hide_mysql_datacache_tab}, |
2403 | }, | ||
2404 | 1994 | ||
2405 | { | 1995 | { |
2406 | "GNUNET_setup_vpn_exit_interface_name_entry", | 1996 | "GNUNET_setup_fs_datacache_postgres_radiobutton", |
2407 | "changed", | 1997 | "toggled", |
2408 | "exit", | 1998 | "dhtcache", |
2409 | "IFNAME", | 1999 | "DATABASE", |
2410 | gettext_noop ("Name of the virtual interface the GNUnet exit service should create for traffic exiting the VPN to the Internet"), | 2000 | gettext_noop ("Use Postgres to cache DHT data"), |
2411 | "https://gnunet.org/configuration-exit", | 2001 | "https://gnunet.org/configuration-datacache", |
2412 | &load_text, | 2002 | &load_option_list /* abuse! */ , |
2413 | &save_text, NULL, | 2003 | &save_option_list /* abuse! */ , "postgres", |
2414 | NULL | 2004 | hide_postgres_datacache_tab}, |
2415 | }, | ||
2416 | |||
2417 | { | ||
2418 | "GNUNET_setup_vpn_exit_interface_v4_ip_entry", | ||
2419 | "changed", | ||
2420 | "exit", | ||
2421 | "IPV4ADDR", | ||
2422 | gettext_noop ("IPv4 address to use for the VPN Exit interface"), | ||
2423 | "https://gnunet.org/configuration-exit", | ||
2424 | &load_text, | ||
2425 | &save_text, NULL, | ||
2426 | NULL | ||
2427 | }, | ||
2428 | |||
2429 | { | ||
2430 | "GNUNET_setup_vpn_exit_interface_v4_mask_entry", | ||
2431 | "changed", | ||
2432 | "exit", | ||
2433 | "IPV4MASK", | ||
2434 | gettext_noop ("IPv4 network mask to use for the VPN Exit interface"), | ||
2435 | "https://gnunet.org/configuration-exit", | ||
2436 | &load_text, | ||
2437 | &save_text, NULL, | ||
2438 | NULL | ||
2439 | }, | ||
2440 | |||
2441 | { | ||
2442 | "GNUNET_setup_vpn_exit_interface_v6_ip_entry", | ||
2443 | "changed", | ||
2444 | "exit", | ||
2445 | "IPV6ADDR", | ||
2446 | gettext_noop ("IPv6 address to use for the VPN Exit interface"), | ||
2447 | "https://gnunet.org/configuration-exit", | ||
2448 | &load_text, | ||
2449 | &save_text, NULL, | ||
2450 | NULL | ||
2451 | }, | ||
2452 | |||
2453 | { | ||
2454 | "GNUNET_setup_vpn_exit_interface_v6_mask_spinbutton", | ||
2455 | "value-changed", | ||
2456 | "exit", | ||
2457 | "IPV6MASK", | ||
2458 | gettext_noop ("IPv6 network prefix length to use for the VPN Exit interface"), | ||
2459 | "https://gnunet.org/configuration-exit", | ||
2460 | &load_number, | ||
2461 | &save_number, NULL, | ||
2462 | NULL | ||
2463 | }, | ||
2464 | 2005 | ||
2006 | { | ||
2007 | "GNUNET_setup_datacache_mysql_database_name_entry", | ||
2008 | "changed", | ||
2009 | "datacache-mysql", | ||
2010 | "DATABASE", | ||
2011 | gettext_noop ("Name for the MySQL database"), | ||
2012 | "https://gnunet.org/configuration-datacache", | ||
2013 | &load_text, | ||
2014 | &save_text, NULL, | ||
2015 | NULL}, | ||
2465 | 2016 | ||
2466 | { | 2017 | { |
2467 | "GNUNET_setup_vpn_exit_enable_udp_checkbutton", | 2018 | "GNUNET_setup_datacache_mysql_config_file_filechooserbutton", |
2468 | "toggled", | 2019 | "selection-changed", |
2469 | "exit", | 2020 | "datacache-mysql", |
2470 | "ENABLE_UDP", | 2021 | "CONFIG", |
2471 | gettext_noop ("Allow other users to use your Internet connection for UDP traffic (via the Exit interface)"), | 2022 | gettext_noop ("Configuration file for MySQL access"), |
2472 | "https://gnunet.org/configuration-exit", | 2023 | "http://dev.mysql.com/doc/refman/5.5/en/option-files.html", |
2473 | &load_yes_no, | 2024 | &load_filename, |
2474 | &save_yes_no, NULL, | 2025 | &save_filename, NULL, |
2475 | NULL | 2026 | NULL}, |
2476 | }, | ||
2477 | |||
2478 | { | ||
2479 | "GNUNET_setup_vpn_exit_enable_tcp_checkbutton", | ||
2480 | "toggled", | ||
2481 | "exit", | ||
2482 | "ENABLE_TCP", | ||
2483 | gettext_noop ("Allow other users to use your Internet connection for TCP traffic (via the Exit interface)"), | ||
2484 | "https://gnunet.org/configuration-exit", | ||
2485 | &load_yes_no, | ||
2486 | &save_yes_no, NULL, | ||
2487 | NULL | ||
2488 | }, | ||
2489 | |||
2490 | /* DNS treeview */ | ||
2491 | |||
2492 | { | ||
2493 | "GNUNET_setup_vpn_dns_service_treeview", | ||
2494 | NULL, | ||
2495 | NULL, | ||
2496 | NULL, | ||
2497 | gettext_noop ("Specification of .gnunet hostnames and services offered by this peer"), | ||
2498 | "https://gnunet.org/configuration-dns", | ||
2499 | &load_vpn_dns_configuration, | ||
2500 | NULL, NULL, | ||
2501 | NULL | ||
2502 | }, | ||
2503 | |||
2504 | { | ||
2505 | "GNUNET_setup_vpn_dns_service_dnsname_cellrenderertext", | ||
2506 | "editing-started", | ||
2507 | NULL, | ||
2508 | NULL, | ||
2509 | NULL, | ||
2510 | "https://gnunet.org/configuration-dns", | ||
2511 | NULL, | ||
2512 | &vpn_dns_service_dnsname_install_edited_handler, | ||
2513 | NULL, | ||
2514 | NULL | ||
2515 | }, | ||
2516 | 2027 | ||
2517 | { | 2028 | { |
2518 | "GNUNET_setup_vpn_dns_service_tcpudp_cellrenderertext", | 2029 | "GNUNET_setup_datacache_mysql_username_entry", |
2519 | "editing-started", | 2030 | "changed", |
2520 | NULL, | 2031 | "datacache-mysql", |
2521 | NULL, | 2032 | "USER", |
2522 | NULL, | 2033 | gettext_noop ("Username for MySQL access"), |
2523 | "https://gnunet.org/configuration-dns", | 2034 | "https://gnunet.org/configuration-datacache", |
2524 | NULL, | 2035 | &load_text, |
2525 | &vpn_dns_service_tcpudp_install_edited_handler, | 2036 | &save_text, NULL, |
2526 | NULL, | 2037 | NULL}, |
2527 | NULL | ||
2528 | }, | ||
2529 | 2038 | ||
2530 | { | 2039 | { |
2531 | "GNUNET_setup_vpn_dns_service_sourceport_cellrenderertext", | 2040 | "GNUNET_setup_datacache_mysql_password_entry", |
2532 | "editing-started", | 2041 | "changed", |
2533 | NULL, | 2042 | "datacache-mysql", |
2534 | NULL, | 2043 | "PASSWORD", |
2535 | NULL, | 2044 | gettext_noop ("Password for MySQL access"), |
2536 | "https://gnunet.org/configuration-dns", | 2045 | "https://gnunet.org/configuration-datacache", |
2537 | NULL, | 2046 | &load_text, |
2538 | &vpn_dns_service_sourceport_install_edited_handler, | 2047 | &save_text, NULL, |
2539 | NULL, | 2048 | NULL}, |
2540 | NULL | 2049 | |
2541 | }, | 2050 | { |
2542 | 2051 | "GNUNET_setup_datacache_mysql_hostname_entry", | |
2543 | { | 2052 | "changed", |
2544 | "GNUNET_setup_vpn_dns_service_targethostname_cellrenderertext", | 2053 | "datacache-mysql", |
2545 | "editing-started", | 2054 | "HOST", |
2546 | NULL, | 2055 | gettext_noop ("Name of host running MySQL database"), |
2547 | NULL, | 2056 | "https://gnunet.org/configuration-datacache", |
2548 | NULL, | 2057 | &load_text, |
2549 | "https://gnunet.org/configuration-dns", | 2058 | &save_text, NULL, |
2550 | NULL, | 2059 | NULL}, |
2551 | &vpn_dns_service_targethostname_install_edited_handler, | 2060 | |
2552 | NULL, | 2061 | { |
2553 | NULL | 2062 | "GNUNET_setup_transport_wlan_interface_entry", |
2554 | }, | 2063 | "changed", |
2555 | 2064 | "transport-wlan", | |
2556 | { | 2065 | "INTERFACE", |
2557 | "GNUNET_setup_vpn_dns_service_targetport_cellrenderertext", | 2066 | gettext_noop ("Name of monitoring interface to use (monX)"), |
2558 | "editing-started", | 2067 | "https://gnunet.org/configuration-wlan", |
2559 | NULL, | 2068 | &load_text, |
2560 | NULL, | 2069 | &save_text, NULL, |
2561 | NULL, | 2070 | NULL}, |
2562 | "https://gnunet.org/configuration-dns", | 2071 | |
2563 | NULL, | 2072 | { |
2564 | &vpn_dns_service_targetport_install_edited_handler, | 2073 | "GNUNET_setup_datacache_mysql_port_spinbutton", |
2565 | NULL, | 2074 | "value-changed", |
2566 | NULL | 2075 | "datacache-mysql", |
2567 | }, | 2076 | "PORT", |
2568 | 2077 | gettext_noop ("Port of MySQL database"), | |
2569 | /* END of list */ | 2078 | "https://gnunet.org/configuration-datacache", |
2570 | 2079 | &load_number, | |
2571 | { NULL, NULL, NULL, NULL, NULL, | 2080 | &save_number, NULL, |
2572 | NULL, NULL, NULL, NULL } | 2081 | NULL}, |
2573 | }; | 2082 | |
2083 | { | ||
2084 | "GNUNET_setup_datacache_postgres_config_entry", | ||
2085 | "changed", | ||
2086 | "datacache-postgres", | ||
2087 | "CONFIG", | ||
2088 | gettext_noop ("Configuration for Postgres (passed to PQconnectdb)"), | ||
2089 | "http://www.postgresql.org/docs/8.1/static/libpq.html#LIBPQ-CONNECT", | ||
2090 | &load_text, | ||
2091 | &save_text, NULL, | ||
2092 | NULL}, | ||
2093 | |||
2094 | { | ||
2095 | "GNUNET_setup_vpn_master_interface_entry", | ||
2096 | "changed", | ||
2097 | "vpn", | ||
2098 | "IFNAME", | ||
2099 | gettext_noop ("Name of the virtual interface the GNUnet VPN should create"), | ||
2100 | "https://gnunet.org/configuration-vpn", | ||
2101 | &load_text, | ||
2102 | &save_text, NULL, | ||
2103 | NULL}, | ||
2104 | |||
2105 | { | ||
2106 | "GNUNET_setup_vpn_master_interface_v4_ip_entry", | ||
2107 | "changed", | ||
2108 | "vpn", | ||
2109 | "IPV4ADDR", | ||
2110 | gettext_noop ("IPv4 address to use for the VPN interface"), | ||
2111 | "https://gnunet.org/configuration-vpn", | ||
2112 | &load_text, | ||
2113 | &save_text, NULL, | ||
2114 | NULL}, | ||
2115 | |||
2116 | { | ||
2117 | "GNUNET_setup_vpn_master_interface_v4_mask_entry", | ||
2118 | "changed", | ||
2119 | "vpn", | ||
2120 | "IPV4MASK", | ||
2121 | gettext_noop ("IPv4 network mask to use for the VPN interface"), | ||
2122 | "https://gnunet.org/configuration-vpn", | ||
2123 | &load_text, | ||
2124 | &save_text, NULL, | ||
2125 | NULL}, | ||
2126 | |||
2127 | { | ||
2128 | "GNUNET_setup_vpn_master_interface_v6_ip_entry", | ||
2129 | "changed", | ||
2130 | "vpn", | ||
2131 | "IPV6ADDR", | ||
2132 | gettext_noop ("IPv6 address to use for the VPN interface"), | ||
2133 | "https://gnunet.org/configuration-vpn", | ||
2134 | &load_text, | ||
2135 | &save_text, NULL, | ||
2136 | NULL}, | ||
2137 | |||
2138 | { | ||
2139 | "GNUNET_setup_vpn_master_interface_v6_mask_spinbutton", | ||
2140 | "value-changed", | ||
2141 | "vpn", | ||
2142 | "IPV6MASK", | ||
2143 | gettext_noop ("IPv6 network prefix length to use for the VPN interface"), | ||
2144 | "https://gnunet.org/configuration-vpn", | ||
2145 | &load_number, | ||
2146 | &save_number, NULL, | ||
2147 | NULL}, | ||
2148 | |||
2149 | { | ||
2150 | "GNUNET_setup_vpn_master_vdns_server_entry", | ||
2151 | "changed", | ||
2152 | "vpn", | ||
2153 | "VIRTDNS", | ||
2154 | gettext_noop | ||
2155 | ("IP address of the virtual DNS server that resolves through GNUnet (use in resolve.conf if you want to resolve through some GNUnet DNS Exit)"), | ||
2156 | "https://gnunet.org/configuration-vpn", | ||
2157 | &load_text, | ||
2158 | &save_text, NULL, | ||
2159 | NULL}, | ||
2160 | |||
2161 | { | ||
2162 | "GNUNET_setup_vpn_enable_vpn_exit_checkbutton", | ||
2163 | "toggled", | ||
2164 | "arm", | ||
2165 | "DEFAULTSERVICES", | ||
2166 | gettext_noop | ||
2167 | ("Activate the VPN exit to provide services and/or to enable others to use your Internet connection"), | ||
2168 | "https://gnunet.org/configuration-exit", | ||
2169 | &load_option_list, | ||
2170 | &save_option_list, "exit", | ||
2171 | hide_exit_options}, | ||
2172 | |||
2173 | { | ||
2174 | "GNUNET_setup_vpn_enable_dns_exit_checkbutton", | ||
2175 | "toggled", | ||
2176 | "dns", | ||
2177 | "PROVIDE_EXIT", | ||
2178 | gettext_noop | ||
2179 | ("Allow other peers to perform DNS resolutions using your Internet connection"), | ||
2180 | "https://gnunet.org/configuration-dns", | ||
2181 | &load_yes_no, | ||
2182 | &save_yes_no, NULL, | ||
2183 | NULL}, | ||
2184 | |||
2185 | { | ||
2186 | "GNUNET_setup_vpn_exit_interface_name_entry", | ||
2187 | "changed", | ||
2188 | "exit", | ||
2189 | "IFNAME", | ||
2190 | gettext_noop | ||
2191 | ("Name of the virtual interface the GNUnet exit service should create for traffic exiting the VPN to the Internet"), | ||
2192 | "https://gnunet.org/configuration-exit", | ||
2193 | &load_text, | ||
2194 | &save_text, NULL, | ||
2195 | NULL}, | ||
2196 | |||
2197 | { | ||
2198 | "GNUNET_setup_vpn_exit_interface_v4_ip_entry", | ||
2199 | "changed", | ||
2200 | "exit", | ||
2201 | "IPV4ADDR", | ||
2202 | gettext_noop ("IPv4 address to use for the VPN Exit interface"), | ||
2203 | "https://gnunet.org/configuration-exit", | ||
2204 | &load_text, | ||
2205 | &save_text, NULL, | ||
2206 | NULL}, | ||
2207 | |||
2208 | { | ||
2209 | "GNUNET_setup_vpn_exit_interface_v4_mask_entry", | ||
2210 | "changed", | ||
2211 | "exit", | ||
2212 | "IPV4MASK", | ||
2213 | gettext_noop ("IPv4 network mask to use for the VPN Exit interface"), | ||
2214 | "https://gnunet.org/configuration-exit", | ||
2215 | &load_text, | ||
2216 | &save_text, NULL, | ||
2217 | NULL}, | ||
2218 | |||
2219 | { | ||
2220 | "GNUNET_setup_vpn_exit_interface_v6_ip_entry", | ||
2221 | "changed", | ||
2222 | "exit", | ||
2223 | "IPV6ADDR", | ||
2224 | gettext_noop ("IPv6 address to use for the VPN Exit interface"), | ||
2225 | "https://gnunet.org/configuration-exit", | ||
2226 | &load_text, | ||
2227 | &save_text, NULL, | ||
2228 | NULL}, | ||
2229 | |||
2230 | { | ||
2231 | "GNUNET_setup_vpn_exit_interface_v6_mask_spinbutton", | ||
2232 | "value-changed", | ||
2233 | "exit", | ||
2234 | "IPV6MASK", | ||
2235 | gettext_noop | ||
2236 | ("IPv6 network prefix length to use for the VPN Exit interface"), | ||
2237 | "https://gnunet.org/configuration-exit", | ||
2238 | &load_number, | ||
2239 | &save_number, NULL, | ||
2240 | NULL}, | ||
2241 | |||
2242 | |||
2243 | { | ||
2244 | "GNUNET_setup_vpn_exit_enable_udp_checkbutton", | ||
2245 | "toggled", | ||
2246 | "exit", | ||
2247 | "ENABLE_UDP", | ||
2248 | gettext_noop | ||
2249 | ("Allow other users to use your Internet connection for UDP traffic (via the Exit interface)"), | ||
2250 | "https://gnunet.org/configuration-exit", | ||
2251 | &load_yes_no, | ||
2252 | &save_yes_no, NULL, | ||
2253 | NULL}, | ||
2254 | |||
2255 | { | ||
2256 | "GNUNET_setup_vpn_exit_enable_tcp_checkbutton", | ||
2257 | "toggled", | ||
2258 | "exit", | ||
2259 | "ENABLE_TCP", | ||
2260 | gettext_noop | ||
2261 | ("Allow other users to use your Internet connection for TCP traffic (via the Exit interface)"), | ||
2262 | "https://gnunet.org/configuration-exit", | ||
2263 | &load_yes_no, | ||
2264 | &save_yes_no, NULL, | ||
2265 | NULL}, | ||
2266 | |||
2267 | /* DNS treeview */ | ||
2268 | |||
2269 | { | ||
2270 | "GNUNET_setup_vpn_dns_service_treeview", | ||
2271 | NULL, | ||
2272 | NULL, | ||
2273 | NULL, | ||
2274 | gettext_noop | ||
2275 | ("Specification of .gnunet hostnames and services offered by this peer"), | ||
2276 | "https://gnunet.org/configuration-dns", | ||
2277 | &load_vpn_dns_configuration, | ||
2278 | NULL, NULL, | ||
2279 | NULL}, | ||
2280 | |||
2281 | { | ||
2282 | "GNUNET_setup_vpn_dns_service_dnsname_cellrenderertext", | ||
2283 | "editing-started", | ||
2284 | NULL, | ||
2285 | NULL, | ||
2286 | NULL, | ||
2287 | "https://gnunet.org/configuration-dns", | ||
2288 | NULL, | ||
2289 | &vpn_dns_service_dnsname_install_edited_handler, | ||
2290 | NULL, | ||
2291 | NULL}, | ||
2292 | |||
2293 | { | ||
2294 | "GNUNET_setup_vpn_dns_service_tcpudp_cellrenderertext", | ||
2295 | "editing-started", | ||
2296 | NULL, | ||
2297 | NULL, | ||
2298 | NULL, | ||
2299 | "https://gnunet.org/configuration-dns", | ||
2300 | NULL, | ||
2301 | &vpn_dns_service_tcpudp_install_edited_handler, | ||
2302 | NULL, | ||
2303 | NULL}, | ||
2304 | |||
2305 | { | ||
2306 | "GNUNET_setup_vpn_dns_service_sourceport_cellrenderertext", | ||
2307 | "editing-started", | ||
2308 | NULL, | ||
2309 | NULL, | ||
2310 | NULL, | ||
2311 | "https://gnunet.org/configuration-dns", | ||
2312 | NULL, | ||
2313 | &vpn_dns_service_sourceport_install_edited_handler, | ||
2314 | NULL, | ||
2315 | NULL}, | ||
2316 | |||
2317 | { | ||
2318 | "GNUNET_setup_vpn_dns_service_targethostname_cellrenderertext", | ||
2319 | "editing-started", | ||
2320 | NULL, | ||
2321 | NULL, | ||
2322 | NULL, | ||
2323 | "https://gnunet.org/configuration-dns", | ||
2324 | NULL, | ||
2325 | &vpn_dns_service_targethostname_install_edited_handler, | ||
2326 | NULL, | ||
2327 | NULL}, | ||
2328 | |||
2329 | { | ||
2330 | "GNUNET_setup_vpn_dns_service_targetport_cellrenderertext", | ||
2331 | "editing-started", | ||
2332 | NULL, | ||
2333 | NULL, | ||
2334 | NULL, | ||
2335 | "https://gnunet.org/configuration-dns", | ||
2336 | NULL, | ||
2337 | &vpn_dns_service_targetport_install_edited_handler, | ||
2338 | NULL, | ||
2339 | NULL}, | ||
2340 | |||
2341 | /* END of list */ | ||
2342 | |||
2343 | {NULL, NULL, NULL, NULL, NULL, | ||
2344 | NULL, NULL, NULL, NULL} | ||
2345 | }; | ||
2574 | 2346 | ||
2575 | /* end of gnunet-setup-options.c */ | 2347 | /* end of gnunet-setup-options.c */ |
diff --git a/src/setup/gnunet-setup-transport-http.c b/src/setup/gnunet-setup-transport-http.c index 17c116c6..2820f0a1 100644 --- a/src/setup/gnunet-setup-transport-http.c +++ b/src/setup/gnunet-setup-transport-http.c | |||
@@ -36,10 +36,9 @@ | |||
36 | void | 36 | void |
37 | GNUNET_setup_transport_http_test_button_clicked_cb () | 37 | GNUNET_setup_transport_http_test_button_clicked_cb () |
38 | { | 38 | { |
39 | GNUNET_setup_transport_test ("transport-http", | 39 | GNUNET_setup_transport_test ("transport-http", GNUNET_YES, |
40 | GNUNET_YES, | 40 | "GNUNET_setup_transport_http_test_success_image", |
41 | "GNUNET_setup_transport_http_test_success_image", | 41 | "GNUNET_setup_transport_http_test_fail_image"); |
42 | "GNUNET_setup_transport_http_test_fail_image"); | ||
43 | } | 42 | } |
44 | 43 | ||
45 | 44 | ||
diff --git a/src/setup/gnunet-setup-transport-https.c b/src/setup/gnunet-setup-transport-https.c index 08554383..80ae2457 100644 --- a/src/setup/gnunet-setup-transport-https.c +++ b/src/setup/gnunet-setup-transport-https.c | |||
@@ -36,10 +36,9 @@ | |||
36 | void | 36 | void |
37 | GNUNET_setup_transport_https_test_button_clicked_cb () | 37 | GNUNET_setup_transport_https_test_button_clicked_cb () |
38 | { | 38 | { |
39 | GNUNET_setup_transport_test ("transport-https", | 39 | GNUNET_setup_transport_test ("transport-https", GNUNET_YES, |
40 | GNUNET_YES, | 40 | "GNUNET_setup_transport_https_test_success_image", |
41 | "GNUNET_setup_transport_https_test_success_image", | 41 | "GNUNET_setup_transport_https_test_fail_image"); |
42 | "GNUNET_setup_transport_https_test_fail_image"); | ||
43 | } | 42 | } |
44 | 43 | ||
45 | 44 | ||
diff --git a/src/setup/gnunet-setup-transport-plugins.c b/src/setup/gnunet-setup-transport-plugins.c index 52fa9dea..f17b13d0 100644 --- a/src/setup/gnunet-setup-transport-plugins.c +++ b/src/setup/gnunet-setup-transport-plugins.c | |||
@@ -34,72 +34,66 @@ | |||
34 | * @param name name of the plugin to check | 34 | * @param name name of the plugin to check |
35 | */ | 35 | */ |
36 | static void | 36 | static void |
37 | test_plugin (GtkWidget *widget, | 37 | test_plugin (GtkWidget * widget, const char *name) |
38 | const char *name) | ||
39 | { | 38 | { |
40 | if (GNUNET_YES == | 39 | if (GNUNET_YES == GNUNET_PLUGIN_test (name)) |
41 | GNUNET_PLUGIN_test (name)) | 40 | { |
42 | { | 41 | gtk_widget_set_sensitive (widget, TRUE); |
43 | gtk_widget_set_sensitive (widget, | 42 | } |
44 | TRUE); | ||
45 | } | ||
46 | else | 43 | else |
47 | { | 44 | { |
48 | gtk_widget_set_sensitive (widget, | 45 | gtk_widget_set_sensitive (widget, FALSE); |
49 | FALSE); | 46 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE); |
50 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), | 47 | } |
51 | FALSE); | ||
52 | } | ||
53 | } | 48 | } |
54 | 49 | ||
55 | 50 | ||
56 | 51 | ||
57 | void | 52 | void |
58 | GNUNET_setup_transport_tcp_checkbutton_realize_cb (GtkWidget *widget, | 53 | GNUNET_setup_transport_tcp_checkbutton_realize_cb (GtkWidget * widget, |
59 | gpointer user_data) | 54 | gpointer user_data) |
60 | { | 55 | { |
61 | test_plugin (widget, "libgnunet_plugin_transport_tcp"); | 56 | test_plugin (widget, "libgnunet_plugin_transport_tcp"); |
62 | } | 57 | } |
63 | 58 | ||
64 | 59 | ||
65 | void | 60 | void |
66 | GNUNET_setup_transport_udp_checkbutton_realize_cb (GtkWidget *widget, | 61 | GNUNET_setup_transport_udp_checkbutton_realize_cb (GtkWidget * widget, |
67 | gpointer user_data) | 62 | gpointer user_data) |
68 | { | 63 | { |
69 | test_plugin (widget, "libgnunet_plugin_transport_udp"); | 64 | test_plugin (widget, "libgnunet_plugin_transport_udp"); |
70 | } | 65 | } |
71 | 66 | ||
72 | 67 | ||
73 | void | 68 | void |
74 | GNUNET_setup_transport_http_checkbutton_realize_cb (GtkWidget *widget, | 69 | GNUNET_setup_transport_http_checkbutton_realize_cb (GtkWidget * widget, |
75 | gpointer user_data) | 70 | gpointer user_data) |
76 | { | 71 | { |
77 | test_plugin (widget, "libgnunet_plugin_transport_http"); | 72 | test_plugin (widget, "libgnunet_plugin_transport_http"); |
78 | } | 73 | } |
79 | 74 | ||
80 | 75 | ||
81 | void | 76 | void |
82 | GNUNET_setup_transport_https_checkbutton_realize_cb (GtkWidget *widget, | 77 | GNUNET_setup_transport_https_checkbutton_realize_cb (GtkWidget * widget, |
83 | gpointer user_data) | 78 | gpointer user_data) |
84 | { | 79 | { |
85 | test_plugin (widget, "libgnunet_plugin_transport_https"); | 80 | test_plugin (widget, "libgnunet_plugin_transport_https"); |
86 | } | 81 | } |
87 | 82 | ||
88 | 83 | ||
89 | void | 84 | void |
90 | GNUNET_setup_transport_dv_checkbutton_realize_cb (GtkWidget *widget, | 85 | GNUNET_setup_transport_dv_checkbutton_realize_cb (GtkWidget * widget, |
91 | gpointer user_data) | 86 | gpointer user_data) |
92 | { | 87 | { |
93 | test_plugin (widget, "libgnunet_plugin_transport_dv"); | 88 | test_plugin (widget, "libgnunet_plugin_transport_dv"); |
94 | } | 89 | } |
95 | 90 | ||
96 | 91 | ||
97 | void | 92 | void |
98 | GNUNET_setup_transport_wlan_checkbutton_realize_cb (GtkWidget *widget, | 93 | GNUNET_setup_transport_wlan_checkbutton_realize_cb (GtkWidget * widget, |
99 | gpointer user_data) | 94 | gpointer user_data) |
100 | { | 95 | { |
101 | test_plugin (widget, "libgnunet_plugin_transport_wlan"); | 96 | test_plugin (widget, "libgnunet_plugin_transport_wlan"); |
102 | } | 97 | } |
103 | 98 | ||
104 | /* end of gnunet-setup-transport-plugins.c */ | 99 | /* end of gnunet-setup-transport-plugins.c */ |
105 | |||
diff --git a/src/setup/gnunet-setup-transport-tcp.c b/src/setup/gnunet-setup-transport-tcp.c index 89d8085c..d82fb16b 100644 --- a/src/setup/gnunet-setup-transport-tcp.c +++ b/src/setup/gnunet-setup-transport-tcp.c | |||
@@ -36,10 +36,9 @@ | |||
36 | void | 36 | void |
37 | GNUNET_setup_transport_tcp_test_button_clicked_cb () | 37 | GNUNET_setup_transport_tcp_test_button_clicked_cb () |
38 | { | 38 | { |
39 | GNUNET_setup_transport_test ("transport-tcp", | 39 | GNUNET_setup_transport_test ("transport-tcp", GNUNET_YES, |
40 | GNUNET_YES, | 40 | "GNUNET_setup_transport_tcp_test_success_image", |
41 | "GNUNET_setup_transport_tcp_test_success_image", | 41 | "GNUNET_setup_transport_tcp_test_fail_image"); |
42 | "GNUNET_setup_transport_tcp_test_fail_image"); | ||
43 | } | 42 | } |
44 | 43 | ||
45 | 44 | ||
diff --git a/src/setup/gnunet-setup-transport-test.c b/src/setup/gnunet-setup-transport-test.c index 4bc9c26c..87f8fc9f 100644 --- a/src/setup/gnunet-setup-transport-test.c +++ b/src/setup/gnunet-setup-transport-test.c | |||
@@ -48,9 +48,9 @@ struct TestContext | |||
48 | 48 | ||
49 | /** | 49 | /** |
50 | * Name of widget to show on success. | 50 | * Name of widget to show on success. |
51 | */ | 51 | */ |
52 | const char *success_image; | 52 | const char *success_image; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * Name of widget to show on failure. | 55 | * Name of widget to show on failure. |
56 | */ | 56 | */ |
@@ -66,39 +66,38 @@ struct TestContext | |||
66 | * @param result GNUNET_YES on success | 66 | * @param result GNUNET_YES on success |
67 | */ | 67 | */ |
68 | static void | 68 | static void |
69 | display_test_result (struct TestContext *tc, | 69 | display_test_result (struct TestContext *tc, int result) |
70 | int result) | ||
71 | { | 70 | { |
72 | GObject *w; | 71 | GObject *w; |
73 | 72 | ||
74 | if (GNUNET_YES != result) | 73 | if (GNUNET_YES != result) |
75 | { | 74 | { |
76 | w = GNUNET_SETUP_get_object (tc->failure_image); | 75 | w = GNUNET_SETUP_get_object (tc->failure_image); |
77 | if (NULL != w) | 76 | if (NULL != w) |
78 | gtk_widget_show (GTK_WIDGET (w)); | 77 | gtk_widget_show (GTK_WIDGET (w)); |
79 | w = GNUNET_SETUP_get_object (tc->success_image); | 78 | w = GNUNET_SETUP_get_object (tc->success_image); |
80 | if (NULL != w) | 79 | if (NULL != w) |
81 | gtk_widget_hide (GTK_WIDGET (w)); | 80 | gtk_widget_hide (GTK_WIDGET (w)); |
82 | } | 81 | } |
83 | else | 82 | else |
84 | { | 83 | { |
85 | w = GNUNET_SETUP_get_object (tc->failure_image); | 84 | w = GNUNET_SETUP_get_object (tc->failure_image); |
86 | if (NULL != w) | 85 | if (NULL != w) |
87 | gtk_widget_hide (GTK_WIDGET (w)); | 86 | gtk_widget_hide (GTK_WIDGET (w)); |
88 | w = GNUNET_SETUP_get_object (tc->success_image); | 87 | w = GNUNET_SETUP_get_object (tc->success_image); |
89 | if (NULL != w) | 88 | if (NULL != w) |
90 | gtk_widget_show (GTK_WIDGET (w)); | 89 | gtk_widget_show (GTK_WIDGET (w)); |
91 | } | 90 | } |
92 | if (GNUNET_SCHEDULER_NO_TASK != tc->tsk) | 91 | if (GNUNET_SCHEDULER_NO_TASK != tc->tsk) |
93 | { | 92 | { |
94 | GNUNET_SCHEDULER_cancel (tc->tsk); | 93 | GNUNET_SCHEDULER_cancel (tc->tsk); |
95 | tc->tsk = GNUNET_SCHEDULER_NO_TASK; | 94 | tc->tsk = GNUNET_SCHEDULER_NO_TASK; |
96 | } | 95 | } |
97 | if (NULL != tc->tst) | 96 | if (NULL != tc->tst) |
98 | { | 97 | { |
99 | GNUNET_NAT_test_stop (tc->tst); | 98 | GNUNET_NAT_test_stop (tc->tst); |
100 | tc->tst = NULL; | 99 | tc->tst = NULL; |
101 | } | 100 | } |
102 | GNUNET_free (tc); | 101 | GNUNET_free (tc); |
103 | } | 102 | } |
104 | 103 | ||
@@ -111,8 +110,7 @@ display_test_result (struct TestContext *tc, | |||
111 | * @param success currently always GNUNET_OK | 110 | * @param success currently always GNUNET_OK |
112 | */ | 111 | */ |
113 | static void | 112 | static void |
114 | result_callback (void *cls, | 113 | result_callback (void *cls, int success) |
115 | int success) | ||
116 | { | 114 | { |
117 | struct TestContext *tc = cls; | 115 | struct TestContext *tc = cls; |
118 | 116 | ||
@@ -128,8 +126,7 @@ result_callback (void *cls, | |||
128 | * @param tc scheduler callback | 126 | * @param tc scheduler callback |
129 | */ | 127 | */ |
130 | static void | 128 | static void |
131 | fail_timeout (void *cls, | 129 | fail_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
132 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
133 | { | 130 | { |
134 | struct TestContext *tstc = cls; | 131 | struct TestContext *tstc = cls; |
135 | 132 | ||
@@ -148,10 +145,9 @@ fail_timeout (void *cls, | |||
148 | * @param failure_image image to show on failure | 145 | * @param failure_image image to show on failure |
149 | */ | 146 | */ |
150 | void | 147 | void |
151 | GNUNET_setup_transport_test (const char *section_name, | 148 | GNUNET_setup_transport_test (const char *section_name, int is_tcp, |
152 | int is_tcp, | 149 | const char *success_image, |
153 | const char *success_image, | 150 | const char *failure_image) |
154 | const char *failure_image) | ||
155 | { | 151 | { |
156 | struct TestContext *tc; | 152 | struct TestContext *tc; |
157 | unsigned long long bnd_port; | 153 | unsigned long long bnd_port; |
@@ -159,19 +155,15 @@ GNUNET_setup_transport_test (const char *section_name, | |||
159 | GtkWidget *w; | 155 | GtkWidget *w; |
160 | 156 | ||
161 | if (GNUNET_OK != | 157 | if (GNUNET_OK != |
162 | GNUNET_CONFIGURATION_get_value_number (cfg, | 158 | GNUNET_CONFIGURATION_get_value_number (cfg, section_name, "PORT", |
163 | section_name, | 159 | &bnd_port)) |
164 | "PORT", | 160 | { |
165 | &bnd_port)) | 161 | GNUNET_break (0); |
166 | { | 162 | return; |
167 | GNUNET_break (0); | 163 | } |
168 | return; | ||
169 | } | ||
170 | if (GNUNET_OK != | 164 | if (GNUNET_OK != |
171 | GNUNET_CONFIGURATION_get_value_number (cfg, | 165 | GNUNET_CONFIGURATION_get_value_number (cfg, section_name, |
172 | section_name, | 166 | "ADVERTISED_PORT", &adv_port)) |
173 | "ADVERTISED_PORT", | ||
174 | &adv_port)) | ||
175 | adv_port = bnd_port; | 167 | adv_port = bnd_port; |
176 | tc = GNUNET_malloc (sizeof (struct TestContext)); | 168 | tc = GNUNET_malloc (sizeof (struct TestContext)); |
177 | tc->success_image = success_image; | 169 | tc->success_image = success_image; |
@@ -180,20 +172,15 @@ GNUNET_setup_transport_test (const char *section_name, | |||
180 | gtk_widget_hide (w); | 172 | gtk_widget_hide (w); |
181 | GNUNET_assert (NULL != cfg); | 173 | GNUNET_assert (NULL != cfg); |
182 | GNUNET_RESOLVER_connect (cfg); | 174 | GNUNET_RESOLVER_connect (cfg); |
183 | tc->tst = GNUNET_NAT_test_start (cfg, | 175 | tc->tst = |
184 | is_tcp, | 176 | GNUNET_NAT_test_start (cfg, is_tcp, (uint16_t) bnd_port, |
185 | (uint16_t) bnd_port, | 177 | (uint16_t) adv_port, &result_callback, tc); |
186 | (uint16_t) adv_port, | ||
187 | &result_callback, | ||
188 | tc); | ||
189 | if (NULL == tc->tst) | 178 | if (NULL == tc->tst) |
190 | { | 179 | { |
191 | display_test_result (tc, GNUNET_SYSERR); | 180 | display_test_result (tc, GNUNET_SYSERR); |
192 | return; | 181 | return; |
193 | } | 182 | } |
194 | tc->tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 183 | tc->tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &fail_timeout, tc); |
195 | &fail_timeout, | ||
196 | tc); | ||
197 | } | 184 | } |
198 | 185 | ||
199 | /* end of gnunet-setup-transport-test.c */ | 186 | /* end of gnunet-setup-transport-test.c */ |
diff --git a/src/setup/gnunet-setup-transport-udp.c b/src/setup/gnunet-setup-transport-udp.c index f758f8d0..60421c78 100644 --- a/src/setup/gnunet-setup-transport-udp.c +++ b/src/setup/gnunet-setup-transport-udp.c | |||
@@ -37,10 +37,9 @@ void | |||
37 | GNUNET_setup_transport_udp_test_button_clicked_cb () | 37 | GNUNET_setup_transport_udp_test_button_clicked_cb () |
38 | { | 38 | { |
39 | 39 | ||
40 | GNUNET_setup_transport_test ("transport-udp", | 40 | GNUNET_setup_transport_test ("transport-udp", GNUNET_NO, |
41 | GNUNET_NO, | 41 | "GNUNET_setup_transport_udp_test_success_image", |
42 | "GNUNET_setup_transport_udp_test_success_image", | 42 | "GNUNET_setup_transport_udp_test_fail_image"); |
43 | "GNUNET_setup_transport_udp_test_fail_image"); | ||
44 | 43 | ||
45 | } | 44 | } |
46 | 45 | ||
diff --git a/src/setup/gnunet-setup-transport.c b/src/setup/gnunet-setup-transport.c index 6b4d243c..3fae215a 100644 --- a/src/setup/gnunet-setup-transport.c +++ b/src/setup/gnunet-setup-transport.c | |||
@@ -56,14 +56,15 @@ update_icmp_server_enable_button (int on) | |||
56 | { | 56 | { |
57 | GtkToggleButton *button; | 57 | GtkToggleButton *button; |
58 | 58 | ||
59 | button = GTK_TOGGLE_BUTTON (GNUNET_SETUP_get_object ("GNUNET_setup_transport_icmp_server_enable_checkbutton")); | 59 | button = |
60 | GTK_TOGGLE_BUTTON (GNUNET_SETUP_get_object | ||
61 | ("GNUNET_setup_transport_icmp_server_enable_checkbutton")); | ||
60 | if (button == NULL) | 62 | if (button == NULL) |
61 | { | 63 | { |
62 | GNUNET_break (0); | 64 | GNUNET_break (0); |
63 | return; | 65 | return; |
64 | } | 66 | } |
65 | gtk_toggle_button_set_active (button, | 67 | gtk_toggle_button_set_active (button, on ? TRUE : FALSE); |
66 | on ? TRUE : FALSE); | ||
67 | } | 68 | } |
68 | 69 | ||
69 | 70 | ||
@@ -75,18 +76,17 @@ update_icmp_server_enable_button (int on) | |||
75 | * @param success currently always GNUNET_OK | 76 | * @param success currently always GNUNET_OK |
76 | */ | 77 | */ |
77 | static void | 78 | static void |
78 | result_callback (void *cls, | 79 | result_callback (void *cls, int success) |
79 | int success) | ||
80 | { | 80 | { |
81 | GNUNET_SCHEDULER_cancel (tsk); | 81 | GNUNET_SCHEDULER_cancel (tsk); |
82 | tsk = GNUNET_SCHEDULER_NO_TASK; | 82 | tsk = GNUNET_SCHEDULER_NO_TASK; |
83 | GNUNET_NAT_test_stop (tst); | 83 | GNUNET_NAT_test_stop (tst); |
84 | tst = NULL; | 84 | tst = NULL; |
85 | if (NULL != resolver) | 85 | if (NULL != resolver) |
86 | { | 86 | { |
87 | GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM)); | 87 | GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM)); |
88 | GNUNET_OS_process_close (resolver); | 88 | GNUNET_OS_process_close (resolver); |
89 | } | 89 | } |
90 | update_icmp_server_enable_button (success); | 90 | update_icmp_server_enable_button (success); |
91 | } | 91 | } |
92 | 92 | ||
@@ -99,8 +99,7 @@ result_callback (void *cls, | |||
99 | * @param tc scheduler callback | 99 | * @param tc scheduler callback |
100 | */ | 100 | */ |
101 | static void | 101 | static void |
102 | fail_timeout (void *cls, | 102 | fail_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
103 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
104 | { | 103 | { |
105 | GNUNET_assert (NULL != tst); | 104 | GNUNET_assert (NULL != tst); |
106 | tsk = GNUNET_SCHEDULER_NO_TASK; | 105 | tsk = GNUNET_SCHEDULER_NO_TASK; |
@@ -116,27 +115,20 @@ fail_timeout (void *cls, | |||
116 | * @param cls the 'int*' for the result | 115 | * @param cls the 'int*' for the result |
117 | * @param tc scheduler context | 116 | * @param tc scheduler context |
118 | */ | 117 | */ |
119 | static void | 118 | static void |
120 | reversal_test (void *cls, | 119 | reversal_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
121 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
122 | { | 120 | { |
123 | int *ok = cls; | 121 | int *ok = cls; |
124 | 122 | ||
125 | GNUNET_assert (NULL != cfg); | 123 | GNUNET_assert (NULL != cfg); |
126 | GNUNET_RESOLVER_connect (cfg); | 124 | GNUNET_RESOLVER_connect (cfg); |
127 | tst = GNUNET_NAT_test_start (cfg, | 125 | tst = GNUNET_NAT_test_start (cfg, GNUNET_YES, 0, 0, &result_callback, ok); |
128 | GNUNET_YES, | ||
129 | 0, 0, | ||
130 | &result_callback, | ||
131 | ok); | ||
132 | if (NULL == tst) | 126 | if (NULL == tst) |
133 | { | 127 | { |
134 | *ok = GNUNET_SYSERR; | 128 | *ok = GNUNET_SYSERR; |
135 | return; | 129 | return; |
136 | } | 130 | } |
137 | tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 131 | tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &fail_timeout, ok); |
138 | &fail_timeout, | ||
139 | ok); | ||
140 | } | 132 | } |
141 | 133 | ||
142 | /** | 134 | /** |
@@ -146,10 +138,10 @@ static void | |||
146 | test_connection_reversal () | 138 | test_connection_reversal () |
147 | { | 139 | { |
148 | if (NULL != resolver) | 140 | if (NULL != resolver) |
149 | return; /* test already active!? */ | 141 | return; /* test already active!? */ |
150 | resolver = GNUNET_OS_start_process (NULL, NULL, | 142 | resolver = |
151 | "gnunet-service-resolver", | 143 | GNUNET_OS_start_process (NULL, NULL, "gnunet-service-resolver", |
152 | "gnunet-service-resolver", NULL); | 144 | "gnunet-service-resolver", NULL); |
153 | GNUNET_SCHEDULER_add_now (&reversal_test, NULL); | 145 | GNUNET_SCHEDULER_add_now (&reversal_test, NULL); |
154 | } | 146 | } |
155 | 147 | ||
@@ -166,36 +158,31 @@ test_connection_reversal () | |||
166 | * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort | 158 | * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort |
167 | */ | 159 | */ |
168 | static int | 160 | static int |
169 | nipo (void *cls, | 161 | nipo (void *cls, const char *name, int isDefault, const struct sockaddr *addr, |
170 | const char *name, | 162 | socklen_t addrlen) |
171 | int isDefault, | ||
172 | const struct sockaddr * | ||
173 | addr, socklen_t addrlen) | ||
174 | { | 163 | { |
175 | const struct sockaddr_in *in; | 164 | const struct sockaddr_in *in; |
176 | char buf[INET_ADDRSTRLEN]; | 165 | char buf[INET_ADDRSTRLEN]; |
177 | GtkEntry *entry; | 166 | GtkEntry *entry; |
178 | 167 | ||
179 | if (! isDefault) | 168 | if (!isDefault) |
180 | return GNUNET_OK; | 169 | return GNUNET_OK; |
181 | if (addrlen != sizeof (struct sockaddr_in)) | 170 | if (addrlen != sizeof (struct sockaddr_in)) |
182 | return GNUNET_OK; | 171 | return GNUNET_OK; |
183 | in = (const struct sockaddr_in*) addr; | 172 | in = (const struct sockaddr_in *) addr; |
184 | 173 | ||
185 | /* set internal IP address */ | 174 | /* set internal IP address */ |
186 | inet_ntop (AF_INET, &in->sin_addr, buf, sizeof(buf)); | 175 | inet_ntop (AF_INET, &in->sin_addr, buf, sizeof (buf)); |
187 | GNUNET_CONFIGURATION_set_value_string (cfg, | 176 | GNUNET_CONFIGURATION_set_value_string (cfg, "nat", "INTERNAL_ADDRESS", buf); |
188 | "nat", | 177 | entry = |
189 | "INTERNAL_ADDRESS", | 178 | GTK_ENTRY (GNUNET_SETUP_get_object |
190 | buf); | 179 | ("GNUNET_setup_transport_internal_ip_entry")); |
191 | entry = GTK_ENTRY (GNUNET_SETUP_get_object ("GNUNET_setup_transport_internal_ip_entry")); | ||
192 | if (entry == NULL) | 180 | if (entry == NULL) |
193 | { | 181 | { |
194 | GNUNET_break (0); | 182 | GNUNET_break (0); |
195 | return GNUNET_SYSERR; | 183 | return GNUNET_SYSERR; |
196 | } | 184 | } |
197 | gtk_entry_set_text (entry, | 185 | gtk_entry_set_text (entry, buf); |
198 | buf); | ||
199 | /* no need to continue iteration */ | 186 | /* no need to continue iteration */ |
200 | return GNUNET_SYSERR; | 187 | return GNUNET_SYSERR; |
201 | } | 188 | } |
@@ -208,8 +195,7 @@ nipo (void *cls, | |||
208 | * @param addr the address, NULL on errors | 195 | * @param addr the address, NULL on errors |
209 | */ | 196 | */ |
210 | static void | 197 | static void |
211 | set_external_ipv4 (void *cls, | 198 | set_external_ipv4 (void *cls, const struct in_addr *addr) |
212 | const struct in_addr *addr) | ||
213 | { | 199 | { |
214 | struct in_addr ia; | 200 | struct in_addr ia; |
215 | char buf[INET_ADDRSTRLEN]; | 201 | char buf[INET_ADDRSTRLEN]; |
@@ -218,46 +204,40 @@ set_external_ipv4 (void *cls, | |||
218 | GtkToggleButton *button; | 204 | GtkToggleButton *button; |
219 | 205 | ||
220 | if (NULL != addr) | 206 | if (NULL != addr) |
221 | { | 207 | { |
222 | /* enable 'behind nat' */ | 208 | /* enable 'behind nat' */ |
223 | if (NULL != cfg) | 209 | if (NULL != cfg) |
224 | GNUNET_CONFIGURATION_set_value_string (cfg, | 210 | GNUNET_CONFIGURATION_set_value_string (cfg, "nat", "BEHIND_NAT", "YES"); |
225 | "nat", | 211 | o = GNUNET_SETUP_get_object ("GNUNET_setup_transport_nat_checkbutton"); |
226 | "BEHIND_NAT", | 212 | if (NULL != o) |
227 | "YES"); | 213 | { |
228 | o = GNUNET_SETUP_get_object ("GNUNET_setup_transport_nat_checkbutton"); | 214 | button = GTK_TOGGLE_BUTTON (o); |
229 | if (NULL != o) | 215 | if (button == NULL) |
230 | { | 216 | { |
231 | button = GTK_TOGGLE_BUTTON (o); | 217 | GNUNET_break (0); |
232 | if (button == NULL) | 218 | return; |
233 | { | 219 | } |
234 | GNUNET_break (0); | 220 | gtk_toggle_button_set_active (button, TRUE); |
235 | return; | ||
236 | } | ||
237 | gtk_toggle_button_set_active (button, | ||
238 | TRUE); | ||
239 | } | ||
240 | |||
241 | /* set external IP address */ | ||
242 | inet_ntop (AF_INET, &ia, buf, sizeof(buf)); | ||
243 | if (NULL != cfg) | ||
244 | GNUNET_CONFIGURATION_set_value_string (cfg, | ||
245 | "nat", | ||
246 | "EXTERNAL_ADDRESS", | ||
247 | buf); | ||
248 | o = GNUNET_SETUP_get_object ("GNUNET_setup_transport_external_ip_address_entry"); | ||
249 | if (NULL != o) | ||
250 | { | ||
251 | entry = GTK_ENTRY (o); | ||
252 | if (entry == NULL) | ||
253 | { | ||
254 | GNUNET_break (0); | ||
255 | return; | ||
256 | } | ||
257 | gtk_entry_set_text (entry, | ||
258 | buf); | ||
259 | } | ||
260 | } | 221 | } |
222 | |||
223 | /* set external IP address */ | ||
224 | inet_ntop (AF_INET, &ia, buf, sizeof (buf)); | ||
225 | if (NULL != cfg) | ||
226 | GNUNET_CONFIGURATION_set_value_string (cfg, "nat", "EXTERNAL_ADDRESS", | ||
227 | buf); | ||
228 | o = GNUNET_SETUP_get_object | ||
229 | ("GNUNET_setup_transport_external_ip_address_entry"); | ||
230 | if (NULL != o) | ||
231 | { | ||
232 | entry = GTK_ENTRY (o); | ||
233 | if (entry == NULL) | ||
234 | { | ||
235 | GNUNET_break (0); | ||
236 | return; | ||
237 | } | ||
238 | gtk_entry_set_text (entry, buf); | ||
239 | } | ||
240 | } | ||
261 | } | 241 | } |
262 | 242 | ||
263 | 243 | ||
@@ -273,9 +253,7 @@ GNUNET_setup_transport_autoconfig_button_clicked_cb () | |||
273 | char *tmp; | 253 | char *tmp; |
274 | 254 | ||
275 | /* try to detect external IP */ | 255 | /* try to detect external IP */ |
276 | (void) GNUNET_NAT_mini_get_external_ipv4 (TIMEOUT, | 256 | (void) GNUNET_NAT_mini_get_external_ipv4 (TIMEOUT, &set_external_ipv4, NULL); |
277 | &set_external_ipv4, | ||
278 | NULL); | ||
279 | /* Try to detect internal IP */ | 257 | /* Try to detect internal IP */ |
280 | GNUNET_OS_network_interfaces_list (&nipo, NULL); | 258 | GNUNET_OS_network_interfaces_list (&nipo, NULL); |
281 | 259 | ||
@@ -283,45 +261,38 @@ GNUNET_setup_transport_autoconfig_button_clicked_cb () | |||
283 | 261 | ||
284 | /* test gnunet-helper-nat-server */ | 262 | /* test gnunet-helper-nat-server */ |
285 | tmp = NULL; | 263 | tmp = NULL; |
286 | hns = ( (GNUNET_OK == | 264 | hns = |
287 | GNUNET_CONFIGURATION_get_value_string (cfg, | 265 | ((GNUNET_OK == |
288 | "nat", | 266 | GNUNET_CONFIGURATION_get_value_string (cfg, "nat", "EXTERNAL_ADDRESS", |
289 | "EXTERNAL_ADDRESS", | 267 | &tmp)) && (0 < strlen (tmp)) && |
290 | &tmp)) && | 268 | (GNUNET_YES == |
291 | (0 < strlen (tmp)) && | 269 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "nat", "BEHIND_NAT")) && |
292 | (GNUNET_YES == | 270 | (GNUNET_YES == |
293 | GNUNET_CONFIGURATION_get_value_yesno (cfg, | 271 | GNUNET_OS_check_helper_binary ("gnunet-helper-nat-server"))); |
294 | "nat", | ||
295 | "BEHIND_NAT")) && | ||
296 | (GNUNET_YES == | ||
297 | GNUNET_OS_check_helper_binary ("gnunet-helper-nat-server")) ); | ||
298 | GNUNET_free_non_null (tmp); | 272 | GNUNET_free_non_null (tmp); |
299 | if (hns) | 273 | if (hns) |
300 | test_connection_reversal (); | 274 | test_connection_reversal (); |
301 | 275 | ||
302 | /* test gnunet-helper-nat-client */ | 276 | /* test gnunet-helper-nat-client */ |
303 | tmp = NULL; | 277 | tmp = NULL; |
304 | hnc = ( (GNUNET_OK == | 278 | hnc = |
305 | GNUNET_CONFIGURATION_get_value_string (cfg, | 279 | ((GNUNET_OK == |
306 | "nat", | 280 | GNUNET_CONFIGURATION_get_value_string (cfg, "nat", "INTERNAL_ADDRESS", |
307 | "INTERNAL_ADDRESS", | 281 | &tmp)) && (0 < strlen (tmp)) && |
308 | &tmp)) && | 282 | (GNUNET_YES != |
309 | (0 < strlen (tmp)) && | 283 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "nat", "BEHIND_NAT")) && |
310 | (GNUNET_YES != | 284 | (GNUNET_YES == |
311 | GNUNET_CONFIGURATION_get_value_yesno (cfg, | 285 | GNUNET_OS_check_helper_binary ("gnunet-helper-nat-client"))); |
312 | "nat", | ||
313 | "BEHIND_NAT")) && | ||
314 | (GNUNET_YES == | ||
315 | GNUNET_OS_check_helper_binary ("gnunet-helper-nat-client")) ); | ||
316 | GNUNET_free_non_null (tmp); | 286 | GNUNET_free_non_null (tmp); |
317 | button = GTK_TOGGLE_BUTTON (GNUNET_SETUP_get_object ("GNUNET_setup_transport_icmp_client_enable_checkbutton")); | 287 | button = |
288 | GTK_TOGGLE_BUTTON (GNUNET_SETUP_get_object | ||
289 | ("GNUNET_setup_transport_icmp_client_enable_checkbutton")); | ||
318 | if (button == NULL) | 290 | if (button == NULL) |
319 | { | 291 | { |
320 | GNUNET_break (0); | 292 | GNUNET_break (0); |
321 | return; | 293 | return; |
322 | } | 294 | } |
323 | gtk_toggle_button_set_active (button, | 295 | gtk_toggle_button_set_active (button, hnc ? TRUE : FALSE); |
324 | hnc ? TRUE : FALSE); | ||
325 | } | 296 | } |
326 | 297 | ||
327 | /* end of gnunet-setup-transport.c */ | 298 | /* end of gnunet-setup-transport.c */ |
diff --git a/src/setup/gnunet-setup.c b/src/setup/gnunet-setup.c index 6844a076..dc8b6bcb 100644 --- a/src/setup/gnunet-setup.c +++ b/src/setup/gnunet-setup.c | |||
@@ -77,9 +77,8 @@ GNUNET_SETUP_get_object (const char *name) | |||
77 | 77 | ||
78 | 78 | ||
79 | static gboolean | 79 | static gboolean |
80 | help_click_callback (GtkWidget *widget, | 80 | help_click_callback (GtkWidget * widget, GdkEventButton * event, |
81 | GdkEventButton *event, | 81 | gpointer user_data) |
82 | gpointer user_data) | ||
83 | { | 82 | { |
84 | const struct GNUNET_SETUP_OptionSpecification *os = user_data; | 83 | const struct GNUNET_SETUP_OptionSpecification *os = user_data; |
85 | GtkLinkButton *help; | 84 | GtkLinkButton *help; |
@@ -87,10 +86,8 @@ help_click_callback (GtkWidget *widget, | |||
87 | if (event->type != GDK_BUTTON_PRESS) | 86 | if (event->type != GDK_BUTTON_PRESS) |
88 | return FALSE; | 87 | return FALSE; |
89 | help = GTK_LINK_BUTTON (GNUNET_SETUP_get_object ("GNUNET_setup_help_text")); | 88 | help = GTK_LINK_BUTTON (GNUNET_SETUP_get_object ("GNUNET_setup_help_text")); |
90 | gtk_link_button_set_uri (help, | 89 | gtk_link_button_set_uri (help, os->help_url); |
91 | os->help_url); | 90 | gtk_button_set_label (GTK_BUTTON (help), os->help_text); |
92 | gtk_button_set_label (GTK_BUTTON (help), | ||
93 | os->help_text); | ||
94 | return FALSE; | 91 | return FALSE; |
95 | } | 92 | } |
96 | 93 | ||
@@ -104,7 +101,7 @@ help_click_callback (GtkWidget *widget, | |||
104 | */ | 101 | */ |
105 | static void | 102 | static void |
106 | update_visibility (const struct GNUNET_SETUP_OptionSpecification *os, | 103 | update_visibility (const struct GNUNET_SETUP_OptionSpecification *os, |
107 | const char *value) | 104 | const char *value) |
108 | { | 105 | { |
109 | unsigned int i; | 106 | unsigned int i; |
110 | const struct GNUNET_SETUP_VisibilitySpecification *vs; | 107 | const struct GNUNET_SETUP_VisibilitySpecification *vs; |
@@ -115,51 +112,49 @@ update_visibility (const struct GNUNET_SETUP_OptionSpecification *os, | |||
115 | return; | 112 | return; |
116 | i = 0; | 113 | i = 0; |
117 | while (os->visibility[i].widget_name != NULL) | 114 | while (os->visibility[i].widget_name != NULL) |
115 | { | ||
116 | vs = &os->visibility[i]; | ||
117 | widget = GTK_WIDGET (GNUNET_SETUP_get_object (vs->widget_name)); | ||
118 | if (widget == NULL) | ||
118 | { | 119 | { |
119 | vs = &os->visibility[i]; | 120 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Widget `%s' not found\n"), |
120 | widget = GTK_WIDGET (GNUNET_SETUP_get_object (vs->widget_name)); | 121 | vs->widget_name); |
121 | if (widget == NULL) | 122 | } |
122 | { | 123 | if (NULL != vs->show_value) |
123 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 124 | { |
124 | _("Widget `%s' not found\n"), | 125 | if (0 != |
125 | vs->widget_name); | 126 | regcomp (&r, vs->show_value, REG_EXTENDED | REG_ICASE | REG_NOSUB)) |
126 | } | 127 | { |
127 | if (NULL != vs->show_value) | 128 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
128 | { | 129 | _("Invalid regular expression `%s'\n"), vs->show_value); |
129 | if (0 != regcomp (&r, vs->show_value, REG_EXTENDED | REG_ICASE | REG_NOSUB)) | 130 | i++; |
130 | { | 131 | continue; |
131 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 132 | } |
132 | _("Invalid regular expression `%s'\n"), | 133 | if (0 == regexec (&r, value, 0, NULL, 0)) |
133 | vs->show_value); | 134 | gtk_widget_show (widget); |
134 | i++; | 135 | else |
135 | continue; | 136 | gtk_widget_hide (widget); |
136 | } | 137 | regfree (&r); |
137 | if (0 == regexec (&r, value, 0, NULL, 0)) | 138 | } |
138 | gtk_widget_show (widget); | 139 | if (NULL != vs->hide_value) |
139 | else | 140 | { |
140 | gtk_widget_hide (widget); | 141 | if (0 != regcomp (&r, vs->hide_value, REG_ICASE | REG_NOSUB)) |
141 | regfree (&r); | 142 | { |
142 | } | 143 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
143 | if (NULL != vs->hide_value) | 144 | _("Invalid regular expression `%s'\n"), vs->show_value); |
144 | { | 145 | i++; |
145 | if (0 != regcomp (&r, vs->hide_value, REG_ICASE | REG_NOSUB)) | 146 | continue; |
146 | { | 147 | } |
147 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 148 | if (0 == regexec (&r, value, 0, NULL, 0)) |
148 | _("Invalid regular expression `%s'\n"), | 149 | gtk_widget_hide (widget); |
149 | vs->show_value); | 150 | else |
150 | i++; | 151 | gtk_widget_show (widget); |
151 | continue; | 152 | regfree (&r); |
152 | } | ||
153 | if (0 == regexec (&r, value, 0, NULL, 0)) | ||
154 | gtk_widget_hide (widget); | ||
155 | else | ||
156 | gtk_widget_show (widget); | ||
157 | regfree (&r); | ||
158 | } | ||
159 | i++; | ||
160 | } | 153 | } |
154 | i++; | ||
155 | } | ||
161 | } | 156 | } |
162 | 157 | ||
163 | 158 | ||
164 | /** | 159 | /** |
165 | * Function called whenever a widget changes its state. | 160 | * Function called whenever a widget changes its state. |
@@ -173,24 +168,18 @@ widget_state_change_callback (const struct GNUNET_SETUP_OptionSpecification *os) | |||
173 | widget = GNUNET_SETUP_get_object (os->widget_name); | 168 | widget = GNUNET_SETUP_get_object (os->widget_name); |
174 | GNUNET_assert (NULL != os->save_function); | 169 | GNUNET_assert (NULL != os->save_function); |
175 | if (GNUNET_OK != | 170 | if (GNUNET_OK != |
176 | os->save_function (os->load_save_cls, | 171 | os->save_function (os->load_save_cls, os->section, os->option, widget, |
177 | os->section, | 172 | cfg)) |
178 | os->option, | 173 | { |
179 | widget, | 174 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
180 | cfg)) | 175 | _("Failed to obtain option value from widget `%s'\n"), |
181 | { | 176 | os->widget_name); |
182 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 177 | return; |
183 | _("Failed to obtain option value from widget `%s'\n"), | 178 | } |
184 | os->widget_name); | 179 | if ((os->section != NULL) && (os->option != NULL)) |
185 | return; | ||
186 | } | ||
187 | if ( (os->section != NULL) && | ||
188 | (os->option != NULL) ) | ||
189 | GNUNET_assert (GNUNET_OK == | 180 | GNUNET_assert (GNUNET_OK == |
190 | GNUNET_CONFIGURATION_get_value_string (cfg, | 181 | GNUNET_CONFIGURATION_get_value_string (cfg, os->section, |
191 | os->section, | 182 | os->option, &value)); |
192 | os->option, | ||
193 | &value)); | ||
194 | else | 183 | else |
195 | value = NULL; | 184 | value = NULL; |
196 | update_visibility (os, value); | 185 | update_visibility (os, value); |
@@ -211,85 +200,71 @@ load_options () | |||
211 | 200 | ||
212 | i = 0; | 201 | i = 0; |
213 | while (option_specifications[i].widget_name != NULL) | 202 | while (option_specifications[i].widget_name != NULL) |
203 | { | ||
204 | os = &option_specifications[i]; | ||
205 | widget = GNUNET_SETUP_get_object (os->widget_name); | ||
206 | if (NULL == widget) | ||
214 | { | 207 | { |
215 | os = &option_specifications[i]; | 208 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Widget `%s' not found\n"), |
216 | widget = GNUNET_SETUP_get_object (os->widget_name); | 209 | os->widget_name); |
217 | if (NULL == widget) | ||
218 | { | ||
219 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
220 | _("Widget `%s' not found\n"), | ||
221 | os->widget_name); | ||
222 | i++; | ||
223 | continue; | ||
224 | } | ||
225 | if (os->load_function != NULL) | ||
226 | { | ||
227 | if ( (NULL == os->section) || | ||
228 | (NULL == os->option) ) | ||
229 | { | ||
230 | if (GNUNET_OK != | ||
231 | os->load_function (os->load_save_cls, | ||
232 | NULL, NULL, NULL, | ||
233 | widget, | ||
234 | cfg)) | ||
235 | { | ||
236 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
237 | _("Failed to initialize widget `%s'\n"), | ||
238 | os->widget_name); | ||
239 | } | ||
240 | } | ||
241 | else | ||
242 | { | ||
243 | if (GNUNET_OK != | ||
244 | GNUNET_CONFIGURATION_get_value_string (cfg, | ||
245 | os->section, | ||
246 | os->option, | ||
247 | &value)) | ||
248 | { | ||
249 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
250 | _("No default value known for option `%s' in section `%s'\n"), | ||
251 | os->option, | ||
252 | os->section); | ||
253 | } | ||
254 | else | ||
255 | { | ||
256 | if (GNUNET_OK != | ||
257 | os->load_function (os->load_save_cls, | ||
258 | os->section, os->option, | ||
259 | value, | ||
260 | widget, | ||
261 | cfg)) | ||
262 | { | ||
263 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
264 | _("Failed to initialize widget `%s' with value `%s'\n"), | ||
265 | os->widget_name, | ||
266 | value); | ||
267 | } | ||
268 | else | ||
269 | { | ||
270 | update_visibility (os, value); | ||
271 | } | ||
272 | GNUNET_free (value); | ||
273 | } | ||
274 | } | ||
275 | } | ||
276 | if (os->help_text != NULL) | ||
277 | { | ||
278 | g_signal_connect (widget, | ||
279 | "button-press-event", | ||
280 | G_CALLBACK (&help_click_callback), | ||
281 | (void*) os); | ||
282 | } | ||
283 | if (os->change_signal != NULL) | ||
284 | { | ||
285 | GNUNET_assert (NULL != os->save_function); | ||
286 | g_signal_connect_swapped (widget, | ||
287 | os->change_signal, | ||
288 | G_CALLBACK (&widget_state_change_callback), | ||
289 | (void*) os); | ||
290 | } | ||
291 | i++; | 210 | i++; |
211 | continue; | ||
292 | } | 212 | } |
213 | if (os->load_function != NULL) | ||
214 | { | ||
215 | if ((NULL == os->section) || (NULL == os->option)) | ||
216 | { | ||
217 | if (GNUNET_OK != | ||
218 | os->load_function (os->load_save_cls, NULL, NULL, NULL, widget, | ||
219 | cfg)) | ||
220 | { | ||
221 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
222 | _("Failed to initialize widget `%s'\n"), os->widget_name); | ||
223 | } | ||
224 | } | ||
225 | else | ||
226 | { | ||
227 | if (GNUNET_OK != | ||
228 | GNUNET_CONFIGURATION_get_value_string (cfg, os->section, os->option, | ||
229 | &value)) | ||
230 | { | ||
231 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
232 | _ | ||
233 | ("No default value known for option `%s' in section `%s'\n"), | ||
234 | os->option, os->section); | ||
235 | } | ||
236 | else | ||
237 | { | ||
238 | if (GNUNET_OK != | ||
239 | os->load_function (os->load_save_cls, os->section, os->option, | ||
240 | value, widget, cfg)) | ||
241 | { | ||
242 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
243 | _("Failed to initialize widget `%s' with value `%s'\n"), | ||
244 | os->widget_name, value); | ||
245 | } | ||
246 | else | ||
247 | { | ||
248 | update_visibility (os, value); | ||
249 | } | ||
250 | GNUNET_free (value); | ||
251 | } | ||
252 | } | ||
253 | } | ||
254 | if (os->help_text != NULL) | ||
255 | { | ||
256 | g_signal_connect (widget, "button-press-event", | ||
257 | G_CALLBACK (&help_click_callback), (void *) os); | ||
258 | } | ||
259 | if (os->change_signal != NULL) | ||
260 | { | ||
261 | GNUNET_assert (NULL != os->save_function); | ||
262 | g_signal_connect_swapped (widget, os->change_signal, | ||
263 | G_CALLBACK (&widget_state_change_callback), | ||
264 | (void *) os); | ||
265 | } | ||
266 | i++; | ||
267 | } | ||
293 | 268 | ||
294 | } | 269 | } |
295 | 270 | ||
@@ -297,29 +272,25 @@ load_options () | |||
297 | /** | 272 | /** |
298 | * Callback invoked if the application is supposed to exit. | 273 | * Callback invoked if the application is supposed to exit. |
299 | */ | 274 | */ |
300 | void | 275 | void |
301 | GNUNET_SETUP_quit_cb (GtkObject *object, | 276 | GNUNET_SETUP_quit_cb (GtkObject * object, gpointer user_data) |
302 | gpointer user_data) | ||
303 | { | 277 | { |
304 | struct GNUNET_CONFIGURATION_Handle *cfgDefault; | 278 | struct GNUNET_CONFIGURATION_Handle *cfgDefault; |
305 | 279 | ||
306 | GNUNET_GTK_main_loop_quit (ml); | 280 | GNUNET_GTK_main_loop_quit (ml); |
307 | cfgDefault = GNUNET_CONFIGURATION_create (); | 281 | cfgDefault = GNUNET_CONFIGURATION_create (); |
308 | (void) GNUNET_CONFIGURATION_load (cfgDefault, NULL); /* load defaults only */ | 282 | (void) GNUNET_CONFIGURATION_load (cfgDefault, NULL); /* load defaults only */ |
309 | if (GNUNET_OK != | 283 | if (GNUNET_OK != GNUNET_CONFIGURATION_write_diffs (cfgDefault, cfg, cfgName)) |
310 | GNUNET_CONFIGURATION_write_diffs (cfgDefault, | 284 | gret = 1; |
311 | cfg, | ||
312 | cfgName)) | ||
313 | gret = 1; | ||
314 | GNUNET_CONFIGURATION_destroy (cfgDefault); | 285 | GNUNET_CONFIGURATION_destroy (cfgDefault); |
315 | GNUNET_CONFIGURATION_destroy (cfg); | 286 | GNUNET_CONFIGURATION_destroy (cfg); |
316 | cfg = NULL; | 287 | cfg = NULL; |
317 | if (NULL != resolver) | 288 | if (NULL != resolver) |
318 | { | 289 | { |
319 | GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM)); | 290 | GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM)); |
320 | GNUNET_OS_process_close (resolver); | 291 | GNUNET_OS_process_close (resolver); |
321 | resolver = NULL; | 292 | resolver = NULL; |
322 | } | 293 | } |
323 | } | 294 | } |
324 | 295 | ||
325 | 296 | ||
@@ -330,18 +301,17 @@ GNUNET_SETUP_quit_cb (GtkObject *object, | |||
330 | * @param tc scheduler context | 301 | * @param tc scheduler context |
331 | */ | 302 | */ |
332 | static void | 303 | static void |
333 | run (void *cls, | 304 | run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
334 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
335 | { | 305 | { |
336 | ml = cls; | 306 | ml = cls; |
337 | GtkWidget *main_window; | 307 | GtkWidget *main_window; |
338 | 308 | ||
339 | cfg = GNUNET_CONFIGURATION_create (); | 309 | cfg = GNUNET_CONFIGURATION_create (); |
340 | (void) GNUNET_CONFIGURATION_load (cfg, cfgName); | 310 | (void) GNUNET_CONFIGURATION_load (cfg, cfgName); |
341 | main_window = GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_dialog")); | 311 | main_window = GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_dialog")); |
342 | resolver = GNUNET_OS_start_process (NULL, NULL, | 312 | resolver = |
343 | "gnunet-service-resolver", | 313 | GNUNET_OS_start_process (NULL, NULL, "gnunet-service-resolver", |
344 | "gnunet-service-resolver", NULL); | 314 | "gnunet-service-resolver", NULL); |
345 | load_options (); | 315 | load_options (); |
346 | gtk_widget_show (main_window); | 316 | gtk_widget_show (main_window); |
347 | gtk_window_present (GTK_WINDOW (main_window)); | 317 | gtk_window_present (GTK_WINDOW (main_window)); |
@@ -356,8 +326,7 @@ run (void *cls, | |||
356 | * @return 0 on success | 326 | * @return 0 on success |
357 | */ | 327 | */ |
358 | int | 328 | int |
359 | main (int argc, | 329 | main (int argc, char *const *argv) |
360 | char *const *argv) | ||
361 | { | 330 | { |
362 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 331 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
363 | GNUNET_GETOPT_OPTION_CFG_FILE (&cfgName), | 332 | GNUNET_GETOPT_OPTION_CFG_FILE (&cfgName), |
@@ -372,16 +341,12 @@ main (int argc, | |||
372 | loglev = GNUNET_strdup ("WARNING"); | 341 | loglev = GNUNET_strdup ("WARNING"); |
373 | 342 | ||
374 | if (GNUNET_OK == | 343 | if (GNUNET_OK == |
375 | GNUNET_GTK_main_loop_start ("gnunet-setup", | 344 | GNUNET_GTK_main_loop_start ("gnunet-setup", "guunet-setup", argc, argv, |
376 | "guunet-setup", | 345 | options, "gnunet_setup_gtk_main_window.glade", |
377 | argc, | 346 | &run)) |
378 | argv, | ||
379 | options, | ||
380 | "gnunet_setup_gtk_main_window.glade", | ||
381 | &run)) | ||
382 | ret = gret; | 347 | ret = gret; |
383 | else | 348 | else |
384 | ret = 1; | 349 | ret = 1; |
385 | GNUNET_free (cfgName); | 350 | GNUNET_free (cfgName); |
386 | GNUNET_free (loglev); | 351 | GNUNET_free (loglev); |
387 | return ret; | 352 | return ret; |