Ejemplo n.º 1
0
void QPubNub::subscribe() {
  QString url(subscribeUrl(m_channelUrlPart) + m_timeToken);
  if (!m_uuid.isNull()) {
    url += "?uuid=" + m_uuid;
  }
  QNetworkReply* reply = sendRequest(url);
  connect(reply, &QNetworkReply::finished, this, &QPubNub::onSubscribeReadyRead);
  // This can't be connected using the new syntax, cause the signal and error property have the same name "error"
  connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onError(QNetworkReply::NetworkError)));
}
Ejemplo n.º 2
0
SIPXTAPI_API SIPX_RESULT sipxConfigVoicemailSubscribe(const SIPX_INST hInst,
                                                      const char* szSubscribeURL)
{
    OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,
        "sipxConfigVoicemailSubscribe hInst=%p URL=%s",
        hInst, szSubscribeURL);

    SIPX_RESULT rc = SIPX_RESULT_INVALID_ARGS;
    SIPX_INSTANCE_DATA* pInst = (SIPX_INSTANCE_DATA*) hInst;

    assert(pInst);
    if (pInst)
    {
        assert(pInst->pRefreshManager);
        assert(pInst->pLineManager);
        assert(pInst->pSipUserAgent);
        if (pInst->pRefreshManager && pInst->pLineManager && pInst->pSipUserAgent)
        {
            if (szSubscribeURL != NULL)
            {
                UtlString userId;
                UtlString contactUri;
                UtlString outboundLine;
                Url subscribeUrl(szSubscribeURL);
                subscribeUrl.getUserId(userId);

                pInst->pLineManager->getDefaultOutboundLine(outboundLine);

                // If the PHONESET_MSG_WAITING_SUBSCRIBE setting does
                // not have a userid field specified, get the one
                // from the default outbound line and use that
                if( userId.isNull() )
                {
                    // get default outbound line from the line manager
                    Url outbound(outboundLine);
                    outbound.getUserId(userId);
                    subscribeUrl.setUserId(userId);
                }

                // make sure we associate a user with the line
                pInst->pSipUserAgent->getContactUri( &contactUri );
                Url contactForLine ( contactUri );
                contactForLine.setUserId( userId );

                UtlString contactforLineStr = contactForLine.toString();

                SipMessage* mwiSubscribeRequest = new SipMessage();

                int sipSubscribePeriodSeconds;

                // get the Subscribe Period from the RefreshManager
                sipSubscribePeriodSeconds = pInst->pRefreshManager->getSubscribeTimeout();

                mwiSubscribeRequest->setVoicemailData (
                    outboundLine.data(),           // fromField
                    outboundLine.data(),           // toField
                    subscribeUrl.toString().data(),// uri
                    contactforLineStr.data(),      // contactUrl
                    NULL,                          // callId, do not set here
                    1,                             // cseq
                    sipSubscribePeriodSeconds);    // expiresInSeconds

                // send the subscribe request to the refresh manager
                pInst->pRefreshManager->newSubscribeMsg( *mwiSubscribeRequest );
                rc = SIPX_RESULT_SUCCESS;
            }
        }
    }

    return rc;
}