/** * init module function */ static int mod_init(void) { bind_presence_t bind_presence; presence_api_t pres; if(passive_mode==1) return 0; if(register_mi_mod(exports.name, mi_cmds)!=0) { LM_ERR("failed to register MI commands\n"); return -1; } LM_DBG("db_url=%s/%d/%p\n",ZSW(db_url.s),db_url.len, db_url.s); /* bind the SL API */ if (sl_load_api(&slb)!=0) { LM_ERR("cannot bind to SL API\n"); return -1; } bind_presence= (bind_presence_t)find_export("bind_presence", 1,0); if (!bind_presence) { LM_ERR("Can't bind presence\n"); return -1; } if (bind_presence(&pres) < 0) { LM_ERR("Can't bind to presence module\n"); return -1; } pres_get_sphere= pres.get_sphere; pres_add_event= pres.add_event; pres_update_watchers= pres.update_watchers_status; pres_contains_event= pres.contains_event; pres_get_presentity= pres.get_presentity; pres_free_presentity= pres.free_presentity; if (pres_add_event == NULL || pres_update_watchers== NULL) { LM_ERR("Can't import add_event\n"); return -1; } if(xml_add_events()< 0) { LM_ERR("adding xml events\n"); return -1; } if(force_active== 0) { /* binding to mysql module */ if (db_bind_mod(&db_url, &pxml_dbf)) { LM_ERR("Database module not found\n"); return -1; } if (!DB_CAPABILITY(pxml_dbf, DB_CAP_ALL)) { LM_ERR("Database module does not implement all functions" " needed by the module\n"); return -1; } pxml_db = pxml_dbf.init(&db_url); if (!pxml_db) { LM_ERR("while connecting to database\n"); return -1; } if(db_check_table_version(&pxml_dbf, pxml_db, &xcap_table, S_TABLE_VERSION) < 0) { LM_ERR("error during table version check.\n"); return -1; } if(!integrated_xcap_server ) { xcap_api_t xcap_api; bind_xcap_t bind_xcap; /* bind xcap */ bind_xcap= (bind_xcap_t)find_export("bind_xcap", 1, 0); if (!bind_xcap) { LM_ERR("Can't bind xcap_client\n"); return -1; } if (bind_xcap(&xcap_api) < 0) { LM_ERR("Can't bind xcap_api\n"); return -1; } xcap_GetNewDoc= xcap_api.getNewDoc; if(xcap_GetNewDoc== NULL) { LM_ERR("can't import get_elem from xcap_client module\n"); return -1; } if(xcap_api.register_xcb(PRES_RULES, xcap_doc_updated)< 0) { LM_ERR("registering xcap callback function\n"); return -1; } } } if(shm_copy_xcap_list()< 0) { LM_ERR("copying xcap server list in share memory\n"); return -1; } if(pxml_db) pxml_dbf.close(pxml_db); pxml_db = NULL; return 0; }
/** * init module function */ static int mod_init(void) { bind_presence_t bind_presence; presence_api_t pres; bind_xcap_t bind_xcap; xcap_api_t xcap_api; /* load XCAP API */ bind_xcap = (bind_xcap_t)find_export("bind_xcap", 1, 0); if (!bind_xcap) { LM_ERR("Can't bind xcap\n"); return -1; } if (bind_xcap(&xcap_api) < 0) { LM_ERR("Can't bind xcap\n"); return -1; } integrated_xcap_server = xcap_api.integrated_server; db_url = xcap_api.db_url; xcap_table = xcap_api.xcap_table; normalizeSipUri = xcap_api.normalize_sip_uri; xcapParseUri = xcap_api.parse_xcap_uri; xcapDbGetDoc = xcap_api.get_xcap_doc; if(force_active==0) { if ( verify_db() < 0 ) return -1; } /* load SL API */ if(load_sig_api(&xml_sigb)==-1) { LM_ERR("can't load signaling functions\n"); return -1; } bind_presence= (bind_presence_t)find_export("bind_presence", 1,0); if (!bind_presence) { LM_ERR("Can't bind presence\n"); return -1; } if (bind_presence(&pres) < 0) { LM_ERR("Can't bind module pua\n"); return -1; } pres_get_sphere= pres.get_sphere; pres_add_event= pres.add_event; pres_update_watchers= pres.update_watchers_status; if (pres_add_event == NULL || pres_update_watchers== NULL) { LM_ERR("Can't import add_event\n"); return -1; } if(xml_add_events()< 0) { LM_ERR("adding xml events\n"); return -1; } if(pres_rules_auid.s) { pres_rules_auid.len = strlen(pres_rules_auid.s); if (pres_rules_auid.len == IETF_PRES_RULES_AUID_LEN && strncmp(pres_rules_auid.s, IETF_PRES_RULES_AUID, IETF_PRES_RULES_AUID_LEN) == 0) { LM_INFO("using IETF mode for pres-rules\n"); pres_rules_doc_id = PRES_RULES; } if (pres_rules_auid.len == OMA_PRES_RULES_AUID_LEN && strncmp(pres_rules_auid.s, OMA_PRES_RULES_AUID, OMA_PRES_RULES_AUID_LEN) == 0) { LM_INFO("using OMA mode for pres-rules\n"); pres_rules_doc_id = OMA_PRES_RULES; } else { LM_ERR("unrecognized AUID for pres-rules: %.*s\n", pres_rules_auid.len, pres_rules_auid.s); return -1; } } if(force_active== 0 && !integrated_xcap_server ) { xcap_client_api_t xcap_client_api; bind_xcap_client_t bind_xcap_client; /* bind xcap */ bind_xcap_client = (bind_xcap_client_t)find_export("bind_xcap_client", 1, 0); if (!bind_xcap_client) { LM_ERR("Can't bind xcap_client\n"); return -1; } if (bind_xcap_client(&xcap_client_api) < 0) { LM_ERR("Can't bind xcap_client_api\n"); return -1; } xcap_GetNewDoc= xcap_client_api.getNewDoc; if(xcap_GetNewDoc== NULL) { LM_ERR("can't import getNewDoc from xcap_client module\n"); return -1; } if(xcap_client_api.register_xcb(pres_rules_doc_id, xcap_doc_updated) < 0) { LM_ERR("registering xcap callback function\n"); return -1; } if(pres_rules_filename.s) pres_rules_filename.len = strlen(pres_rules_filename.s); } if(shm_copy_xcap_list()< 0) { LM_ERR("copying xcap server list in share memory\n"); return -1; } if(pxml_db) pxml_dbf.close(pxml_db); pxml_db = NULL; return 0; }