int sal_publish(SalOp *op, const char *from, const char *to, SalPresenceStatus presence_mode){ osip_message_t *pub; int i; char buf[1024]; const char *route=sal_op_get_route(op); mk_presence_body (presence_mode, from, buf, sizeof (buf), presence_style); i = eXosip_build_publish(&pub,to, from, NULL, "presence", "600", presence_style ? "application/xpidf+xml" : "application/pidf+xml", buf); if (i<0){ ms_warning("Failed to build publish request."); return -1; } if (route) sal_message_add_route(pub,route); eXosip_lock(); i = eXosip_publish(pub, to); /* should update the sip-if-match parameter from sip-etag from last 200ok of PUBLISH */ eXosip_unlock(); if (i<0){ ms_message("Failed to send publish request."); return -1; } sal_add_other(sal_op_get_sal(op),op,pub); return 0; }
OWPL_RESULT owplPresencePublish(OWPL_LINE hLine, const int Online, const char * szStatus, OWPL_PUB *hPub) { char UriBuf[100]; char MsgBodyBuf[500]; char ProxyBuf[100]; int n = sizeof(UriBuf); int i; phVLine * vl = NULL; OWSIPAccount account ; // SPIKE_SPIKE_SIP_SIMPLE if (phcfg.pim_disabled) { return OWPL_RESULT_SUCCESS; } account = owplLineSipAccountGet (hLine) ; if (account <= 0) { return OWPL_RESULT_INVALID_ARGS ; } // save infos for later user from a timer event if((vl = ph_valid_vlid(hLine)) != NULL) { vl->publishInfo.onlineState = Online; if (szStatus) { vl->publishInfo.szStatus = strdup(szStatus); } else { vl->publishInfo.szStatus = strdup(""); } vl->publishInfo.hPub = hPub; // nine minutes timeout i.e. 540s vl->publishInfo.publishTimeout = 540; vl->publishInfo.lastPublishTime = time(0); } else { return OWPL_RESULT_FAILURE; } buildPidfPayload(hLine, MsgBodyBuf, sizeof(MsgBodyBuf), Online, szStatus); n = sizeof(UriBuf); owplLineGetUri(hLine, UriBuf, &n); n = sizeof(ProxyBuf); owplLineGetProxy(hLine, ProxyBuf, &n); eXosip_lock(); i = eXosip_publish(account, UriBuf, UriBuf, ProxyBuf, 0, PRESENCE_CONTENT_TYPE, MsgBodyBuf); eXosip_unlock(); if (i != 0) { return OWPL_RESULT_FAILURE; } return OWPL_RESULT_SUCCESS; }
MY_DLLEXPORT OWPL_RESULT owplPresencePublish(OWPL_LINE hLine, const int Online, const char * szStatus, OWPL_PUB *hPub) { char UriBuf[100]; char MsgBodyBuf[500]; char ProxyBuf[100]; int n = sizeof(UriBuf); int i; phVLine * vl = NULL; // SPIKE_SPIKE_SIP_SIMPLE if (phcfg.pim_disabled) { return OWPL_RESULT_SUCCESS; } // save infos for later user from a timer event if((vl = ph_valid_vlid(hLine)) != NULL) { vl->publishInfo.onlineState = Online; if(szStatus != NULL) { vl->publishInfo.szStatus = strdup(szStatus); } vl->publishInfo.hPub = hPub; // nine minutes timeout i.e. 540s vl->publishInfo.publishTimeout = 540; vl->publishInfo.lastPublishTime = time(0); } else { return OWPL_RESULT_FAILURE; } owplLineGetUri(hLine, UriBuf, &n); snprintf(MsgBodyBuf, sizeof(MsgBodyBuf), PUBLISH_MSG_TEMPLATE, UriBuf, Online ? "open" : "close", szStatus, UriBuf); n = sizeof(ProxyBuf); owplLineGetProxy(hLine, ProxyBuf, &n); eXosip_lock(); i = eXosip_publish(UriBuf, UriBuf, ProxyBuf, 0, PRESENCE_CONTENT_TYPE, MsgBodyBuf); eXosip_unlock(); if (i != 0) { return OWPL_RESULT_FAILURE; } return OWPL_RESULT_SUCCESS; }