| ... |
... |
@@ -51,6 +51,7 @@ class StartChatDialog(Gtk.ApplicationWindow): |
|
51
|
51
|
self.set_default_size(-1, 400)
|
|
52
|
52
|
self.ready_to_destroy = False
|
|
53
|
53
|
self._parameter_form = None
|
|
|
54
|
+ self._keywords = []
|
|
54
|
55
|
self._destroyed = False
|
|
55
|
56
|
self._search_stopped = False
|
|
56
|
57
|
|
| ... |
... |
@@ -470,6 +471,12 @@ class StartChatDialog(Gtk.ApplicationWindow): |
|
470
|
471
|
text = self._ui.search_entry.get_text().strip()
|
|
471
|
472
|
self._global_search_listbox.start_search()
|
|
472
|
473
|
|
|
|
474
|
+ if app.config.get('muclumbus_api_pref') == 'http':
|
|
|
475
|
+ self._start_http_search(con, text)
|
|
|
476
|
+ else:
|
|
|
477
|
+ self._start_iq_search(con, text)
|
|
|
478
|
+
|
|
|
479
|
+ def _start_iq_search(self, con, text):
|
|
473
|
480
|
if self._parameter_form is None:
|
|
474
|
481
|
con.get_module('Muclumbus').request_parameters(
|
|
475
|
482
|
app.config.get('muclumbus_api_jid'),
|
| ... |
... |
@@ -482,7 +489,15 @@ class StartChatDialog(Gtk.ApplicationWindow): |
|
482
|
489
|
app.config.get('muclumbus_api_jid'),
|
|
483
|
490
|
self._parameter_form,
|
|
484
|
491
|
callback=self._on_search_result,
|
|
485
|
|
- user_data=con)
|
|
|
492
|
+ user_data=(con, False))
|
|
|
493
|
+
|
|
|
494
|
+ def _start_http_search(self, con, text):
|
|
|
495
|
+ self._keywords = text.split(' ')
|
|
|
496
|
+ con.get_module('Muclumbus').set_http_search(
|
|
|
497
|
+ app.config.get('muclumbus_api_http_uri'),
|
|
|
498
|
+ self._keywords,
|
|
|
499
|
+ callback=self._on_search_result,
|
|
|
500
|
+ user_data=(con, True))
|
|
486
|
501
|
|
|
487
|
502
|
@ensure_not_destroyed
|
|
488
|
503
|
def _parameters_received(self, result, user_data):
|
| ... |
... |
@@ -494,16 +509,10 @@ class StartChatDialog(Gtk.ApplicationWindow): |
|
494
|
509
|
con, text = user_data
|
|
495
|
510
|
self._parameter_form = result
|
|
496
|
511
|
self._parameter_form.type_ = 'submit'
|
|
497
|
|
- self._parameter_form.vars['q'].value = text
|
|
498
|
|
-
|
|
499
|
|
- con.get_module('Muclumbus').set_search(
|
|
500
|
|
- app.config.get('muclumbus_api_jid'),
|
|
501
|
|
- self._parameter_form,
|
|
502
|
|
- callback=self._on_search_result,
|
|
503
|
|
- user_data=con)
|
|
|
512
|
+ self._start_iq_search(con, text)
|
|
504
|
513
|
|
|
505
|
514
|
@ensure_not_destroyed
|
|
506
|
|
- def _on_search_result(self, result, con):
|
|
|
515
|
+ def _on_search_result(self, result, user_data):
|
|
507
|
516
|
if self._search_stopped:
|
|
508
|
517
|
return
|
|
509
|
518
|
|
| ... |
... |
@@ -519,6 +528,13 @@ class StartChatDialog(Gtk.ApplicationWindow): |
|
519
|
528
|
self._global_search_listbox.end_search()
|
|
520
|
529
|
return
|
|
521
|
530
|
|
|
|
531
|
+ con, http = user_data
|
|
|
532
|
+ if http:
|
|
|
533
|
+ self._continue_http_search(result, con)
|
|
|
534
|
+ else:
|
|
|
535
|
+ self._continue_iq_search(result, con)
|
|
|
536
|
+
|
|
|
537
|
+ def _continue_iq_search(self, result, con):
|
|
522
|
538
|
con.get_module('Muclumbus').set_search(
|
|
523
|
539
|
app.config.get('muclumbus_api_jid'),
|
|
524
|
540
|
self._parameter_form,
|
| ... |
... |
@@ -527,6 +543,14 @@ class StartChatDialog(Gtk.ApplicationWindow): |
|
527
|
543
|
callback=self._on_search_result,
|
|
528
|
544
|
user_data=con)
|
|
529
|
545
|
|
|
|
546
|
+ def _continue_http_search(self, result, con):
|
|
|
547
|
+ con.get_module('Muclumbus').set_http_search(
|
|
|
548
|
+ app.config.get('muclumbus_api_http_uri'),
|
|
|
549
|
+ self._keywords,
|
|
|
550
|
+ after=result.last,
|
|
|
551
|
+ callback=self._on_search_result,
|
|
|
552
|
+ user_data=con)
|
|
|
553
|
+
|
|
530
|
554
|
def _destroy(self, *args):
|
|
531
|
555
|
self._destroyed = True
|
|
532
|
556
|
|