--- res_pjsip_publish_asterisk.c.orig 2015-02-19 12:10:39.619628575 -0600 +++ res_pjsip_publish_asterisk.c 2015-02-19 11:58:39.773331226 -0600 @@ -856,22 +856,27 @@ static int load_module(void) { + struct ast_sorcery *sorcery; + CHECK_PJSIP_PUBSUB_MODULE_LOADED(); - ast_sorcery_apply_default(ast_sip_get_sorcery(), "asterisk-publication", "config", "pjsip.conf,criteria=type=asterisk-publication"); + sorcery = ast_sip_get_sorcery(); + + ast_sorcery_apply_config(sorcery, "res_pjsip_publish_asterisk"); + ast_sorcery_apply_default(sorcery, "asterisk-publication", "config", "pjsip.conf,criteria=type=asterisk-publication"); - if (ast_sorcery_object_register(ast_sip_get_sorcery(), "asterisk-publication", asterisk_publication_config_alloc, NULL, NULL)) { + if (ast_sorcery_object_register(sorcery, "asterisk-publication", asterisk_publication_config_alloc, NULL, NULL)) { return AST_MODULE_LOAD_DECLINE; } - ast_sorcery_object_field_register(ast_sip_get_sorcery(), "asterisk-publication", "type", "", OPT_NOOP_T, 0, 0); - ast_sorcery_object_field_register(ast_sip_get_sorcery(), "asterisk-publication", "devicestate_publish", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct asterisk_publication_config, devicestate_publish)); - ast_sorcery_object_field_register(ast_sip_get_sorcery(), "asterisk-publication", "mailboxstate_publish", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct asterisk_publication_config, mailboxstate_publish)); - ast_sorcery_object_field_register(ast_sip_get_sorcery(), "asterisk-publication", "device_state", "no", OPT_BOOL_T, 1, FLDSET(struct asterisk_publication_config, device_state)); - ast_sorcery_object_field_register_custom(ast_sip_get_sorcery(), "asterisk-publication", "device_state_filter", "", regex_filter_handler, NULL, NULL, 0, 0); - ast_sorcery_object_field_register(ast_sip_get_sorcery(), "asterisk-publication", "mailbox_state", "no", OPT_BOOL_T, 1, FLDSET(struct asterisk_publication_config, mailbox_state)); - ast_sorcery_object_field_register_custom(ast_sip_get_sorcery(), "asterisk-publication", "mailbox_state_filter", "", regex_filter_handler, NULL, NULL, 0, 0); - ast_sorcery_reload_object(ast_sip_get_sorcery(), "asterisk-publication"); + ast_sorcery_object_field_register(sorcery, "asterisk-publication", "type", "", OPT_NOOP_T, 0, 0); + ast_sorcery_object_field_register(sorcery, "asterisk-publication", "devicestate_publish", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct asterisk_publication_config, devicestate_publish)); + ast_sorcery_object_field_register(sorcery, "asterisk-publication", "mailboxstate_publish", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct asterisk_publication_config, mailboxstate_publish)); + ast_sorcery_object_field_register(sorcery, "asterisk-publication", "device_state", "no", OPT_BOOL_T, 1, FLDSET(struct asterisk_publication_config, device_state)); + ast_sorcery_object_field_register_custom(sorcery, "asterisk-publication", "device_state_filter", "", regex_filter_handler, NULL, NULL, 0, 0); + ast_sorcery_object_field_register(sorcery, "asterisk-publication", "mailbox_state", "no", OPT_BOOL_T, 1, FLDSET(struct asterisk_publication_config, mailbox_state)); + ast_sorcery_object_field_register_custom(sorcery, "asterisk-publication", "mailbox_state_filter", "", regex_filter_handler, NULL, NULL, 0, 0); + ast_sorcery_reload_object(sorcery, "asterisk-publication"); if (ast_sip_register_publish_handler(&asterisk_devicestate_publication_handler)) { ast_log(LOG_WARNING, "Unable to register event publication handler %s\n", @@ -905,12 +910,14 @@ return AST_MODULE_LOAD_SUCCESS; } +/* static int reload_module(void) { ast_sorcery_reload_object(ast_sip_get_sorcery(), "asterisk-publication"); asterisk_publication_send_refresh(); return 0; } +*/ static int unload_module(void) { @@ -923,7 +930,6 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP Asterisk Event PUBLISH Support", .load = load_module, - .reload = reload_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND, );