3 my $pluginName = "$pluginName";
5 my $password = "kyrios";
6 my $loggedAccount = "mcepl\@porky.stuttgart.redhat.com";
8 #+#define XMLNS_BOOKMARK "storage:bookmarks" /* XEP-0048 */
9 #+#define XMLNS_PRIVATE "jabber:iq:private" /* XEP-0049 */
11 $botname = "USERSERV";
13 perl_api_version
=> 2,
14 name
=> "Perl: Open Chats from XMPP Bookmarks",
16 summary
=> "Opens all chats on XMPP server according to bookmarks stored there.",
17 description
=> "Opens all chats on XMPP server according to bookmarks stored there.",
18 author
=> "Matěj Cepl <mcepl\@redhat.com>",
19 url
=> "http://matej.ceplovi.cz",
20 load
=> "plugin_load",
21 unload
=> "plugin_unload",
24 #(00:25:06) charding: Can anyone tell me what's the difference
25 #between the 'signing-on' and 'account-connecting' signals? Is
26 #signing-on for when pidgin is starting up? and account-connecting
27 #is when pidgin is already running and you enable and that
28 #particular acct is connecting?
29 #(00:29:18) elb: charding: as best I can tell, the only difference is that
30 #signing-on is called for both registration and regular
31 #connection, and account-connecting is called only for the later
32 #(00:29:22) elb: latter
33 #(00:29:28) elb: they're emitted one right after another in
34 #purple_connection_new
38 Purple
::Debug
::info
("$pluginName", "start paramterers=@_\n");
41 $conn = Purple
::Connections
::get_handle
();
42 Purple
::Signal
::connect($conn, "signed-on", $plugin,
44 Purple
::Debug
::info
("$pluginName", "Login to $botname plugin loaded\n");
48 Purple
::Debug
::info
("$pluginName", "Login to $botname plugin unloaded\n");
53 my $account = $conn->get_account();
54 my $username = $account->get_username();
55 Purple
::Debug
::misc
("$pluginName", "signed-on (" . $username . ")\n");
58 if ($username eq $loggedAccount) {
59 my $ret = Purple
::Prpl
::send_raw
($conn,
60 ":$login PRIVMSG $botname :login $login $password\n");
61 Purple
::Debug
::misc
("$pluginName", "ret=$ret\n");
64 # Purple::timeout_add();
67 my @allChats = Purple
::get_ims
();
68 my @allTitles = map($_->get_title(),@allChats);
69 Purple
::Debug
::misc
("$pluginName", "\@allTitles=@allTitles\n");
70 Purple
::Debug
::misc
("$pluginName", "Purple::get_ims() = " . Purple
::get_ims
());
71 my @userservChats = grep ((
72 $_->get_title() =~ /^\W*$botname\W*$/
73 ), Purple
::get_ims
());
74 $userservChats[1]->destroy();
77 #+static xt_status jabber_parse_bookmark( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )
79 #+ struct xt_node *query, *c, *c2;
81 #+ if( !( query = xt_find_node( node->children, "query" ) ) )
83 #+ imcb_log( ic, "WARNING: Received NULL roster packet" );
87 #+ imcb_log( ic, "Bookmark fetched" );
88 #+ c = query->children;
89 #+ if( !( c = xt_find_node( c, "storage" )))
94 #+ while( ( c = xt_find_node( c, "conference" ) ) )
96 #+ char *autojoin = xt_find_attr( c, "autojoin" );
97 #+ char *name = xt_find_attr( c, "name" );
98 #+ char *jid = xt_find_attr( c, "jid" );
99 #+ char *nick, *password;
102 #+ if( (c2 = xt_find_node( c->children, "nick" )))
104 #+ if( (c2 = xt_find_node( c->children, "password" )))
105 #+ password = c2->text;
107 #+ if( jid && autojoin &&
108 #+ ( g_strcasecmp( autojoin, "true" ) == 0 ||
109 #+ g_strcasecmp( autojoin, "1" ) == 0 ))
111 #+ imcb_log( ic, "Autojoin on %s as %s", jid, nick );
112 #+ jabber_chat_join(ic, jid, nick, password);
125 #+int jabber_get_bookmark( struct im_connection *ic )
127 #+ struct xt_node *node;
130 #+ imcb_log( ic, "Fetching bookmark list" );
132 #+ node = xt_new_node( "storage", NULL, NULL );
133 #+ xt_add_attr( node, "xmlns", XMLNS_BOOKMARK );
135 #+ node = xt_new_node( "query", NULL, node );
136 #+ xt_add_attr( node, "xmlns", XMLNS_PRIVATE );
137 #+ node = jabber_make_packet( "iq", "get", NULL, node );
139 #+ jabber_cache_add( ic, node, jabber_parse_bookmark );
140 #+ st = jabber_write_packet( ic, node );
145 # Probably better get_bookmarkS (instead of get_bookmark), because
146 # it gets all bookmarks stored on the server.
147 # @param im_connection pointer Connection
151 my $im_connection = shift;
155 Purple
::Debug
::info
("$pluginName", "Fetching bookmark list\n");
159 # whenever we get connected
160 # * is this Jabber server?
161 # * if yes, does it support Private Storage?
162 # * if yes, get bookmarks
163 # * for bookmark in bookmarks:
164 # connectMUC(bookmark)# if isAutostart(bookmark) and notOpen(bookmark):