![]() |
Home page |
Mailing list |
Docs
Asterisk developer's documentation :: Codename Pineapple
res_jabber.c File Reference
Definition in file res_jabber.c.
#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <iksemel.h>
#include "asterisk/channel.h"
#include "asterisk/jabber.h"
#include "asterisk/file.h"
#include "asterisk/config.h"
#include "asterisk/callerid.h"
#include "asterisk/lock.h"
#include "asterisk/logger.h"
#include "asterisk/options.h"
#include "asterisk/cli.h"
#include "asterisk/app.h"
#include "asterisk/pbx.h"
#include "asterisk/md5.h"
#include "asterisk/acl.h"
#include "asterisk/utils.h"
#include "asterisk/module.h"
#include "asterisk/astobj.h"
#include "asterisk/astdb.h"
#include "asterisk/manager.h"
Include dependency graph for res_jabber.c:

Go to the source code of this file.
Defines | |
| #define | JABBER_CONFIG "jabber.conf" |
Functions | |
| static int | aji_act_hook (void *data, int type, iks *node) |
| The action hook parses the inbound packets, constantly running. | |
| static void | aji_buddy_destroy (struct aji_buddy *obj) |
| Deletes the aji_buddy data structure. | |
| static int | aji_client_connect (void *data, ikspak *pak) |
| connects as a client to jabber server. | |
| static void | aji_client_destroy (struct aji_client *obj) |
| Deletes the aji_client data structure. | |
| static int | aji_client_info_handler (void *data, ikspak *pak) |
| static int | aji_client_initialize (struct aji_client *client) |
| prepares client for connect. | |
| static int | aji_component_initialize (struct aji_client *client) |
| prepares component for connect. | |
| static int | aji_create_buddy (char *label, struct aji_client *client) |
| creates transport. creates buddy. | |
| static int | aji_create_client (char *label, struct ast_variable *var, int debug) |
| creates aji_client structure. | |
| static int | aji_dinfo_handler (void *data, ikspak *pak) |
| static int | aji_ditems_handler (void *data, ikspak *pak) |
| static int | aji_do_debug (int fd, int argc, char *argv[]) |
| turnon console debugging. | |
| static int | aji_do_reload (int fd, int argc, char *argv[]) |
| reload jabber module. | |
| static int | aji_filter_roster (void *data, ikspak *pak) |
| filters the roster packet we get back from server. | |
| static struct aji_resource * | aji_find_resource (struct aji_buddy *buddy, char *name) |
| static struct aji_version * | aji_find_version (char *node, char *version, ikspak *pak) |
| static int | aji_get_roster (struct aji_client *client) |
| static void | aji_handle_iq (struct aji_client *client, iks *node) |
| Handles <iq> tags. | |
| static void | aji_handle_message (struct aji_client *client, ikspak *pak) |
| Handles presence packets. | |
| static void | aji_handle_presence (struct aji_client *client, ikspak *pak) |
| static void | aji_handle_subscribe (struct aji_client *client, ikspak *pak) |
| handles subscription requests. | |
| static int | aji_highest_bit (int number) |
| Detects the highest bit in a number. | |
| static int | aji_load_config (void) |
| load config file. | |
| static void | aji_log_hook (void *data, const char *xmpp, size_t size, int is_incoming) |
| the debug loop. | |
| static int | aji_no_debug (int fd, int argc, char *argv[]) |
| turnoff console debugging. | |
| static void | aji_pruneregister (struct aji_client *client) |
| attempts to register to a transport. attempts to register to a transport step 2. goes through roster and prunes users not needed in list, or adds them accordingly. | |
| static int | aji_reconnect (struct aji_client *client) |
| static void * | aji_recv_loop (void *data) |
| receive message loop. | |
| static int | aji_register_approve_handler (void *data, ikspak *pak) |
| static int | aji_register_query_handler (void *data, ikspak *pak) |
| static int | aji_reload (void) |
| static int | aji_send_exec (struct ast_channel *chan, void *data) |
| Dial plan function to send a message. | |
| static void | aji_set_presence (struct aji_client *client, char *to, char *from, int level, char *desc) |
| set presence of client. | |
| static int | aji_show_clients (int fd, int argc, char *argv[]) |
| show client status. | |
| static int | aji_status_exec (struct ast_channel *chan, void *data) |
| Dial plan function status(). puts the status of watched user into a channel variable. | |
| static int | aji_test (int fd, int argc, char *argv[]) |
| send test message for debugging. | |
| int | ast_aji_create_chat (struct aji_client *client, char *room, char *server, char *topic) |
| create a chatroom. | |
| int | ast_aji_disconnect (struct aji_client *client) |
| disconnect from jabber server. | |
| aji_client * | ast_aji_get_client (const char *name) |
| grab a aji_client structure by label name. | |
| aji_client_container * | ast_aji_get_clients (void) |
| void | ast_aji_increment_mid (char *mid) |
| increments the mid field for messages and other events. | |
| int | ast_aji_invite_chat (struct aji_client *client, char *user, char *room, char *message) |
| invite to a chatroom. | |
| int | ast_aji_join_chat (struct aji_client *client, char *room) |
| join a chatroom. | |
| int | ast_aji_send (struct aji_client *client, const char *address, const char *message) |
| sends messages. | |
| AST_MODULE_INFO (ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS,"AJI - Asterisk Jabber Interface",.load=load_module,.unload=unload_module,.reload=reload,) | |
| static int | gtalk_yuck (iks *node) |
| static iks * | jabber_make_auth (iksid *id, const char *pass, const char *sid) |
| static int | load_module (void) |
| static int | manager_jabber_send (struct mansession *s, const struct message *m) |
| Send a Jabber Message via call from the Manager. | |
| static int | reload (void) |
| static int | unload_module (void) |
Variables | |
| static struct ast_cli_entry | aji_cli [] |
| static char * | ajisend_descrip |
| static char * | ajisend_synopsis = "JabberSend(jabber,screenname,message)" |
| static char * | ajistatus_descrip |
| static char * | ajistatus_synopsis = "JabberStatus(Jabber,ScreenName,Variable)" |
| static char * | app_ajisend = "JabberSend" |
| static char * | app_ajistatus = "JabberStatus" |
| aji_capabilities * | capabilities |
| aji_client_container | clients |
| static const char | debug_usage [] |
| static struct ast_flags | globalflags = { AJI_AUTOPRUNE | AJI_AUTOREGISTER } |
| Global flags, initialized to default values. | |
| static char | mandescr_jabber_send [] |
| static const char | no_debug_usage [] |
| static const char | reload_usage [] |
| static const char | test_usage [] |
|
|
Definition at line 55 of file res_jabber.c. Referenced by aji_load_config(). |
|
||||||||||||||||
|
The action hook parses the inbound packets, constantly running.
Definition at line 460 of file res_jabber.c. References aji_client_connect(), aji_client_destroy(), AJI_CONNECTED, AJI_CONNECTING, AJI_DISCONNECTED, aji_handle_iq(), aji_handle_message(), aji_handle_presence(), aji_handle_subscribe(), aji_highest_bit(), asprintf, ast_aji_increment_mid(), ast_base64encode(), ast_log(), ast_malloc, ast_sha1_hash(), ASTOBJ_REF, ASTOBJ_UNREF, aji_client::authorized, base64, aji_client::component, aji_client::f, free, jabber_make_auth(), aji_client::jid, len, LOG_DEBUG, LOG_ERROR, LOG_WARNING, aji_client::mid, option_debug, aji_client::p, aji_client::password, s, secret, aji_client::state, aji_client::usesasl, and aji_client::usetls. Referenced by aji_create_client(). 00461 { 00462 struct aji_client *client = ASTOBJ_REF((struct aji_client *) data); 00463 ikspak *pak = NULL; 00464 iks *auth = NULL; 00465 00466 if(!node) { 00467 ast_log(LOG_ERROR, "aji_act_hook was called with out a packet\n"); /* most likely cause type is IKS_NODE_ERROR lost connection */ 00468 ASTOBJ_UNREF(client, aji_client_destroy); 00469 return IKS_HOOK; 00470 } 00471 00472 pak = iks_packet(node); 00473 00474 if (!client->component) { /*client */ 00475 switch (type) { 00476 case IKS_NODE_START: 00477 if (client->usetls && !iks_is_secure(client->p)) { 00478 if (iks_has_tls()) 00479 iks_start_tls(client->p); 00480 else 00481 ast_log(LOG_ERROR, "gnuTLS not installed.\n"); 00482 break; 00483 } 00484 if (!client->usesasl) { 00485 iks_filter_add_rule(client->f, aji_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, client->mid, IKS_RULE_DONE); 00486 auth = jabber_make_auth(client->jid, client->password, iks_find_attrib(node, "id")); 00487 if (auth) { 00488 iks_insert_attrib(auth, "id", client->mid); 00489 iks_insert_attrib(auth, "to", client->jid->server); 00490 ast_aji_increment_mid(client->mid); 00491 iks_send(client->p, auth); 00492 iks_delete(auth); 00493 } else 00494 ast_log(LOG_ERROR, "Out of memory.\n"); 00495 } 00496 break; 00497 00498 case IKS_NODE_NORMAL: 00499 { 00500 int features = 0; 00501 if (!strcmp("stream:features", iks_name(node))) { 00502 features = iks_stream_features(node); 00503 if (client->usesasl) { 00504 if (client->usetls && !iks_is_secure(client->p)) 00505 break; 00506 if (client->authorized) { 00507 if (features & IKS_STREAM_BIND) { 00508 iks_filter_add_rule (client->f, aji_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_DONE); 00509 auth = iks_make_resource_bind(client->jid); 00510 if (auth) { 00511 iks_insert_attrib(auth, "id", client->mid); 00512 ast_aji_increment_mid(client->mid); 00513 iks_send(client->p, auth); 00514 iks_delete(auth); 00515 } else { 00516 ast_log(LOG_ERROR, "Out of memory.\n"); 00517 break; 00518 } 00519 } 00520 if (features & IKS_STREAM_SESSION) { 00521 iks_filter_add_rule (client->f, aji_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "auth", IKS_RULE_DONE); 00522 auth = iks_make_session(); 00523 if (auth) { 00524 iks_insert_attrib(auth, "id", "auth"); 00525 ast_aji_increment_mid(client->mid); 00526 iks_send(client->p, auth); 00527 iks_delete(auth); 00528 } else { 00529 ast_log(LOG_ERROR, "Out of memory.\n"); 00530 } 00531 } 00532 } else { 00533 features = aji_highest_bit(features); 00534 if (features == IKS_STREAM_SASL_MD5) 00535 iks_start_sasl(client->p, IKS_SASL_DIGEST_MD5, client->jid->user, client->password); 00536 else { 00537 if (features == IKS_STREAM_SASL_PLAIN) { 00538 iks *x = NULL; 00539 x = iks_new("auth"); 00540 if (x) { 00541 int len = strlen(client->jid->user) + strlen(client->password) + 3; 00542 /* XXX Check return values XXX */ 00543 char *s = ast_malloc(80 + len); 00544 char *base64 = ast_malloc(80 + len * 2); 00545 00546 iks_insert_attrib(x, "xmlns", IKS_NS_XMPP_SASL); 00547 iks_insert_attrib(x, "mechanism", "PLAIN"); 00548 sprintf(s, "%c%s%c%s", 0, client->jid->user, 0, client->password); 00549 ast_base64encode(base64, (const unsigned char *) s, len, len * 2); 00550 iks_insert_cdata(x, base64, 0); 00551 iks_send(client->p, x); 00552 iks_delete(x); 00553 if (base64) 00554 free(base64); 00555 if (s) 00556 free(s); 00557 } else { 00558 ast_log(LOG_ERROR, "Out of memory.\n"); 00559 } 00560 } 00561 } 00562 } 00563 } 00564 } else if (!strcmp("failure", iks_name(node))) { 00565 ast_log(LOG_ERROR, "JABBER: encryption failure. possible bad password.\n"); 00566 } else if (!strcmp("success", iks_name(node))) { 00567 client->authorized = 1; 00568 iks_send_header(client->p, client->jid->server); 00569 } 00570 break; 00571 } 00572 case IKS_NODE_ERROR: 00573 ast_log(LOG_ERROR, "JABBER: Node Error\n"); 00574 ASTOBJ_UNREF(client, aji_client_destroy); 00575 return IKS_HOOK; 00576 break; 00577 case IKS_NODE_STOP: 00578 ast_log(LOG_WARNING, "JABBER: Disconnected\n"); 00579 ASTOBJ_UNREF(client, aji_client_destroy); 00580 return IKS_HOOK; 00581 break; 00582 } 00583 } else if (client->state != AJI_CONNECTED && client->component) { 00584 switch (type) { 00585 case IKS_NODE_START: 00586 if (client->state == AJI_DISCONNECTED) { 00587 char secret[160], shasum[320], *handshake; 00588 00589 sprintf(secret, "%s%s", pak->id, client->password); 00590 ast_sha1_hash(shasum, secret); 00591 handshake = NULL; 00592 asprintf(&handshake, "<handshake>%s</handshake>", shasum); 00593 if (handshake) { 00594 iks_send_raw(client->p, handshake); 00595 free(handshake); 00596 handshake = NULL; 00597 } 00598 client->state = AJI_CONNECTING; 00599 if(iks_recv(client->p,1) == 2) /*XXX proper result for iksemel library on iks_recv of <handshake/> XXX*/ 00600 client->state = AJI_CONNECTED; 00601 else 00602 ast_log(LOG_WARNING,"Jabber didn't seem to handshake, failed to authenicate.\n"); 00603 break; 00604 } 00605 break; 00606 00607 case IKS_NODE_NORMAL: 00608 break; 00609 00610 case IKS_NODE_ERROR: 00611 ast_log(LOG_ERROR, "JABBER: Node Error\n"); 00612 ASTOBJ_UNREF(client, aji_client_destroy); 00613 return IKS_HOOK; 00614 00615 case IKS_NODE_STOP: 00616 ast_log(LOG_WARNING, "JABBER: Disconnected\n"); 00617 ASTOBJ_UNREF(client, aji_client_destroy); 00618 return IKS_HOOK; 00619 } 00620 } 00621 00622 switch (pak->type) { 00623 case IKS_PAK_NONE: 00624 if (option_debug) 00625 ast_log(LOG_DEBUG, "JABBER: I Don't know what to do with you NONE\n"); 00626 break; 00627 case IKS_PAK_MESSAGE: 00628 aji_handle_message(client, pak); 00629 if (option_debug) 00630 ast_log(LOG_DEBUG, "JABBER: I Don't know what to do with you MESSAGE\n"); 00631 break; 00632 case IKS_PAK_PRESENCE: 00633 aji_handle_presence(client, pak); 00634 if (option_debug) 00635 ast_log(LOG_DEBUG, "JABBER: I Do know how to handle presence!!\n"); 00636 break; 00637 case IKS_PAK_S10N: 00638 aji_handle_subscribe(client, pak); 00639 if (option_debug) 00640 ast_log(LOG_DEBUG, "JABBER: I Dont know S10N subscribe!!\n"); 00641 break; 00642 case IKS_PAK_IQ: 00643 if (option_debug) 00644 ast_log(LOG_DEBUG, "JABBER: I Dont have an IQ!!!\n"); 00645 aji_handle_iq(client, node); 00646 break; 00647 default: 00648 if (option_debug) 00649 ast_log(LOG_DEBUG, "JABBER: I Dont know %i\n", pak->type); 00650 break; 00651 } 00652 00653 iks_filter_packet(client->f, pak); 00654 00655 if (node) 00656 iks_delete(node); 00657 00658 ASTOBJ_UNREF(client, aji_client_destroy); 00659 return IKS_OK; 00660 }
|
|
|
Deletes the aji_buddy data structure.
Definition at line 197 of file res_jabber.c. References aji_resource::description, free, aji_resource::next, and aji_buddy::resources. Referenced by aji_client_destroy(), aji_create_buddy(), and aji_handle_presence(). 00198 { 00199 struct aji_resource *tmp; 00200 00201 while ((tmp = obj->resources)) { 00202 obj->resources = obj->resources->next; 00203 free(tmp->description); 00204 free(tmp); 00205 } 00206 00207 free(obj); 00208 }
|
|
||||||||||||
|
connects as a client to jabber server.
Definition at line 1790 of file res_jabber.c. References aji_client_destroy(), AJI_CONNECTING, AJI_DISCONNECTED, aji_filter_roster(), aji_get_roster(), ast_log(), ASTOBJ_REF, ASTOBJ_UNREF, aji_client::component, aji_client::f, aji_client::jid, LOG_ERROR, aji_client::stack, and aji_client::state. Referenced by aji_act_hook(). 01791 { 01792 struct aji_client *client = ASTOBJ_REF((struct aji_client *) data); 01793 int res = 0; 01794 01795 if (client) { 01796 if (client->state == AJI_DISCONNECTED) { 01797 iks_filter_add_rule(client->f, aji_filter_roster, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "roster", IKS_RULE_DONE); 01798 client->state = AJI_CONNECTING; 01799 client->jid = (iks_find_cdata(pak->query, "jid")) ? iks_id_new(client->stack, iks_find_cdata(pak->query, "jid")) : client->jid; 01800 iks_filter_remove_hook(client->f, aji_client_connect); 01801 if(!client->component) /*client*/ 01802 aji_get_roster(client); 01803 } 01804 } else 01805 ast_log(LOG_ERROR, "Out of memory.\n"); 01806 01807 ASTOBJ_UNREF(client, aji_client_destroy); 01808 return res; 01809 }
|
|
|
||||||||||||
|
Definition at line 868 of file res_jabber.c. References aji_client_destroy(), aji_find_resource(), ast_log(), ASTOBJ_CONTAINER_FIND, ASTOBJ_REF, ASTOBJ_UNREF, aji_client::buddies, aji_resource::cap, aji_client::jid, aji_version::jingle, LOG_ERROR, LOG_NOTICE, aji_client::p, and aji_resource::resource. Referenced by aji_create_client(). 00869 { 00870 struct aji_client *client = ASTOBJ_REF((struct aji_client *) data); 00871 struct aji_resource *resource = NULL; 00872 struct aji_buddy *buddy = ASTOBJ_CONTAINER_FIND(&client->buddies, pak->from->partial); 00873 00874 resource = aji_find_resource(buddy, pak->from->resource); 00875 if (pak->subtype == IKS_TYPE_RESULT) { 00876 if (!resource) { 00877 ast_log(LOG_NOTICE,"JABBER: Received client info from %s when not requested.\n", pak->from->full); 00878 ASTOBJ_UNREF(client, aji_client_destroy); 00879 return IKS_FILTER_EAT; 00880 } 00881 if (iks_find_with_attrib(pak->query, "feature", "var", "http://www.google.com/xmpp/protocol/voice/v1")) { 00882 resource->cap->jingle = 1; 00883 } else 00884 resource->cap->jingle = 0; 00885 } else if (pak->subtype == IKS_TYPE_GET) { 00886 iks *iq, *disco, *ident, *google, *query; 00887 iq = iks_new("iq"); 00888 query = iks_new("query"); 00889 ident = iks_new("identity"); 00890 disco = iks_new("feature"); 00891 google = iks_new("feature"); 00892 if (iq && ident && disco && google) { 00893 iks_insert_attrib(iq, "from", client->jid->full); 00894 iks_insert_attrib(iq, "to", pak->from->full); 00895 iks_insert_attrib(iq, "type", "result"); 00896 iks_insert_attrib(iq, "id", pak->id); 00897 iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#info"); 00898 iks_insert_attrib(ident, "category", "client"); 00899 iks_insert_attrib(ident, "type", "pc"); 00900 iks_insert_attrib(ident, "name", "asterisk"); 00901 iks_insert_attrib(disco, "var", "http://jabber.org/protocol/disco#info"); 00902 iks_insert_attrib(google, "var", "http://www.google.com/xmpp/protocol/voice/v1"); 00903 iks_insert_node(iq, query); 00904 iks_insert_node(query, ident); 00905 iks_insert_node(query, google); 00906 iks_insert_node(query, disco); 00907 iks_send(client->p, iq); 00908 } else 00909 ast_log(LOG_ERROR, "Out of Memory.\n"); 00910 if (iq) 00911 iks_delete(iq); 00912 if (query) 00913 iks_delete(query); 00914 if (ident) 00915 iks_delete(ident); 00916 if (google) 00917 iks_delete(google); 00918 if (disco) 00919 iks_delete(disco); 00920 } else if (pak->subtype == IKS_TYPE_ERROR) { 00921 ast_log(LOG_NOTICE, "User %s does not support discovery.\n", pak->from->full); 00922 } 00923 ASTOBJ_UNREF(client, aji_client_destroy); 00924 return IKS_FILTER_EAT; 00925 }
|
|
|
prepares client for connect.
Definition at line 1816 of file res_jabber.c. References ast_log(), aji_client::jid, LOG_ERROR, aji_client::p, aji_client::port, S_OR, and aji_client::serverhost. Referenced by aji_reconnect(). 01817 { 01818 int connected = 0; 01819 01820 connected = iks_connect_via(client->p, S_OR(client->serverhost, client->jid->server), client->port, client->jid->server); 01821 01822 if (connected == IKS_NET_NOCONN) { 01823 ast_log(LOG_ERROR, "JABBER ERROR: No Connection\n"); 01824 return IKS_HOOK; 01825 } else if (connected == IKS_NET_NODNS) { 01826 ast_log(LOG_ERROR, "JABBER ERROR: No DNS %s for client to %s\n", client->name, S_OR(client->serverhost, client->jid->server)); 01827 return IKS_HOOK; 01828 } else 01829 iks_recv(client->p, 30); 01830 return IKS_OK; 01831 }
|
|
|
prepares component for connect.
Definition at line 1838 of file res_jabber.c. References ast_log(), aji_client::jid, LOG_ERROR, aji_client::p, aji_client::port, and aji_client::user. Referenced by aji_reconnect(). 01839 { 01840 int connected = 1; 01841 connected = iks_connect_via(client->p, client->jid->server, client->port, client->user); 01842 if (connected == IKS_NET_NOCONN) { 01843 ast_log(LOG_ERROR, "JABBER ERROR: No Connection\n"); 01844 return IKS_HOOK; 01845 } else if (connected == IKS_NET_NODNS) { 01846 ast_log(LOG_ERROR, "JABBER ERROR: No DNS\n"); 01847 return IKS_HOOK; 01848 } else if (!connected) 01849 iks_recv(client->p, 30); 01850 return IKS_OK; 01851 }
|
|
||||||||||||
|
creates transport. creates buddy.
Definition at line 2227 of file res_jabber.c. References aji_buddy_destroy(), ast_log(), ASTOBJ_CONTAINER_FIND, ASTOBJ_CONTAINER_LINK, ASTOBJ_INIT, ASTOBJ_UNLOCK, ASTOBJ_UNMARK, ASTOBJ_UNREF, ASTOBJ_WRLOCK, aji_client::buddies, LOG_WARNING, and malloc. Referenced by aji_create_client(), and aji_handle_presence(). 02228 { 02229 struct aji_buddy *buddy = NULL; 02230 int flag = 0; 02231 buddy = ASTOBJ_CONTAINER_FIND(&client->buddies,label); 02232 if (!buddy) { 02233 flag = 1; 02234 buddy = malloc(sizeof(struct aji_buddy)); 02235 if(!buddy) { 02236 ast_log(LOG_WARNING, "Out of memory\n"); 02237 return 0; 02238 } 02239 memset(buddy, 0, sizeof(struct aji_buddy)); 02240 ASTOBJ_INIT(buddy); 02241 } 02242 ASTOBJ_WRLOCK(buddy); 02243 ast_copy_string(buddy->name, label, sizeof(buddy->name)); 02244 ASTOBJ_UNLOCK(buddy); 02245 if(flag) 02246 ASTOBJ_CONTAINER_LINK(&client->buddies, buddy); 02247 else { 02248 ASTOBJ_UNMARK(buddy); 02249 ASTOBJ_UNREF(buddy, aji_buddy_destroy); 02250 } 02251 return 1; 02252 }
|
|
||||||||||||||||
|
creates aji_client structure.
Definition at line 2037 of file res_jabber.c. References aji_act_hook(), AJI_AUTOPRUNE, AJI_AUTOREGISTER, aji_client_destroy(), aji_client_info_handler(), aji_create_buddy(), aji_dinfo_handler(), AJI_DISCONNECTED, aji_ditems_handler(), aji_log_hook(), aji_register_approve_handler(), aji_register_query_handler(), asprintf, ast_copy_flags, ast_false(), AST_FLAGS_ALL, AST_LIST_HEAD_INIT, ast_log(), ast_set2_flag, ast_true(), ASTOBJ_CONTAINER_FIND, ASTOBJ_CONTAINER_INIT, ASTOBJ_CONTAINER_LINK, ASTOBJ_CONTAINER_MARKALL, ASTOBJ_INIT, ASTOBJ_UNLOCK, ASTOBJ_UNMARK, ASTOBJ_UNREF, ASTOBJ_WRLOCK, aji_client::authorized, aji_client::buddies, clients, aji_client::component, aji_client::debug, aji_client::f, aji_client::forcessl, free, globalflags, aji_client::jid, aji_client::keepalive, LOG_ERROR, malloc, aji_client::message_timeout, aji_client::mid, aji_client::p, aji_client::password, aji_client::port, aji_client::serverhost, aji_client::stack, aji_client::state, aji_client::statusmessage, aji_client::timeout, aji_client::user, aji_client::usesasl, aji_client::usetls, and var. 02038 { 02039 char *resource; 02040 struct aji_client *client = NULL; 02041 int flag = 0; 02042 02043 client = ASTOBJ_CONTAINER_FIND(&clients,label); 02044 if (!client) { 02045 flag = 1; 02046 client = (struct aji_client *) malloc(sizeof(struct aji_client)); 02047 if (!client) { 02048 ast_log(LOG_ERROR, "Out of memory!\n"); 02049 return 0; 02050 } 02051 memset(client, 0, sizeof(struct aji_client)); 02052 ASTOBJ_INIT(client); 02053 ASTOBJ_WRLOCK(client); 02054 ASTOBJ_CONTAINER_INIT(&client->buddies); 02055 } else { 02056 ASTOBJ_WRLOCK(client); 02057 ASTOBJ_UNMARK(client); 02058 } 02059 ASTOBJ_CONTAINER_MARKALL(&client->buddies); 02060 ast_copy_string(client->name, label, sizeof(client->name)); 02061 ast_copy_string(client->mid, "aaaaa", sizeof(client->mid)); 02062 02063 client->debug = debug; 02064 ast_copy_flags(client, &globalflags, AST_FLAGS_ALL); 02065 client->port = 5222; 02066 client->usetls = 1; 02067 client->usesasl = 1; 02068 client->forcessl = 0; 02069 client->keepalive = 1; 02070 client->timeout = 50; 02071 client->message_timeout = 100; 02072 AST_LIST_HEAD_INIT(&client->messages); 02073 client->component = 0; 02074 ast_copy_string(client->statusmessage, "Online and Available", sizeof(client->statusmessage)); 02075 02076 if (flag) { 02077 client->authorized = 0; 02078 client->state = AJI_DISCONNECTED; 02079 } 02080 while (var) { 02081 if (!strcasecmp(var->name, "username")) 02082 ast_copy_string(client->user, var->value, sizeof(client->user)); 02083 else if (!strcasecmp(var->name, "serverhost")) 02084 ast_copy_string(client->serverhost, var->value, sizeof(client->serverhost)); 02085 else if (!strcasecmp(var->name, "secret")) 02086 ast_copy_string(client->password, var->value, sizeof(client->password)); 02087 else if (!strcasecmp(var->name, "statusmessage")) 02088 ast_copy_string(client->statusmessage, var->value, sizeof(client->statusmessage)); 02089 else if (!strcasecmp(var->name, "port")) 02090 client->port = atoi(var->value); 02091 else if (!strcasecmp(var->name, "timeout")) 02092 client->message_timeout = atoi(var->value); 02093 else if (!strcasecmp(var->name, "debug")) 02094 client->debug = (ast_false(var->value)) ? 0 : 1; 02095 else if (!strcasecmp(var->name, "type")) { 02096 if (!strcasecmp(var->value, "component")) 02097 client->component = 1; 02098 } else if (!strcasecmp(var->name, "usetls")) { 02099 client->usetls = (ast_false(var->value)) ? 0 : 1; 02100 } else if (!strcasecmp(var->name, "usesasl")) { 02101 client->usesasl = (ast_false(var->value)) ? 0 : 1; 02102 } else if (!strcasecmp(var->name, "forceoldssl")) 02103 client->forcessl = (ast_false(var->value)) ? 0 : 1; 02104 else if (!strcasecmp(var->name, "keepalive")) 02105 client->keepalive = (ast_false(var->value)) ? 0 : 1; 02106 else if (!strcasecmp(var->name, "autoprune")) 02107 ast_set2_flag(client, ast_true(var->value), AJI_AUTOPRUNE); 02108 else if (!strcasecmp(var->name, "autoregister")) 02109 ast_set2_flag(client, ast_true(var->value), AJI_AUTOREGISTER); 02110 else if (!strcasecmp(var->name, "buddy")) 02111 aji_create_buddy(var->value, client); 02112 /* no transport support in this version */ 02113 /* else if (!strcasecmp(var->name, "transport")) 02114 aji_create_transport(var->value, client); 02115 */ 02116 var = var->next; 02117 } 02118 if (!flag) { 02119 ASTOBJ_UNLOCK(client); 02120 ASTOBJ_UNREF(client, aji_client_destroy); 02121 return 1; 02122 } 02123 client->p = iks_stream_new(((client->component) ? "jabber:component:accept" : "jabber:client"), client, aji_act_hook); 02124 if (!client->p) { 02125 ast_log(LOG_ERROR, "Failed to create stream for client '%s'!\n", client->name); 02126 return 0; 02127 } 02128 client->stack = iks_stack_new(8192, 8192); 02129 if (!client->stack) { 02130 ast_log(LOG_ERROR, "Failed to allocate stack for client '%s'\n", client->name); 02131 return 0; 02132 } 02133 client->f = iks_filter_new(); 02134 if (!client->f) { 02135 ast_log(LOG_ERROR, "Failed to create filter for client '%s'\n", client->name); 02136 return 0; 02137 } 02138 if (!strchr(client->user, '/') && !client->component) { /*client */ 02139 resource = NULL; 02140 asprintf(&resource, "%s/asterisk", client->user); 02141 if (resource) { 02142 client->jid = iks_id_new(client->stack, resource); 02143 free(resource); 02144 } 02145 } else 02146 client->jid = iks_id_new(client->stack, client->user); 02147 if (client->component) { 02148 iks_filter_add_rule(client->f, aji_dinfo_handler, client, IKS_RULE_NS, "http://jabber.org/protocol/disco#info", IKS_RULE_DONE); 02149 iks_filter_add_rule(client->f, aji_ditems_handler, client, IKS_RULE_NS, "http://jabber.org/protocol/disco#items", IKS_RULE_DONE); 02150 iks_filter_add_rule(client->f, aji_register_query_handler, client, IKS_RULE_SUBTYPE, IKS_TYPE_GET, IKS_RULE_NS, "jabber:iq:register", IKS_RULE_DONE); 02151 iks_filter_add_rule(client->f, aji_register_approve_handler, client, IKS_RULE_SUBTYPE, IKS_TYPE_SET, IKS_RULE_NS, "jabber:iq:register", IKS_RULE_DONE); 02152 } else { 02153 iks_filter_add_rule(client->f, aji_client_info_handler, client, IKS_RULE_NS, "http://jabber.org/protocol/disco#info", IKS_RULE_DONE); 02154 } 02155 if (!strchr(client->user, '/') && !client->component) { /*client */ 02156 resource = NULL; 02157 asprintf(&resource, "%s/asterisk", client->user); 02158 if (resource) { 02159 client->jid = iks_id_new(client->stack, resource); 02160 free(resource); 02161 } 02162 } else 02163 client->jid = iks_id_new(client->stack, client->user); 02164 iks_set_log_hook(client->p, aji_log_hook); 02165 ASTOBJ_UNLOCK(client); 02166 ASTOBJ_CONTAINER_LINK(&clients,client); 02167 return 1; 02168 }
|
|
||||||||||||
|
Definition at line 927 of file res_jabber.c. References aji_client_destroy(), aji_find_resource(), ast_log(), ASTOBJ_CONTAINER_FIND, ASTOBJ_REF, ASTOBJ_UNREF, aji_client::buddies, aji_resource::cap, commands, aji_version::jingle, LOG_ERROR, LOG_NOTICE, LOG_WARNING, aji_client::p, aji_resource::resource, and aji_client::user. Referenced by aji_create_client(). 00928 { 00929 struct aji_client *client = ASTOBJ_REF((struct aji_client *) data); 00930 char *node = NULL; 00931 struct aji_resource *resource = NULL; 00932 struct aji_buddy *buddy = ASTOBJ_CONTAINER_FIND(&client->buddies, pak->from->partial); 00933 00934 resource = aji_find_resource(buddy, pak->from->resource); 00935 if (pak->subtype == IKS_TYPE_ERROR) { 00936 ast_log(LOG_WARNING, "Recieved error from a client, turn on jabber debug!\n"); 00937 return IKS_FILTER_EAT; 00938 } 00939 if (pak->subtype == IKS_TYPE_RESULT) { 00940 if (!resource) { 00941 ast_log(LOG_NOTICE,"JABBER: Received client info from %s when not requested.\n", pak->from->full); 00942 ASTOBJ_UNREF(client, aji_client_destroy); 00943 return IKS_FILTER_EAT; 00944 } 00945 if (iks_find_with_attrib(pak->query, "feature", "var", "http://www.google.com/xmpp/protocol/voice/v1")) { 00946 resource->cap->jingle = 1; 00947 } else 00948 resource->cap->jingle = 0; 00949 } else if (pak->subtype == IKS_TYPE_GET && !(node = iks_find_attrib(pak->query, "node"))) { 00950 iks *iq, *query, *identity, *disco, *reg, *commands, *gateway, *version, *vcard, *search; 00951 00952 iq = iks_new("iq"); 00953 query = iks_new("query"); 00954 identity = iks_new("identity"); 00955 disco = iks_new("feature"); 00956 reg = iks_new("feature"); 00957 commands = iks_new("feature"); 00958 gateway = iks_new("feature"); 00959 version = iks_new("feature"); 00960 vcard = iks_new("feature"); 00961 search = iks_new("feature"); 00962 00963 if (iq && query && identity && disco && reg && commands && gateway && version && vcard && search && client) { 00964 iks_insert_attrib(iq, "from", client->user); 00965 iks_insert_attrib(iq, "to", pak->from->full); 00966 iks_insert_attrib(iq, "id", pak->id); 00967 iks_insert_attrib(iq, "type", "result"); 00968 iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#info"); 00969 iks_insert_attrib(identity, "category", "gateway"); 00970 iks_insert_attrib(identity, "type", "pstn"); 00971 iks_insert_attrib(identity, "name", "Asterisk The Open Source PBX"); 00972 iks_insert_attrib(disco, "var", "http://jabber.org/protocol/disco"); 00973 iks_insert_attrib(reg, "var", "jabber:iq:register"); 00974 iks_insert_attrib(commands, "var", "http://jabber.org/protocol/commands"); 00975 iks_insert_attrib(gateway, "var", "jabber:iq:gateway"); 00976 iks_insert_attrib(version, "var", "jabber:iq:version"); 00977 iks_insert_attrib(vcard, "var", "vcard-temp"); 00978 iks_insert_attrib(search, "var", "jabber:iq:search"); 00979 00980 iks_insert_node(iq, query); 00981 iks_insert_node(query, identity); 00982 iks_insert_node(query, disco); 00983 iks_insert_node(query, reg); 00984 iks_insert_node(query, commands); 00985 iks_insert_node(query, gateway); 00986 iks_insert_node(query, version); 00987 iks_insert_node(query, vcard); 00988 iks_insert_node(query, search); 00989 iks_send(client->p, iq); 00990 } else { 00991 ast_log(LOG_ERROR, "Out of memory.\n"); 00992 } 00993 00994 if (iq) 00995 iks_delete(iq); 00996 if (query) 00997 iks_delete(query); 00998 if (identity) 00999 iks_delete(identity); 01000 if (disco) 01001 iks_delete(disco); 01002 if (reg) 01003 iks_delete(reg); 01004 if (commands) 01005 iks_delete(commands); 01006 if (gateway) 01007 iks_delete(gateway); 01008 if (version) 01009 iks_delete(version); 01010 if (vcard) 01011 iks_delete(vcard); 01012 if (search) 01013 iks_delete(search); 01014 01015 } else if (pak->subtype == IKS_TYPE_GET && !strcasecmp(node, "http://jabber.org/protocol/commands")) { 01016 iks *iq, *query, *confirm; 01017 iq = iks_new("iq"); 01018 query = iks_new("query"); 01019 confirm = iks_new("item"); 01020 01021 if (iq && query && confirm && client) { 01022 iks_insert_attrib(iq, "from", client->user); 01023 iks_insert_attrib(iq, "to", pak->from->full); 01024 iks_insert_attrib(iq, "id", pak->id); 01025 iks_insert_attrib(iq, "type", "result"); 01026 iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#items"); 01027 iks_insert_attrib(query, "node", "http://jabber.org/protocol/commands"); 01028 iks_insert_attrib(confirm, "node", "confirmaccount"); 01029 iks_insert_attrib(confirm, "name", "Confirm AIM account"); 01030 iks_insert_attrib(confirm, "jid", client->user); 01031 iks_insert_node(iq, query); 01032 iks_insert_node(query, confirm); 01033 iks_send(client->p, iq); 01034 } else { 01035 ast_log(LOG_ERROR, "Out of memory.\n"); 01036 } 01037 if (iq) 01038 iks_delete(iq); 01039 if (query) 01040 iks_delete(query); 01041 if (confirm) 01042 iks_delete(confirm); 01043 01044 } else if (pak->subtype == IKS_TYPE_GET && !strcasecmp(node, "confirmaccount")) { 01045 iks *iq, *query, *feature; 01046 01047 iq = iks_new("iq"); 01048 query = iks_new("query"); 01049 feature = iks_new("feature"); 01050 01051 if (iq && query && feature && client) { 01052 iks_insert_attrib(iq, "from", client->user); 01053 iks_insert_attrib(iq, "to", pak->from->full); 01054 iks_insert_attrib(iq, "id", pak->id); 01055 iks_insert_attrib(iq, "type", "result"); 01056 iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#info"); 01057 iks_insert_attrib(feature, "var", "http://jabber.org/protocol/commands"); 01058 iks_insert_node(iq, query); 01059 iks_insert_node(query, feature); 01060 iks_send(client->p, iq); 01061 } else { 01062 ast_log(LOG_ERROR, "Out of memory.\n"); 01063 } 01064 if (iq) 01065 iks_delete(iq); 01066 if (query) 01067 iks_delete(query); 01068 if (feature) 01069 iks_delete(feature); 01070 } 01071 01072 ASTOBJ_UNREF(client, aji_client_destroy); 01073 return IKS_FILTER_EAT; 01074 }
|
|
||||||||||||
|
Definition at line 772 of file res_jabber.c. References aji_client_destroy(), ast_log(), ASTOBJ_REF, ASTOBJ_UNREF, LOG_ERROR, aji_client::p, and aji_client::user. Referenced by aji_create_client(). 00773 { 00774 struct aji_client *client = ASTOBJ_REF((struct aji_client *) data); 00775 char *node = NULL; 00776 00777 if (!(node = iks_find_attrib(pak->query, "node"))) { 00778 iks *iq = NULL, *query = NULL, *item = NULL; 00779 iq = iks_new("iq"); 00780 query = iks_new("query"); 00781 item = iks_new("item"); 00782 00783 if (iq && query && item) { 00784 iks_insert_attrib(iq, "from", client->user); 00785 iks_insert_attrib(iq, "to", pak->from->full); 00786 iks_insert_attrib(iq, "id", pak->id); 00787 iks_insert_attrib(iq, "type", "result"); 00788 iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#items"); 00789 iks_insert_attrib(item, "node", "http://jabber.org/protocol/commands"); 00790 iks_insert_attrib(item, "name", "Million Dollar Asterisk Commands"); 00791 iks_insert_attrib(item, "jid", client->user); 00792 00793 iks_insert_node(iq, query); 00794 iks_insert_node(query, item); 00795 iks_send(client->p, iq); 00796 } else { 00797 ast_log(LOG_ERROR, "Out of memory.\n"); 00798 } 00799 if (iq) 00800 iks_delete(iq); 00801 if (query) 00802 iks_delete(query); 00803 if (item) 00804 iks_delete(item); 00805 00806 } else if (!strcasecmp(node, "http://jabber.org/protocol/commands")) { 00807 iks *iq, *query, *confirm; 00808 iq = iks_new("iq"); 00809 query = iks_new("query"); 00810 confirm = iks_new("item"); 00811 if (iq && query && confirm && client) { 00812 iks_insert_attrib(iq, "from", client->user); 00813 iks_insert_attrib(iq, "to", pak->from->full); 00814 iks_insert_attrib(iq, "id", pak->id); 00815 iks_insert_attrib(iq, "type", "result"); 00816 iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#items"); 00817 iks_insert_attrib(query, "node", "http://jabber.org/protocol/commands"); 00818 iks_insert_attrib(confirm, "node", "confirmaccount"); 00819 iks_insert_attrib(confirm, "name", "Confirm AIM account"); 00820 iks_insert_attrib(confirm, "jid", "blog.astjab.org"); 00821 00822 iks_insert_node(iq, query); 00823 iks_insert_node(query, confirm); 00824 iks_send(client->p, iq); 00825 } else { 00826 ast_log(LOG_ERROR, "Out of memory.\n"); 00827 } 00828 if (iq) 00829 iks_delete(iq); 00830 if (query) 00831 iks_delete(query); 00832 if (confirm) 00833 iks_delete(confirm); 00834 00835 } else if (!strcasecmp(node, "confirmaccount")) { 00836 iks *iq = NULL, *query = NULL, *feature = NULL; 00837 00838 iq = iks_new("iq"); 00839 query = iks_new("query"); 00840 feature = iks_new("feature"); 00841 00842 if (iq && query && feature && client) { 00843 iks_insert_attrib(iq, "from", client->user); 00844 iks_insert_attrib(iq, "to", pak->from->full); 00845 iks_insert_attrib(iq, "id", pak->id); 00846 iks_insert_attrib(iq, "type", "result"); 00847 iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#items"); 00848 iks_insert_attrib(feature, "var", "http://jabber.org/protocol/commands"); 00849 iks_insert_node(iq, query); 00850 iks_insert_node(query, feature); 00851 iks_send(client->p, iq); 00852 } else { 00853 ast_log(LOG_ERROR, "Out of memory.\n"); 00854 } 00855 if (iq) 00856 iks_delete(iq); 00857 if (query) 00858 iks_delete(query); 00859 if (feature) 00860 iks_delete(feature); 00861 } 00862 00863 ASTOBJ_UNREF(client, aji_client_destroy); 00864 return IKS_FILTER_EAT; 00865 00866 }
|
|
||||||||||||||||
|
turnon console debugging.
Definition at line 1908 of file res_jabber.c. References ASTOBJ_CONTAINER_TRAVERSE, ASTOBJ_RDLOCK, ASTOBJ_UNLOCK, and clients. 01909 { 01910 ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { 01911 ASTOBJ_RDLOCK(iterator); 01912 iterator->debug = 1; 01913 ASTOBJ_UNLOCK(iterator); 01914 }); 01915 ast_cli(fd, "Jabber Debugging Enabled.\n"); 01916 return RESULT_SUCCESS; 01917 }
|
|
||||||||||||||||
|
reload jabber module.
Definition at line 1924 of file res_jabber.c. References aji_reload(), ast_cli(), and RESULT_SUCCESS. 01925 { 01926 aji_reload(); 01927 ast_cli(fd, "Jabber Reloaded.\n"); 01928 return RESULT_SUCCESS; 01929 }
|
|
||||||||||||
|
filters the roster packet we get back from server.
Definition at line 1679 of file res_jabber.c. References AJI_AUTOPRUNE, AJI_AUTOREGISTER, AJI_CONNECTED, ast_clear_flag, ast_copy_flags, ASTOBJ_CONTAINER_TRAVERSE, ASTOBJ_RDLOCK, ASTOBJ_REF, ASTOBJ_UNLOCK, aji_client::buddies, and aji_client::state. Referenced by aji_client_connect(). 01680 { 01681 struct aji_client *client = ASTOBJ_REF((struct aji_client *) data); 01682 int flag = 0; 01683 iks *x = NULL; 01684 struct aji_buddy *buddy; 01685 01686 client->state = AJI_CONNECTED; 01687 ASTOBJ_CONTAINER_TRAVERSE(&client->buddies, 1, { 01688 ASTOBJ_RDLOCK(iterator); 01689 x = iks_child(pak->query); 01690 flag = 0; 01691 while (x) { 01692 if (!iks_strcmp(iks_name(x), "item")) { 01693 if (!strcasecmp(iterator->name, iks_find_attrib(x, "jid"))) { 01694 flag = 1; 01695 ast_clear_flag(iterator, AJI_AUTOPRUNE | AJI_AUTOREGISTER); 01696 } 01697 } 01698 x = iks_next(x); 01699 } 01700 if (!flag) 01701 ast_copy_flags(iterator, client, AJI_AUTOREGISTER); 01702 if (x) 01703 iks_delete(x); 01704 ASTOBJ_UNLOCK(iterator); 01705 }); 01706 01707 x = iks_child(pak->query); 01708 while (x) { 01709 flag = 0; 01710 if (iks_strcmp(iks_name(x), "item") == 0) { 01711 ASTOBJ_CONTAINER_TRAVERSE(&client->buddies, 1, { 01712 ASTOBJ_RDLOCK(iterator); 01713 if (!strcasecmp(iterator->name, iks_find_attrib(x, "jid"))) 01714 flag = 1; 01715 ASTOBJ_UNLOCK(iterator); 01716 }); 01717 01718 if (!flag) { 01719 buddy = (struct aji_buddy *) malloc(sizeof(struct aji_buddy)); 01720 if (!buddy) { 01721 ast_log(LOG_WARNING, "Out of memory\n"); 01722 return 0; 01723 } 01724 memset(buddy, 0, sizeof(struct aji_buddy)); 01725 ASTOBJ_INIT(buddy); 01726 ASTOBJ_WRLOCK(buddy); 01727 ast_copy_string(buddy->name, iks_find_attrib(x, "jid"), sizeof(buddy->name)); 01728 ast_clear_flag(buddy, AST_FLAGS_ALL); 01729 if(ast_test_flag(client, AJI_AUTOPRUNE)) { 01730 ast_set_flag(buddy, AJI_AUTOPRUNE); 01731 buddy->objflags |= ASTOBJ_FLAG_MARKED; 01732 } else 01733 ast_set_flag(buddy, AJI_AUTOREGISTER); 01734 ASTOBJ_UNLOCK(buddy); 01735 if (buddy) { 01736 ASTOBJ_CONTAINER_LINK(&client->buddies, buddy); 01737 ASTOBJ_UNREF(buddy, aji_buddy_destroy); 01738 } 01739 } 01740 } 01741 x = iks_next(x); 01742 } 01743 if (x) 01744 iks_delete(x); 01745 aji_pruneregister(client); 01746 01747 ASTOBJ_UNREF(client, aji_client_destroy); 01748 return IKS_FILTER_EAT; 01749 }
|
|
||||||||||||
|
Definition at line 268 of file res_jabber.c. References aji_resource::next, aji_resource::resource, and aji_buddy::resources. Referenced by aji_client_info_handler(), aji_dinfo_handler(), and aji_status_exec(). 00269 { 00270 struct aji_resource *res = NULL; 00271 if (!buddy || !name) 00272 return res; 00273 res = buddy->resources; 00274 while (res) { 00275 if (!strcasecmp(res->resource, name)) { 00276 break; 00277 } 00278 res = res->next; 00279 } 00280 return res; 00281 }
|
|
||||||||||||||||
|
Definition at line 210 of file res_jabber.c. References ast_log(), capabilities, aji_version::jingle, LOG_ERROR, malloc, aji_capabilities::next, aji_version::next, aji_capabilities::node, aji_version::parent, aji_version::version, and aji_capabilities::versions. Referenced by aji_handle_presence(). 00211 { 00212 struct aji_capabilities *list = NULL; 00213 struct aji_version *res = NULL; 00214 00215 list = capabilities; 00216 00217 if(!node) 00218 node = pak->from->full; 00219 if(!version) 00220 version = "none supplied."; 00221 while(list) { 00222 if(!strcasecmp(list->node, node)) { 00223 res = list->versions; 00224 while(res) { 00225 if(!strcasecmp(res->version, version)) 00226 return res; 00227 res = res->next; 00228 } 00229 if(!res) { 00230 res = (struct aji_version *)malloc(sizeof(struct aji_version)); 00231 if(!res) { 00232 ast_log(LOG_ERROR, "Out of memory!\n"); 00233 return NULL; 00234 } 00235 res->jingle = 0; 00236 res->parent = list; 00237 ast_copy_string(res->version, version, sizeof(res->version)); 00238 res->next = list->versions; 00239 list->versions = res; 00240 return res; 00241 } 00242 } 00243 list = list->next; 00244 } 00245 if(!list) { 00246 list = (struct aji_capabilities *)malloc(sizeof(struct aji_capabilities)); 00247 if(!list) { 00248 ast_log(LOG_ERROR, "Out of memory!\n"); 00249 return NULL; 00250 } 00251 res = (struct aji_version *)malloc(sizeof(struct aji_version)); 00252 if(!res) { 00253 ast_log(LOG_ERROR, "Out of memory!\n"); 00254 return NULL; 00255 } 00256 ast_copy_string(list->node, node, sizeof(list->node)); 00257 ast_copy_string(res->version, version, sizeof(res->version)); 00258 res->jingle = 0; 00259 res->parent = list; 00260 res->next = list->versions; 00261 list->versions = res; 00262 list->next = capabilities; 00263 capabilities = list; 00264 } 00265 return res; 00266 }
|
|
|
Definition at line 1771 of file res_jabber.c. References aji_set_presence(), aji_client::jid, aji_client::p, and aji_client::statusmessage. Referenced by aji_client_connect(). 01772 { 01773 iks *roster = NULL; 01774 roster = iks_make_iq(IKS_TYPE_GET, IKS_NS_ROSTER); 01775 if(roster) { 01776 iks_insert_attrib(roster, "id", "roster"); 01777 aji_set_presence(client, NULL, client->jid->full, 1, client->statusmessage); 01778 iks_send(client->p, roster); 01779 } 01780 if (roster) 01781 iks_delete(roster); 01782 return 1; 01783 }
|
|
||||||||||||
|
Handles <iq> tags.
Definition at line 1081 of file res_jabber.c. Referenced by aji_act_hook().
|
|
||||||||||||
|
Handles presence packets.
Definition at line 1091 of file res_jabber.c. References aji_message::arrived, ast_calloc, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_strdup, free, aji_message::from, aji_message::id, aji_message::message, and aji_client::message_timeout. Referenced by aji_act_hook(). 01092 { 01093 struct aji_message *insert, *tmp; 01094 int flag = 0; 01095 01096 if (!(insert = ast_calloc(1, sizeof(struct aji_message)))) 01097 return; 01098 time(&insert->arrived); 01099 if (iks_find_cdata(pak->x, "body")) 01100 insert->message = ast_strdup(iks_find_cdata(pak->x, "body")); 01101 if(pak->id) 01102 ast_copy_string(insert->id, pak->id, sizeof(insert->message)); 01103 if (pak->from) 01104 insert->from = ast_strdup(pak->from->full); 01105 AST_LIST_LOCK(&client->messages); 01106 AST_LIST_TRAVERSE_SAFE_BEGIN(&client->messages, tmp, list) { 01107 if (flag) { 01108 AST_LIST_REMOVE_CURRENT(&client->messages, list); 01109 if (tmp->from) 01110 free(tmp->from); 01111 if (tmp->message) 01112 free(tmp->message); 01113 } else if (difftime(time(NULL), tmp->arrived) >= client->message_timeout) { 01114 flag = 1; 01115 AST_LIST_REMOVE_CURRENT(&client->messages, list); 01116 if (tmp->from) 01117 free(tmp->from); 01118 if (tmp->message) 01119 free(tmp->message); 01120 } 01121 } 01122 AST_LIST_TRAVERSE_SAFE_END; 01123 AST_LIST_INSERT_HEAD(&client->messages, insert, list); 01124 AST_LIST_UNLOCK(&client->messages); 01125 }
|
|
||||||||||||
|
Definition at line 1127 of file res_jabber.c. References aji_buddy_destroy(), AJI_CONNECTED, aji_create_buddy(), aji_find_version(), aji_set_presence(), ast_aji_increment_mid(), ast_log(), ast_strdup, ast_verbose(), ASTOBJ_CONTAINER_FIND, ASTOBJ_UNLOCK, ASTOBJ_UNREF, ASTOBJ_WRLOCK, aji_client::buddies, aji_client::component, descrip, aji_resource::description, free, gtalk_yuck(), last, LOG_DEBUG, LOG_ERROR, LOG_NOTICE, malloc, aji_client::mid, aji_resource::next, option_debug, option_verbose, aji_client::p, aji_resource::priority, aji_resource::resource, aji_buddy::resources, aji_client::state, aji_resource::status, aji_client::statusmessage, type, and VERBOSE_PREFIX_3. Referenced by aji_act_hook(). 01128 { 01129 int status, priority; 01130 struct aji_buddy *buddy; 01131 struct aji_resource *tmp = NULL, *last = NULL, *found = NULL; 01132 char *ver, *node, *descrip, *type; 01133 01134 if(client->state != AJI_CONNECTED) 01135 aji_create_buddy(pak->from->partial, client); 01136 01137 buddy = ASTOBJ_CONTAINER_FIND(&client->buddies, pak->from->partial); 01138 if (!buddy) { 01139 ast_log(LOG_NOTICE, "Got presence packet from %s, someone not in our roster!!!!\n", pak->from->partial); 01140 return; 01141 } 01142 type = iks_find_attrib(pak->x, "type"); 01143 if(client->component && type &&!strcasecmp("probe", type)) { 01144 aji_set_presence(client, pak->from->full, iks_find_attrib(pak->x, "to"), 1, client->statusmessage); 01145 ast_verbose("what i was looking for \n"); 01146 } 01147 ASTOBJ_WRLOCK(buddy); 01148 status = (pak->show) ? pak->show : 6; 01149 priority = atoi((iks_find_cdata(pak->x, "priority")) ? iks_find_cdata(pak->x, "priority") : "0"); 01150 tmp = buddy->resources; 01151 descrip = ast_strdup(iks_find_cdata(pak->x,"status")); 01152 01153 while (tmp) { 01154 if (!strcasecmp(tmp->resource, pak->from->resource)) { 01155 tmp->status = status; 01156 if (tmp->description) free(tmp->description); 01157 tmp->description = descrip; 01158 found = tmp; 01159 if (status == 6) { /* Sign off Destroy resource */ 01160 if (last && found->next) { 01161 last->next = found->next; 01162 } else if (!last) { 01163 if (found->next) 01164 buddy->resources = found->next; 01165 else 01166 buddy->resources = NULL; 01167 } else if (!found->next) { 01168 if (last) 01169 last->next = NULL; 01170 else 01171 buddy->resources = NULL; 01172 } 01173 free(found); 01174 found = NULL; 01175 break; 01176 } 01177 if (tmp->priority != priority) { 01178 found->priority = priority; 01179 if (!last && !found->next) 01180 break; 01181 if (last) 01182 last->next = found->next; 01183 else 01184 buddy->resources = found->next; 01185 last = NULL; 01186 tmp = buddy->resources; 01187 if (!buddy->resources) 01188 buddy->resources = found; 01189 while (tmp) { 01190 if (found->priority > tmp->priority) { 01191 if (last) 01192 last->next = found; 01193 found->next = tmp; 01194 if (!last) 01195 buddy->resources = found; 01196 break; 01197 } 01198 if (!tmp->next) { 01199 tmp->next = found; 01200 break; 01201 } 01202 last = tmp; 01203 tmp = tmp->next; 01204 } 01205 } 01206 break; 01207 } 01208 last = tmp; 01209 tmp = tmp->next; 01210 } 01211 01212 if (!found && status != 6) { 01213 found = (struct aji_resource *) malloc(sizeof(struct aji_resource)); 01214 memset(found, 0, sizeof(struct aji_resource)); 01215 01216 if (!found) { 01217 ast_log(LOG_ERROR, "Out of memory!\n"); 01218 return; 01219 } 01220 ast_copy_string(found->resource, pak->from->resource, sizeof(found->resource)); 01221 found->status = status; 01222 found->description = descrip; 01223 found->priority = priority; 01224 found->next = NULL; 01225 last = NULL; 01226 tmp = buddy->resources; 01227 while (tmp) { 01228 if (found->priority > tmp->priority) { 01229 if (last) 01230 last->next = found; 01231 found->next = tmp; 01232 if (!last) 01233 buddy->resources = found; 01234 break; 01235 } 01236 if (!tmp->next) { 01237 tmp->next = found; 01238 break; 01239 } 01240 last = tmp; 01241 tmp = tmp->next; 01242 } 01243 if (!tmp) 01244 buddy->resources = found; 01245 } 01246 ASTOBJ_UNLOCK(buddy); 01247 ASTOBJ_UNREF(buddy, aji_buddy_destroy); 01248 01249 node = iks_find_attrib(iks_find(pak->x, "c"), "node"); 01250 ver = iks_find_attrib(iks_find(pak->x, "c"), "ver"); 01251 01252 if(status !=6 && !found->cap) { 01253 found->cap = aji_find_version(node, ver, pak); 01254 if(gtalk_yuck(pak->x)) /* gtalk should do discover */ 01255 found->cap->jingle = 1; 01256 if(found->cap->jingle && option_debug > 4) { 01257 if (option_debug) 01258 ast_log(LOG_DEBUG,"Special case for google till they support discover.\n"); 01259 } 01260 else { 01261 iks *iq, *query; 01262 iq = iks_new("iq"); 01263 query = iks_new("query"); 01264 if(query && iq) { 01265 iks_insert_attrib(iq, "type", "get"); 01266 iks_insert_attrib(iq, "to", pak->from->full); 01267 iks_insert_attrib(iq,"from",iks_find_attrib(pak->x,"to")); 01268 iks_insert_attrib(iq, "id", client->mid); 01269 ast_aji_increment_mid(client->mid); 01270 iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#info"); 01271 iks_insert_node(iq, query); 01272 iks_send(client->p, iq); 01273 01274 } else 01275 ast_log(LOG_ERROR, "Out of memory.\n"); 01276 if(query) 01277 iks_delete(query); 01278 if(iq) 01279 iks_delete(iq); 01280 } 01281 } 01282 if (option_verbose > 4) { 01283 switch (pak->subtype) { 01284 case IKS_TYPE_AVAILABLE: 01285 ast_verbose(VERBOSE_PREFIX_3 "JABBER: I am available ^_* %i\n", pak->subtype); 01286 break; 01287 case IKS_TYPE_UNAVAILABLE: 01288 ast_verbose(VERBOSE_PREFIX_3 "JABBER: I am unavailable ^_* %i\n", pak->subtype); 01289 break; 01290 default: 01291 ast_verbose(VERBOSE_PREFIX_3 "JABBER: Ohh sexy and the wrong type: %i\n", pak->subtype); 01292 } 01293 switch (pak->show) { 01294 case IKS_SHOW_UNAVAILABLE: 01295 ast_verbose(VERBOSE_PREFIX_3 "JABBER: type: %i subtype %i\n", pak->subtype, pak->show); 01296 break; 01297 case IKS_SHOW_AVAILABLE: 01298 ast_verbose(VERBOSE_PREFIX_3 "JABBER: type is available\n"); 01299 break; 01300 case IKS_SHOW_CHAT: 01301 ast_verbose(VERBOSE_PREFIX_3 "JABBER: type: %i subtype %i\n", pak->subtype, pak->show); 01302 break; 01303 case IKS_SHOW_AWAY: 01304 ast_verbose(VERBOSE_PREFIX_3 "JABBER: type is away\n"); 01305 break; 01306 case IKS_SHOW_XA: 01307 ast_verbose(VERBOSE_PREFIX_3 "JABBER: type: %i subtype %i\n", pak->subtype, pak->show); 01308 break; 01309 case IKS_SHOW_DND: 01310 ast_verbose(VERBOSE_PREFIX_3 "JABBER: type: %i subtype %i\n", pak->subtype, pak->show); 01311 break; 01312 default: 01313 ast_verbose(VERBOSE_PREFIX_3 "JABBER: Kinky! how did that happen %i\n", pak->show); 01314 } 01315 } 01316 }
|
|
||||||||||||
|
handles subscription requests.
Definition at line 1323 of file res_jabber.c. References aji_set_presence(), ast_log(), ast_verbose(), aji_client::component, LOG_ERROR, option_verbose, aji_client::p, aji_resource::status, aji_client::statusmessage, and VERBOSE_PREFIX_3. Referenced by aji_act_hook(). 01324 { 01325 if(pak->subtype == IKS_TYPE_SUBSCRIBE) { 01326 iks *presence = NULL, *status = NULL; 01327 presence = iks_new("presence"); 01328 status = iks_new("status"); 01329 if(presence && status) { 01330 iks_insert_attrib(presence, "type", "subscribed"); 01331 iks_insert_attrib(presence, "to", pak->from->full); 01332 iks_insert_attrib(presence, "from", iks_find_attrib(pak->x, "to")); 01333 if(pak->id) 01334 iks_insert_attrib(presence, "id", pak->id); 01335 iks_insert_cdata(status, "Asterisk has approved subscription", 0); 01336 iks_insert_node(presence, status); 01337 iks_send(client->p, presence); 01338 } else 01339 ast_log(LOG_ERROR, "Unable to allocate nodes\n"); 01340 if(presence) 01341 iks_delete(presence); 01342 if(status) 01343 iks_delete(status); 01344 if(client->component) 01345 aji_set_presence(client, pak->from->full, iks_find_attrib(pak->x, "to"), 1, client->statusmessage); 01346 } 01347 if (option_verbose > 4) { 01348 switch (pak->subtype) { 01349 case IKS_TYPE_SUBSCRIBE: 01350 ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n", pak->subtype); 01351 break; 01352 case IKS_TYPE_SUBSCRIBED: 01353 ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n", pak->subtype); 01354 break; 01355 case IKS_TYPE_UNSUBSCRIBE: 01356 ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n", pak->subtype); 01357 break; 01358 case IKS_TYPE_UNSUBSCRIBED: 01359 ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n", pak->subtype); 01360 break; 01361 default: /*IKS_TYPE_ERROR: */ 01362 ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n", pak->subtype); 01363 break; 01364 } 01365 } 01366 }
|
|
|
Detects the highest bit in a number.
Definition at line 295 of file res_jabber.c. Referenced by aji_act_hook(). 00296 { 00297 int x = sizeof(number) * 8 - 1; 00298 if (!number) 00299 return 0; 00300 for (; x > 0; x--) { 00301 if (number & (1 << x)) 00302 break; 00303 } 00304 return (1 << x); 00305 }
|
|
|
load config file.
Definition at line 2259 of file res_jabber.c. References AJI_AUTOPRUNE, AJI_AUTOREGISTER, ast_category_browse(), ast_config_load(), ast_false(), ast_log(), ast_set2_flag, ast_true(), ast_variable_browse(), ast_variable_retrieve(), debug(), globalflags, JABBER_CONFIG, LOG_WARNING, and var. Referenced by aji_reload(). 02260 { 02261 char *cat = NULL; 02262 int debug = 1; 02263 struct ast_config *cfg = NULL; 02264 struct ast_variable *var = NULL; 02265 02266 cfg = ast_config_load(JABBER_CONFIG); 02267 if (!cfg) { 02268 ast_log(LOG_WARNING, "No such configuration file %s\n", JABBER_CONFIG); 02269 return 0; 02270 } 02271 02272 cat = ast_category_browse(cfg, NULL); 02273 for (var = ast_variable_browse(cfg, "general"); var; var = var->next) { 02274 if (!strcasecmp(var->name, "debug")) 02275 debug = (ast_false(ast_variable_retrieve(cfg, "general", "debug"))) ? 0 : 1; 02276 else if (!strcasecmp(var->name, "autoprune")) 02277 ast_set2_flag(&globalflags, ast_true(var->value), AJI_AUTOPRUNE); 02278 else if (!strcasecmp(var->name, "autoregister")) 02279 ast_set2_flag(&globalflags, ast_true(var->value), AJI_AUTOREGISTER); 02280 } 02281 02282 while (cat) { 02283 if (strcasecmp(cat, "general")) { 02284 var = ast_variable_browse(cfg, cat); 02285 aji_create_client(cat, var, debug); 02286 } 02287 cat = ast_category_browse(cfg, cat); 02288 } 02289 return 1; 02290 }
|
|
||||||||||||||||||||
|
the debug loop.
Definition at line 435 of file res_jabber.c. References aji_client_destroy(), ast_verbose(), ASTOBJ_REF, ASTOBJ_UNREF, aji_client::debug, EVENT_FLAG_USER, manager_event, and option_debug. Referenced by aji_create_client(). 00436 { 00437 struct aji_client *client = ASTOBJ_REF((struct aji_client *) data); 00438 manager_event(EVENT_FLAG_USER, "JabberEvent", "Account: %s\r\nPacket: %s", client->name, xmpp); 00439 00440 if (client->debug) { 00441 if (is_incoming) 00442 ast_verbose("\nJABBER: %s INCOMING: %s\n", client->name, xmpp); 00443 else { 00444 if( strlen(xmpp) == 1) { 00445 if(option_debug > 2 && xmpp[0] == ' ') 00446 ast_verbose("\nJABBER: Keep alive packet\n"); 00447 } else 00448 ast_verbose("\nJABBER: %s OUTGOING: %s\n", client->name, xmpp); 00449 } 00450 00451 } 00452 ASTOBJ_UNREF(client, aji_client_destroy); 00453 }
|
|
||||||||||||||||
|
turnoff console debugging.
Definition at line 1936 of file res_jabber.c. References ASTOBJ_CONTAINER_TRAVERSE, ASTOBJ_RDLOCK, ASTOBJ_UNLOCK, and clients. 01937 { 01938 ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { 01939 ASTOBJ_RDLOCK(iterator); 01940 iterator->debug = 0; 01941 ASTOBJ_UNLOCK(iterator); 01942 }); 01943 ast_cli(fd, "Jabber Debugging Disabled.\n"); 01944 return RESULT_SUCCESS; 01945 }
|
|
|
attempts to register to a transport. attempts to register to a transport step 2. goes through roster and prunes users not needed in list, or adds them accordingly.
Definition at line 1626 of file res_jabber.c. References AJI_AUTOPRUNE, AJI_AUTOREGISTER, ast_clear_flag, ast_test_flag, ASTOBJ_CONTAINER_TRAVERSE, ASTOBJ_RDLOCK, ASTOBJ_UNLOCK, aji_client::buddies, aji_client::jid, and aji_client::p. 01627 { 01628 int res = 0; 01629 iks *removeiq = iks_new("iq"); 01630 iks *removequery = iks_new("query"); 01631 iks *removeitem = iks_new("item"); 01632 iks *send = iks_make_iq(IKS_TYPE_GET, "http://jabber.org/protocol/disco#items"); 01633 01634 if (client && removeiq && removequery && removeitem && send) { 01635 iks_insert_node(removeiq, removequery); 01636 iks_insert_node(removequery, removeitem); 01637 ASTOBJ_CONTAINER_TRAVERSE(&client->buddies, 1, { 01638 ASTOBJ_RDLOCK(iterator); 01639 /* For an aji_buddy, both AUTOPRUNE and AUTOREGISTER will never 01640 * be called at the same time */ 01641 if (ast_test_flag(iterator, AJI_AUTOPRUNE)) { 01642 res = iks_send(client->p, iks_make_s10n(IKS_TYPE_UNSUBSCRIBE, iterator->name, 01643 "GoodBye your status is no longer needed by Asterisk the Open Source PBX" 01644 " so I am no longer subscribing to your presence.\n")); 01645 res = iks_send(client->p, iks_make_s10n(IKS_TYPE_UNSUBSCRIBED, iterator->name, 01646 "GoodBye you are no longer in the asterisk config file so I am removing" 01647 " your access to my presence.\n")); 01648 iks_insert_attrib(removeiq, "from", client->jid->full); 01649 iks_insert_attrib(removeiq, "type", "set"); 01650 iks_insert_attrib(removequery, "xmlns", "jabber:iq:roster"); 01651 iks_insert_attrib(removeitem, "jid", iterator->name); 01652 iks_insert_attrib(removeitem, "subscription", "remove"); 01653 res = iks_send(client->p, removeiq); 01654 } else if (ast_test_flag(iterator, AJI_AUTOREGISTER)) { 01655 res = iks_send(client->p, iks_make_s10n(IKS_TYPE_SUBSCRIBE, iterator->name, 01656 "Greetings I am the Asterisk Open Source PBX and I want to subscribe to your presence\n")); 01657 ast_clear_flag(iterator, AJI_AUTOREGISTER); 01658 } 01659 ASTOBJ_UNLOCK(iterator); 01660 }); 01661 } else 01662 ast_log(LOG_ERROR, "Out of memory.\n"); 01663 if (removeiq) 01664 iks_delete(removeiq); 01665 if (removequery) 01666 iks_delete(removequery); 01667 if (removeitem) 01668 iks_delete(removeitem); 01669 if (send) 01670 iks_delete(send); 01671 ASTOBJ_CONTAINER_PRUNE_MARKED(&client->buddies, aji_buddy_destroy); 01672 }
|
|
|
Definition at line 1751 of file res_jabber.c. References aji_client_initialize(), aji_component_initialize(), AJI_DISCONNECTED, aji_client::authorized, aji_client::component, aji_client::p, aji_client::state, and aji_client::timeout. Referenced by aji_recv_loop(). 01752 { 01753 int res = 0; 01754 01755 if (client->state) 01756 client->state = AJI_DISCONNECTED; 01757 client->timeout=50; 01758 if (client->p) 01759 iks_parser_reset(client->p); 01760 if (client->authorized) 01761 client->authorized = 0; 01762 01763 if(client->component) 01764 res = aji_component_initialize(client); 01765 else 01766 res = aji_client_initialize(client); 01767 01768 return res; 01769 }
|
|
|
receive message loop.
Definition at line 1481 of file res_jabber.c. References aji_client_destroy(), AJI_CONNECTED, aji_reconnect(), ast_log(), ast_verbose(), ASTOBJ_REF, ASTOBJ_UNREF, LOG_WARNING, option_verbose, aji_client::p, aji_client::state, and aji_client::timeout. Referenced by aji_reload(). 01482 { 01483 struct aji_client *client = ASTOBJ_REF((struct aji_client *) data); 01484 int res = IKS_HOOK; 01485 do { 01486 if (res != IKS_OK) { 01487 while(res != IKS_OK) { 01488 if(option_verbose > 3) 01489 ast_verbose("JABBER: reconnecting.\n"); 01490 res = aji_reconnect(client); 01491 sleep(4); 01492 } 01493 } 01494 01495 res = iks_recv(client->p, 1); 01496 client->timeout--; 01497 if (res == IKS_HOOK) 01498 ast_log(LOG_WARNING, "JABBER: Got hook event.\n"); 01499 else if (res == IKS_NET_TLSFAIL) 01500 ast_log(LOG_WARNING, "JABBER: Failure in TLS.\n"); 01501 else if (client->timeout == 0 && client->state == AJI_CONNECTED) { 01502 res = iks_send_raw(client->p, " "); 01503 if(res == IKS_OK) 01504 client->timeout = 50; 01505 else 01506 ast_log(LOG_WARNING, "JABBER: Network Timeout\n"); 01507 } else if (res == IKS_NET_RWERR) 01508 ast_log(LOG_WARNING, "JABBER: socket read error\n"); 01509 } while (client); 01510 ASTOBJ_UNREF(client, aji_client_destroy); 01511 return 0; 01512 }
|
|
||||||||||||
|
Definition at line 662 of file res_jabber.c. References aji_client_destroy(), ast_aji_increment_mid(), ast_log(), ASTOBJ_REF, ASTOBJ_UNREF, aji_client::jid, LOG_ERROR, aji_client::mid, and aji_client::p. Referenced by aji_create_client(). 00663 { 00664 struct aji_client *client = ASTOBJ_REF((struct aji_client *) data); 00665 iks *iq = NULL, *presence = NULL, *x = NULL; 00666 00667 iq = iks_new("iq"); 00668 presence = iks_new("presence"); 00669 x = iks_new("x"); 00670 if (client && iq && presence && x) { 00671 if (!iks_find(pak->query, "remove")) { 00672 iks_insert_attrib(iq, "from", client->jid->full); 00673 iks_insert_attrib(iq, "to", pak->from->full); 00674 iks_insert_attrib(iq, "id", pak->id); 00675 iks_insert_attrib(iq, "type", "result"); 00676 iks_send(client->p, iq); 00677 00678 iks_insert_attrib(presence, "from", client->jid->full); 00679 iks_insert_attrib(presence, "to", pak->from->partial); 00680 iks_insert_attrib(presence, "id", client->mid); 00681 ast_aji_increment_mid(client->mid); 00682 iks_insert_attrib(presence, "type", "subscribe"); 00683 iks_insert_attrib(x, "xmlns", "vcard-temp:x:update"); 00684 iks_insert_node(presence, x); 00685 iks_send(client->p, presence); 00686 } 00687 } else { 00688 ast_log(LOG_ERROR, "Out of memory.\n"); 00689 } 00690 00691 if (iq) 00692 iks_delete(iq); 00693 if(presence) 00694 iks_delete(presence); 00695 if (x) 00696 iks_delete(x); 00697 ASTOBJ_UNREF(client, aji_client_destroy); 00698 return IKS_FILTER_EAT; 00699 }
|
|
||||||||||||
|
Definition at line 701 of file res_jabber.c. References aji_client_destroy(), ast_log(), ast_verbose(), ASTOBJ_CONTAINER_FIND, ASTOBJ_REF, ASTOBJ_UNREF, aji_client::buddies, error(), LOG_ERROR, aji_client::p, and aji_client::user. Referenced by aji_create_client(). 00702 { 00703 struct aji_client *client = ASTOBJ_REF((struct aji_client *) data); 00704 struct aji_buddy *buddy = NULL; 00705 char *node = NULL; 00706 00707 client = (struct aji_client *) data; 00708 00709 buddy = ASTOBJ_CONTAINER_FIND(&client->buddies, pak->from->partial); 00710 if (!buddy) { 00711 iks *iq = NULL, *query = NULL, *error = NULL, *notacceptable = NULL; 00712 00713 ast_verbose("Someone.... %s tried to register but they aren't allowed\n", pak->from->partial); 00714 iq = iks_new("iq"); 00715 query = iks_new("query"); 00716 error = iks_new("error"); 00717 notacceptable = iks_new("not-acceptable"); 00718 if(iq && query && error && notacceptable) { 00719 iks_insert_attrib(iq, "type", "error"); 00720 iks_insert_attrib(iq, "from", client->user); 00721 iks_insert_attrib(iq, "to", pak->from->full); 00722 iks_insert_attrib(iq, "id", pak->id); 00723 iks_insert_attrib(query, "xmlns", "jabber:iq:register"); 00724 iks_insert_attrib(error, "code" , "406"); 00725 iks_insert_attrib(error, "type", "modify"); 00726 iks_insert_attrib(notacceptable, "xmlns", "urn:ietf:params:xml:ns:xmpp-stanzas"); 00727 iks_insert_node(iq, query); 00728 iks_insert_node(iq, error); 00729 iks_insert_node(error, notacceptable); 00730 iks_send(client->p, iq); 00731 } else { 00732 ast_log(LOG_ERROR, "Out of memory.\n"); 00733 } 00734 if (iq) 00735 iks_delete(iq); 00736 if (query) 00737 iks_delete(query); 00738 if (error) 00739 iks_delete(error); 00740 if (notacceptable) 00741 iks_delete(notacceptable); 00742 } else if (!(node = iks_find_attrib(pak->query, "node"))) { 00743 iks *iq = NULL, *query = NULL, *instructions = NULL; 00744 char *explain = "Welcome to Asterisk - the Open Source PBX.\n"; 00745 iq = iks_new("iq"); 00746 query = iks_new("query"); 00747 instructions = iks_new("instructions"); 00748 if (iq && query && instructions && client) { 00749 iks_insert_attrib(iq, "from", client->user); 00750 iks_insert_attrib(iq, "to", pak->from->full); 00751 iks_insert_attrib(iq, "id", pak->id); 00752 iks_insert_attrib(iq, "type", "result"); 00753 iks_insert_attrib(query, "xmlns", "jabber:iq:register"); 00754 iks_insert_cdata(instructions, explain, 0); 00755 iks_insert_node(iq, query); 00756 iks_insert_node(query, instructions); 00757 iks_send(client->p, iq); 00758 } else { 00759 ast_log(LOG_ERROR, "Out of memory.\n"); 00760 } 00761 if (iq) 00762 iks_delete(iq); 00763 if (query) 00764 iks_delete(query); 00765 if (instructions) 00766 iks_delete(instructions); 00767 } 00768 ASTOBJ_UNREF(client, aji_client_destroy); 00769 return IKS_FILTER_EAT; 00770 }
|
|
|
Definition at line 2361 of file res_jabber.c. References aji_client_destroy(), AJI_DISCONNECTED, aji_load_config(), aji_recv_loop(), ast_log(), ast_pthread_create_background, ASTOBJ_CONTAINER_MARKALL, ASTOBJ_CONTAINER_PRUNE_MARKED, ASTOBJ_CONTAINER_TRAVERSE, ASTOBJ_RDLOCK, clients, and LOG_ERROR. Referenced by aji_do_reload(), load_module(), and reload(). 02362 { 02363 ASTOBJ_CONTAINER_MARKALL(&clients); 02364 if (!aji_load_config()) { 02365 ast_log(LOG_ERROR, "JABBER: Failed to load config.\n"); 02366 return 0; 02367 } 02368 ASTOBJ_CONTAINER_PRUNE_MARKED(&clients, aji_client_destroy); 02369 ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { 02370 ASTOBJ_RDLOCK(iterator); 02371 if(iterator->state == AJI_DISCONNECTED) { 02372 if (!iterator->thread) 02373 ast_pthread_create_background(&iterator->thread, NULL, aji_recv_loop, iterator); 02374 } else if (iterator->state == AJI_CONNECTING) 02375 aji_get_roster(iterator); 02376 ASTOBJ_UNLOCK(iterator); 02377 }); 02378 02379 return 1; 02380 }
|
|
||||||||||||
|
Dial plan function to send a message.
Definition at line 399 of file res_jabber.c. References ast_aji_get_client(), ast_aji_send(), ast_log(), ast_strdupa, LOG_ERROR, LOG_WARNING, s, and strsep(). Referenced by load_module(). 00400 { 00401 struct aji_client *client = NULL; 00402 00403 char *s = NULL, *sender = NULL, *recipient = NULL, *message = NULL; 00404 00405 if (!data) { 00406 ast_log(LOG_ERROR, "Out of memory\n"); 00407 return -1; 00408 } 00409 s = ast_strdupa((char *) data); 00410 if (s) { 00411 sender = strsep(&s, "|"); 00412 if (sender && (sender[0] != '\0')) { 00413 recipient = strsep(&s, "|"); 00414 if (recipient && (recipient[0] != '\0')) { 00415 message = s; 00416 } else { 00417 ast_log(LOG_ERROR, "Bad arguments \n"); 00418 return -1; 00419 } 00420 } 00421 } 00422 if (!(client = ast_aji_get_client(sender))) { 00423 ast_log(LOG_WARNING, "Could not find Sender.\n"); 00424 return -1; 00425 } 00426 if (strchr(recipient, '@') && message) 00427 ast_aji_send(client, recipient, message); 00428 return 0; 00429 }
|
|
||||||||||||||||||||||||
|
set presence of client.
Definition at line 1876 of file res_jabber.c. References ast_log(), LOG_ERROR, and aji_client::p. Referenced by aji_get_roster(), aji_handle_presence(), and aji_handle_subscribe(). 01877 { 01878 int res = 0; 01879 iks *presence = iks_make_pres(level, desc); 01880 iks *cnode = iks_new("c"); 01881 iks *priority = iks_new("priority"); 01882 01883 iks_insert_cdata(priority, "0", 1); 01884 if (presence && cnode && client) { 01885 if(to) 01886 iks_insert_attrib(presence, "to", to); 01887 if(from) 01888 iks_insert_attrib(presence, "from", from); 01889 iks_insert_attrib(cnode, "node", "http://www.asterisk.org/xmpp/client/caps"); 01890 iks_insert_attrib(cnode, "ver", "asterisk-xmpp"); 01891 iks_insert_attrib(cnode, "ext", "voice-v1"); 01892 iks_insert_attrib(cnode, "xmlns", "http://jabber.org/protocol/caps"); 01893 iks_insert_node(presence, cnode); 01894 res = iks_send(client->p, presence); 01895 } else 01896 ast_log(LOG_ERROR, "Out of memory.\n"); 01897 if (cnode) 01898 iks_delete(cnode); 01899 if (presence) 01900 iks_delete(presence); 01901 }
|
|
||||||||||||||||
|
show client status.
Definition at line 1952 of file res_jabber.c. References AJI_CONNECTED, AJI_CONNECTING, AJI_DISCONNECTED, ast_cli(), ASTOBJ_CONTAINER_TRAVERSE, ASTOBJ_RDLOCK, and clients. 01953 { 01954 char *status; 01955 int count = 0; 01956 ast_cli(fd, "Jabber Users and their status:\n"); 01957 ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { 01958 ASTOBJ_RDLOCK(iterator); 01959 count++; 01960 switch (iterator->state) { 01961 case AJI_DISCONNECTED: 01962 status = "Disconnected"; 01963 break; 01964 case AJI_CONNECTING: 01965 status = "Connecting"; 01966 break; 01967 case AJI_CONNECTED: 01968 status = "Connected"; 01969 break; 01970 default: 01971 status = "Unknown"; 01972 } 01973 ast_cli(fd, " User: %s - %s\n", iterator->user, status); 01974 ASTOBJ_UNLOCK(iterator); 01975 }); 01976 ast_cli(fd, "----\n"); 01977 ast_cli(fd, " Number of users: %d\n", count); 01978 return RESULT_SUCCESS; 01979 }
|
|
||||||||||||
|
Dial plan function status(). puts the status of watched user into a channel variable.
Definition at line 334 of file res_jabber.c. References aji_find_resource(), ast_aji_get_client(), ast_log(), ast_strdupa, ASTOBJ_CONTAINER_FIND, aji_client::buddies, LOG_ERROR, LOG_NOTICE, LOG_WARNING, pbx_builtin_setvar_helper(), aji_resource::resource, aji_buddy::resources, s, aji_resource::status, and strsep(). Referenced by load_module(). 00335 { 00336 struct aji_client *client = NULL; 00337 struct aji_buddy *buddy = NULL; 00338 struct aji_resource *r = NULL; 00339 char *s = NULL, *sender = NULL, *jid = NULL, *screenname = NULL, *resource = NULL, *variable = NULL; 00340 int stat = 7; 00341 char status[2]; 00342 if (data) { 00343 s = ast_strdupa((char *) data); 00344 if (s) { 00345 sender = strsep(&s, "|"); 00346 if (sender && (sender[0] != '\0')) { 00347 jid = strsep(&s, "|"); 00348 if (jid && (jid[0] != '\0')) { 00349 variable = s; 00350 } else { 00351 ast_log(LOG_ERROR, "Bad arguments\n"); 00352 return -1; 00353 } 00354 } 00355 } 00356 } else { 00357 ast_log(LOG_ERROR, "Out of memory\n"); 00358 return -1; 00359 } 00360 00361 if(!strchr(jid, '/')) { 00362 resource = NULL; 00363 } else { 00364 screenname = strsep(&jid, "/"); 00365 resource = jid; 00366 } 00367 client = ast_aji_get_client(sender); 00368 if (!client) { 00369 ast_log(LOG_WARNING, "Could not find Connection.\n"); 00370 return -1; 00371 } 00372 if(!&client->buddies) { 00373 ast_log(LOG_WARNING, "No buddies for connection.\n"); 00374 return -1; 00375 } 00376 buddy = ASTOBJ_CONTAINER_FIND(&client->buddies, (resource)?screenname:jid); 00377 if (!buddy) { 00378 ast_log(LOG_WARNING, "Could not find Buddy in list.\n"); 00379 return -1; 00380 } 00381 r = aji_find_resource(buddy, resource); 00382 if(!r && buddy->resources) { 00383 r = buddy->resources; 00384 } 00385 if(!r){ 00386 ast_log(LOG_NOTICE, "Resource %s of buddy %s not found \n", resource, screenname); 00387 } 00388 stat = r->status; 00389 sprintf(status, "%d", stat); 00390 pbx_builtin_setvar_helper(chan, variable, status); 00391 return 0; 00392 }
|
|
||||||||||||||||
|
send test message for debugging.
Definition at line 1986 of file res_jabber.c. References ast_aji_send(), ast_cli(), ast_verbose(), ASTOBJ_CONTAINER_FIND, ASTOBJ_CONTAINER_TRAVERSE, ASTOBJ_RDLOCK, ASTOBJ_UNLOCK, aji_client::buddies, aji_resource::cap, clients, aji_resource::description, aji_version::jingle, name, aji_resource::next, aji_capabilities::node, aji_version::parent, aji_resource::priority, aji_resource::resource, RESULT_FAILURE, RESULT_SHOWUSAGE, S_OR, aji_resource::status, and aji_version::version. 01987 { 01988 struct aji_client *client; 01989 struct aji_resource *resource; 01990 const char *name = "asterisk"; 01991 struct aji_message *tmp; 01992 01993 if (argc > 3) 01994 return RESULT_SHOWUSAGE; 01995 else if (argc == 3) 01996 name = argv[2]; 01997 01998 if (!(client = ASTOBJ_CONTAINER_FIND(&clients, name))) { 01999 ast_cli(fd, "Unable to find client '%s'!\n", name); 02000 return RESULT_FAILURE; 02001 } 02002 02003 /* XXX Does Matt really want everyone to use his personal address for tests? */ /* XXX yes he does */ 02004 ast_aji_send(client, "mogorman@astjab.org", "blahblah"); 02005 ASTOBJ_CONTAINER_TRAVERSE(&client->buddies, 1, { 02006 ASTOBJ_RDLOCK(iterator); 02007 ast_verbose("User: %s\n", iterator->name); 02008 for (resource = iterator->resources; resource; resource = resource->next) { 02009 ast_verbose("Resource: %s\n", resource->resource); 02010 if(resource->cap) { 02011 ast_verbose(" client: %s\n", resource->cap->parent->node); 02012 ast_verbose(" version: %s\n", resource->cap->version); 02013 ast_verbose(" Jingle Capable: %d\n", resource->cap->jingle); 02014 } 02015 ast_verbose(" Priority: %d\n", resource->priority); 02016 ast_verbose(" Status: %d\n", resource->status); 02017 ast_verbose(" Message: %s\n", S_OR(resource->description,"")); 02018 } 02019 ASTOBJ_UNLOCK(iterator); 02020 }); 02021 ast_verbose("\nOooh a working message stack!\n"); 02022 AST_LIST_LOCK(&client->messages); 02023 AST_LIST_TRAVERSE(&client->messages, tmp, list) { 02024 ast_verbose(" Message from: %s with id %s @ %s %s\n",tmp->from, S_OR(tmp->id,""), ctime(&tmp->arrived), S_OR(tmp->message, "")); 02025 } 02026 AST_LIST_UNLOCK(&client->messages); 02027 ASTOBJ_UNREF(client, aji_client_destroy); 02028 02029 return RESULT_SUCCESS; 02030 }
|
|
||||||||||||||||||||
|
create a chatroom.
Definition at line 1397 of file res_jabber.c. References ast_aji_increment_mid(), ast_log(), LOG_ERROR, aji_client::mid, and aji_client::p. 01398 { 01399 int res = 0; 01400 iks *iq = NULL; 01401 iq = iks_new("iq"); 01402 if (iq && client) { 01403 iks_insert_attrib(iq, "type", "get"); 01404 iks_insert_attrib(iq, "to", server); 01405 iks_insert_attrib(iq, "id", client->mid); 01406 ast_aji_increment_mid(client->mid); 01407 iks_send(client->p, iq); 01408 } else 01409 ast_log(LOG_ERROR, "Out of memory.\n"); 01410 return res; 01411 }
|
|
|
disconnect from jabber server.
Definition at line 1858 of file res_jabber.c. References aji_client_destroy(), ast_verbose(), ASTOBJ_UNREF, option_verbose, aji_client::p, and VERBOSE_PREFIX_3. Referenced by unload_module(). 01859 { 01860 if (client) { 01861 if (option_verbose > 3) 01862 ast_verbose(VERBOSE_PREFIX_3 "JABBER: Disconnecting\n"); 01863 iks_disconnect(client->p); 01864 iks_parser_delete(client->p); 01865 ASTOBJ_UNREF(client, aji_client_destroy); 01866 } 01867 01868 return 1; 01869 }
|
|
|
grab a aji_client structure by label name.
Definition at line 2297 of file res_jabber.c. References ASTOBJ_CONTAINER_FIND, ASTOBJ_CONTAINER_FIND_FULL, clients, and aji_client::user. Referenced by aji_send_exec(), aji_status_exec(), gtalk_create_member(), jingle_create_member(), and manager_jabber_send(). 02298 { 02299 struct aji_client *client = NULL; 02300 02301 client = ASTOBJ_CONTAINER_FIND(&clients, name); 02302 if (!client && !strchr(name, '@')) 02303 client = ASTOBJ_CONTAINER_FIND_FULL(&clients, name, user,,, strcasecmp); 02304 return client; 02305 }
|
|
|
Definition at line 2307 of file res_jabber.c. References clients. 02308 { 02309 return &clients; 02310 }
|
|
|
increments the mid field for messages and other events.
Definition at line 1519 of file res_jabber.c. Referenced by aji_act_hook(), aji_handle_presence(), aji_register_approve_handler(), ast_aji_create_chat(), ast_aji_invite_chat(), gtalk_action(), gtalk_digit(), gtalk_invite_response(), jingle_accept_call(), jingle_action(), jingle_digit(), and jingle_transmit_invite(). 01520 { 01521 int i = 0; 01522 01523 for (i = strlen(mid) - 1; i >= 0; i--) { 01524 if (mid[i] != 'z') { 01525 mid[i] = mid[i] + 1; 01526 i = 0; 01527 } else 01528 mid[i] = 'a'; 01529 } 01530 }
|
|
||||||||||||||||||||
|
invite to a chatroom.
Definition at line 1446 of file res_jabber.c. References ast_aji_increment_mid(), ast_log(), LOG_ERROR, aji_client::mid, and aji_client::p. 01447 { 01448 int res = 0; 01449 iks *invite, *body, *namespace; 01450 01451 invite = iks_new("message"); 01452 body = iks_new("body"); 01453 namespace = iks_new("x"); 01454 if (client && invite && body && namespace) { 01455 iks_insert_attrib(invite, "to", user); 01456 iks_insert_attrib(invite, "id", client->mid); 01457 ast_aji_increment_mid(client->mid); 01458 iks_insert_cdata(body, message, 0); 01459 iks_insert_attrib(namespace, "xmlns", "jabber:x:conference"); 01460 iks_insert_attrib(namespace, "jid", room); 01461 iks_insert_node(invite, body); 01462 iks_insert_node(invite, namespace); 01463 res = iks_send(client->p, invite); 01464 } else 01465 ast_log(LOG_ERROR, "Out of memory.\n"); 01466 if (body) 01467 iks_delete(body); 01468 if (namespace) 01469 iks_delete(namespace); 01470 if (invite) 01471 iks_delete(invite); 01472 return res; 01473 }
|
|
||||||||||||
|
join a chatroom.
Definition at line 1418 of file res_jabber.c. References ast_log(), LOG_ERROR, aji_client::p, and aji_resource::priority. 01419 { 01420 int res = 0; 01421 iks *presence = NULL, *priority = NULL; 01422 presence = iks_new("presence"); 01423 priority = iks_new("priority"); 01424 if (presence && priority && client) { 01425 iks_insert_cdata(priority, "0", 1); 01426 iks_insert_attrib(presence, "to", room); 01427 iks_insert_node(presence, priority); 01428 res = iks_send(client->p, presence); 01429 iks_insert_cdata(priority, "5", 1); 01430 iks_insert_attrib(presence, "to", room); 01431 res = iks_send(client->p, presence); 01432 } else 01433 ast_log(LOG_ERROR, "Out of memory.\n"); 01434 if (presence) 01435 iks_delete(presence); 01436 if (priority) 01437 iks_delete(priority); 01438 return res; 01439 }
|
|
||||||||||||||||
|
sends messages.
Definition at line 1373 of file res_jabber.c. References AJI_CONNECTED, ast_log(), aji_client::jid, LOG_ERROR, LOG_WARNING, aji_client::p, and aji_client::state. Referenced by aji_send_exec(), aji_test(), and manager_jabber_send(). 01374 { 01375 int res = 0; 01376 iks *message_packet = NULL; 01377 if (client->state == AJI_CONNECTED) { 01378 message_packet = iks_make_msg(IKS_TYPE_CHAT, address, message); 01379 if (message_packet) { 01380 iks_insert_attrib(message_packet, "from", client->jid->full); 01381 res = iks_send(client->p, message_packet); 01382 } else { 01383 ast_log(LOG_ERROR, "Out of memory.\n"); 01384 } 01385 if (message_packet) 01386 iks_delete(message_packet); 01387 } else 01388 ast_log(LOG_WARNING, "JABBER: Not connected can't send\n"); 01389 return 1; 01390 }
|
|
||||||||||||||||||||||||||||
|
|
|
|
Definition at line 283 of file res_jabber.c. Referenced by aji_handle_presence(). 00284 { 00285 if (iks_find_with_attrib(node, "c", "node", "http://www.google.com/xmpp/client/caps")) 00286 return 1; 00287 return 0; 00288 }
|
|
||||||||||||||||
|
Definition at line 307 of file res_jabber.c. References ast_sha1_hash(). Referenced by aji_act_hook(). 00308 { 00309 iks *x, *y; 00310 x = iks_new("iq"); 00311 iks_insert_attrib(x, "type", "set"); 00312 y = iks_insert(x, "query"); 00313 iks_insert_attrib(y, "xmlns", IKS_NS_AUTH); 00314 iks_insert_cdata(iks_insert(y, "username"), id->user, 0); 00315 iks_insert_cdata(iks_insert(y, "resource"), id->resource, 0); 00316 if (sid) { 00317 char buf[41]; 00318 char sidpass[100]; 00319 snprintf(sidpass, sizeof(sidpass), "%s%s", sid, pass); 00320 ast_sha1_hash(buf, sidpass); 00321 iks_insert_cdata(iks_insert(y, "digest"), buf, 0); 00322 } else { 00323 iks_insert_cdata(iks_insert(y, "password"), pass, 0); 00324 } 00325 return x; 00326 }
|
|
|
Definition at line 2405 of file res_jabber.c. References aji_cli, aji_reload(), aji_send_exec(), aji_status_exec(), ajisend_descrip, ajisend_synopsis, ajistatus_descrip, ajistatus_synopsis, app_ajisend, app_ajistatus, ast_cli_register_multiple(), ast_log(), ast_manager_register2(), AST_MODULE_LOAD_DECLINE, ast_register_application(), ASTOBJ_CONTAINER_INIT, clients, EVENT_FLAG_SYSTEM, LOG_NOTICE, manager_jabber_send(), and mandescr_jabber_send. 02406 { 02407 ASTOBJ_CONTAINER_INIT(&clients); 02408 if(!aji_reload()) 02409 return AST_MODULE_LOAD_DECLINE; 02410 ast_manager_register2("JabberSend", EVENT_FLAG_SYSTEM, manager_jabber_send, 02411 "Sends a message to a Jabber Client", mandescr_jabber_send); 02412 ast_register_application(app_ajisend, aji_send_exec, ajisend_synopsis, ajisend_descrip); 02413 ast_register_application(app_ajistatus, aji_status_exec, ajistatus_synopsis, ajistatus_descrip); 02414 ast_cli_register_multiple(aji_cli, sizeof(aji_cli) / sizeof(struct ast_cli_entry)); 02415 02416 ast_log(LOG_NOTICE, "res_jabber.so loaded.\n"); 02417 return 0; 02418 }
|
|
||||||||||||
|
Send a Jabber Message via call from the Manager.
Definition at line 2320 of file res_jabber.c. References ast_aji_get_client(), ast_aji_send(), ast_strlen_zero(), astman_append(), astman_get_header(), astman_send_ack(), astman_send_error(), and s. Referenced by load_module(). 02321 { 02322 struct aji_client *client = NULL; 02323 const char *id = astman_get_header(m,"ActionID"); 02324 const char *jabber = astman_get_header(m,"Jabber"); 02325 const char *screenname = astman_get_header(m,"ScreenName"); 02326 const char *message = astman_get_header(m,"Message"); 02327 02328 if (ast_strlen_zero(jabber)) { 02329 astman_send_error(s, m, "No transport specified"); 02330 return 0; 02331 } 02332 if (ast_strlen_zero(screenname)) { 02333 astman_send_error(s, m, "No ScreenName specified"); 02334 return 0; 02335 } 02336 if (ast_strlen_zero(message)) { 02337 astman_send_error(s, m, "No Message specified"); 02338 return 0; 02339 } 02340 02341 astman_send_ack(s, m, "Attempting to send Jabber Message"); 02342 client = ast_aji_get_client(jabber); 02343 if (!client) { 02344 astman_send_error(s, m, "Could not find Sender"); 02345 return 0; 02346 } 02347 if (strchr(screenname, '@') && message){ 02348 ast_aji_send(client, screenname, message); 02349 if (!ast_strlen_zero(id)) 02350 astman_append(s, "ActionID: %s\r\n",id); 02351 astman_append(s, "Response: Success\r\n"); 02352 return 0; 02353 } 02354 if (!ast_strlen_zero(id)) 02355 astman_append(s, "ActionID: %s\r\n",id); 02356 astman_append(s, "Response: Failure\r\n"); 02357 return 0; 02358 }
|
|
|
Definition at line 2420 of file res_jabber.c. References aji_reload(). 02421 { 02422 aji_reload(); 02423 return 0; 02424 }
|
|
|
Definition at line 2382 of file res_jabber.c. References aji_cli, AJI_DISCONNECTED, app_ajisend, app_ajistatus, ast_aji_disconnect(), ast_cli_unregister_multiple(), ast_manager_unregister(), ast_unregister_application(), ast_verbose(), ASTOBJ_CONTAINER_TRAVERSE, ASTOBJ_RDLOCK, ASTOBJ_UNLOCK, clients, option_verbose, and VERBOSE_PREFIX_3. 02383 { 02384 ast_cli_unregister_multiple(aji_cli, sizeof(aji_cli) / sizeof(struct ast_cli_entry)); 02385 ast_unregister_application(app_ajisend); 02386 ast_unregister_application(app_ajistatus); 02387 ast_manager_unregister("JabberSend"); 02388 ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { 02389 ASTOBJ_RDLOCK(iterator); 02390 if (option_verbose > 2) 02391 ast_verbose(VERBOSE_PREFIX_3 "JABBER: %s\n", iterator->name); 02392 iterator->state = AJI_DISCONNECTED; 02393 ast_aji_disconnect(iterator); 02394 pthread_join(iterator->thread, NULL); 02395 ASTOBJ_UNLOCK(iterator); 02396 }); 02397 02398 ASTOBJ_CONTAINER_DESTROYALL(&clients, aji_client_destroy); 02399 ASTOBJ_CONTAINER_DESTROY(&clients); 02400 02401 ast_log(LOG_NOTICE, "res_jabber unloaded.\n"); 02402 return 0; 02403 }
|
|
|
Definition at line 117 of file res_jabber.c. Referenced by load_module(), and unload_module(). |
|
|
Initial value: "JabberSend(Jabber,ScreenName,Message)\n" " Jabber - Client or transport Asterisk uses to connect to Jabber\n" " ScreenName - User Name to message.\n" " Message - Message to be sent to the buddy\n" Definition at line 143 of file res_jabber.c. Referenced by load_module(). |
|
|
Definition at line 141 of file res_jabber.c. Referenced by load_module(). |
|
|
Definition at line 153 of file res_jabber.c. Referenced by load_module(). |
|
|
Definition at line 151 of file res_jabber.c. Referenced by load_module(). |
|
|
Definition at line 139 of file res_jabber.c. Referenced by load_module(), and unload_module(). |
|
|
Definition at line 149 of file res_jabber.c. Referenced by load_module(), and unload_module(). |
|
|
Definition at line 163 of file res_jabber.c. Referenced by aji_find_version(), and ast_request(). |
|
|
Definition at line 161 of file res_jabber.c. Referenced by aji_create_client(), aji_do_debug(), aji_no_debug(), aji_reload(), aji_show_clients(), aji_test(), ast_aji_get_client(), ast_aji_get_clients(), gtalk_load_config(), jingle_load_config(), load_module(), and unload_module(). |
|
|
Initial value: "Usage: jabber debug\n" " Enables dumping of Jabber packets for debugging purposes.\n" Definition at line 100 of file res_jabber.c. |
|
|
Global flags, initialized to default values.
Definition at line 166 of file res_jabber.c. |
|
|
Definition at line 2312 of file res_jabber.c. Referenced by load_module(). |
|
|
Initial value: "Usage: jabber debug off\n" " Disables dumping of Jabber packets for debugging purposes.\n" Definition at line 104 of file res_jabber.c. |
|
|
Initial value: "Usage: jabber reload\n" " Enables reloading of Jabber module.\n" Definition at line 108 of file res_jabber.c. |
|
|
Initial value: "Usage: jabber test [client]\n" " Sends test message for debugging purposes. A specific client\n" " as configured in jabber.conf can be optionally specified.\n" Definition at line 112 of file res_jabber.c. |