NS_IMETHODIMP
MobileConnectionCallback::NotifyGetCallWaitingSuccess(uint16_t aServiceClass)
{
    return (aServiceClass & nsIMobileConnection::ICC_SERVICE_CLASS_VOICE)
           ? NotifySuccess(JS::TrueHandleValue)
           : NotifySuccess(JS::FalseHandleValue);
}
NS_IMETHODIMP
MobileConnectionCallback::NotifyGetNetworksSuccess(uint32_t aCount,
                                                   nsIMobileNetworkInfo** aNetworks)
{
  nsTArray<nsRefPtr<MobileNetworkInfo>> results;
  for (uint32_t i = 0; i < aCount; i++)
  {
    nsRefPtr<MobileNetworkInfo> networkInfo = new MobileNetworkInfo(mWindow);
    networkInfo->Update(aNetworks[i]);
    results.AppendElement(networkInfo);
  }

  AutoJSAPI jsapi;
  if (NS_WARN_IF(!jsapi.Init(mWindow))) {
    return NS_ERROR_FAILURE;
  }

  JSContext* cx = jsapi.cx();
  JS::Rooted<JS::Value> jsResult(cx);

  if (!ToJSValue(cx, results, &jsResult)) {
    JS_ClearPendingException(cx);
    return NS_ERROR_TYPE_ERR;
  }

  return NotifySuccess(jsResult);
}
Exemplo n.º 3
0
NS_IMETHODIMP
MobileMessageCallback::NotifyMessageMarkedRead(bool aRead)
{
  AutoJSContext cx;
  JS::Rooted<JS::Value> val(cx, JS::BooleanValue(aRead));
  return NotifySuccess(val);
}
NS_IMETHODIMP
MobileMessageCallback::NotifyMessageMarkedRead(bool aRead)
{
    AutoJSContext cx;
    JS::Rooted<JS::Value> val(cx, aRead ? JSVAL_TRUE : JSVAL_FALSE);
    return NotifySuccess(val);
}
NS_IMETHODIMP
MobileConnectionCallback::NotifyGetCallForwardingSuccess(uint32_t aCount,
        nsIMobileCallForwardingOptions** aResults)
{
    nsTArray<MozCallForwardingOptions> results;
    for (uint32_t i = 0; i < aCount; i++)
    {
        MozCallForwardingOptions result;
        int16_t pShort;
        nsString pString;
        bool pBool;

        aResults[i]->GetActive(&pBool);
        result.mActive.Construct(pBool);

        aResults[i]->GetAction(&pShort);
        if (pShort != nsIMobileConnection::CALL_FORWARD_ACTION_UNKNOWN) {
            result.mAction.Construct(pShort);
        }

        aResults[i]->GetReason(&pShort);
        if (pShort != nsIMobileConnection::CALL_FORWARD_REASON_UNKNOWN) {
            result.mReason.Construct(pShort);
        }

        aResults[i]->GetNumber(pString);
        result.mNumber.Construct(pString.get());

        aResults[i]->GetTimeSeconds(&pShort);
        if (pShort >= 0) {
            result.mTimeSeconds.Construct(pShort);
        }

        aResults[i]->GetServiceClass(&pShort);
        if (pShort != nsIMobileConnection::ICC_SERVICE_CLASS_NONE) {
            result.mServiceClass.Construct(pShort);
        }

        results.AppendElement(result);
    }

    AutoJSAPI jsapi;
    if (NS_WARN_IF(!jsapi.Init(mWindow))) {
        return NS_ERROR_FAILURE;
    }

    JSContext* cx = jsapi.cx();
    JS::Rooted<JS::Value> jsResult(cx);

    if (!ToJSValue(cx, results, &jsResult)) {
        JS_ClearPendingException(cx);
        return NS_ERROR_TYPE_ERR;
    }

    return NotifySuccess(jsResult);
}
Exemplo n.º 6
0
NS_IMETHODIMP
MobileMessageCallback::NotifyMessageDeleted(bool *aDeleted, uint32_t aSize)
{
  if (aSize == 1) {
    AutoJSContext cx;
    JS::Rooted<JS::Value> val(cx, JS::BooleanValue(*aDeleted));
    return NotifySuccess(val);
  }

  AutoJSAPI jsapi;
  if (NS_WARN_IF(!jsapi.Init(mDOMRequest->GetOwner()))) {
    return NS_ERROR_FAILURE;
  }
  JSContext* cx = jsapi.cx();

  JS::Rooted<JSObject*> deleteArrayObj(cx, JS_NewArrayObject(cx, aSize));
  for (uint32_t i = 0; i < aSize; i++) {
    JS_DefineElement(cx, deleteArrayObj, i, aDeleted[i], JSPROP_ENUMERATE);
  }

  JS::Rooted<JS::Value> deleteArrayVal(cx, JS::ObjectValue(*deleteArrayObj));
  return NotifySuccess(deleteArrayVal);
}
NS_IMETHODIMP
MobileMessageCallback::NotifyGetSmscAddress(const nsAString& aSmscAddress)
{
  AutoJSContext cx;
  JSString* smsc = JS_NewUCStringCopyN(cx,
                                       static_cast<const jschar *>(aSmscAddress.BeginReading()),
                                       aSmscAddress.Length());

  if (!smsc) {
    return NotifyError(nsIMobileMessageCallback::INTERNAL_ERROR);
  }

  JS::Rooted<JS::Value> val(cx, STRING_TO_JSVAL(smsc));
  return NotifySuccess(val);
}
Exemplo n.º 8
0
NS_IMETHODIMP
MobileMessageCallback::NotifyGetSmscAddress(const nsAString& aSmscAddress)
{
  AutoJSAPI jsapi;
  if (NS_WARN_IF(!jsapi.Init(mDOMRequest->GetOwner()))) {
    return NotifyError(nsIMobileMessageCallback::INTERNAL_ERROR);
  }
  JSContext* cx = jsapi.cx();
  JSString* smsc = JS_NewUCStringCopyN(cx, aSmscAddress.BeginReading(),
                                       aSmscAddress.Length());

  if (!smsc) {
    return NotifyError(nsIMobileMessageCallback::INTERNAL_ERROR);
  }

  JS::Rooted<JS::Value> val(cx, JS::StringValue(smsc));
  return NotifySuccess(val);
}
NS_IMETHODIMP
nsUrlClassifierHashCompleterRequest::OnStopRequest(nsIRequest *request,
                                                   nsISupports *context,
                                                   nsresult status)
{
  LOG(("nsUrlClassifierHashCompleter::OnStopRequest [%p, status=%d]",
       this, status));

  nsCOMPtr<nsIObserverService> observerService =
    do_GetService("@mozilla.org/observer-service;1");
  if (observerService)
    observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);

  if (mShuttingDown)
    return NS_ERROR_ABORT;

  if (NS_SUCCEEDED(status)) {
    nsCOMPtr<nsIHttpChannel> channel = do_QueryInterface(request);
    if (channel) {
      PRBool success;
      status = channel->GetRequestSucceeded(&success);
      if (NS_SUCCEEDED(status) && !success) {
        status = NS_ERROR_ABORT;
      }
    }
  }

  mCompleter->NoteServerResponse(NS_SUCCEEDED(status));

  if (NS_SUCCEEDED(status))
    status = HandleResponse();

  // If we were rescheduled, don't bother notifying success or failure.
  if (!mRescheduled) {
    if (NS_SUCCEEDED(status))
      NotifySuccess();
    else
      NotifyFailure(status);
  }

  mChannel = nsnull;

  return NS_OK;
}
Exemplo n.º 10
0
NS_IMETHODIMP
SmsRequest::NotifyThreadList(const jsval& aThreadList, JSContext* aCx)
{
  MOZ_ASSERT(aThreadList.isObject());

  if (mParent) {
    JSObject* array = const_cast<JSObject*>(&aThreadList.toObject());

    uint32_t length;
    bool ok = JS_GetArrayLength(aCx, array, &length);
    NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);

    ReplyThreadList reply;
    InfallibleTArray<ThreadListItem>& ipcItems = reply.items();

    if (length) {
      ipcItems.SetCapacity(length);

      for (uint32_t i = 0; i < length; i++) {
        jsval arrayEntry;
        ok = JS_GetElement(aCx, array, i, &arrayEntry);
        NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);

        MOZ_ASSERT(arrayEntry.isObject());

        mozilla::idl::SmsThreadListItem item;
        nsresult rv = item.Init(aCx, &arrayEntry);
        NS_ENSURE_SUCCESS(rv, rv);

        ThreadListItem* ipcItem = ipcItems.AppendElement();
        ipcItem->senderOrReceiver() = item.senderOrReceiver;
        ipcItem->timestamp() = item.timestamp;
        ipcItem->body() = item.body;
        ipcItem->unreadCount() = item.unreadCount;
      }
    }

    return SendMessageReply(reply);
  }

  return NotifySuccess(aThreadList);
}
NS_IMETHODIMP
MobileConnectionCallback::NotifyGetClirStatusSuccess(uint16_t aN, uint16_t aM)
{
    MozClirStatus result;
    result.mN.Construct(aN);
    result.mM.Construct(aM);

    AutoJSAPI jsapi;
    if (NS_WARN_IF(!jsapi.Init(mWindow))) {
        return NS_ERROR_FAILURE;
    }

    JSContext* cx = jsapi.cx();
    JS::Rooted<JS::Value> jsResult(cx);
    if (!ToJSValue(cx, result, &jsResult)) {
        JS_ClearPendingException(cx);
        return NS_ERROR_TYPE_ERR;
    }

    return NotifySuccess(jsResult);
};
CLStatus CLDataPostResultNotifier::Notify(int Result)
{
	try
	{
		if(Result == MSG_POST_SUCCESS)
		{
			throw NotifySuccess();
		}
		else if(Result == MSG_POST_ERROR)
		{
			throw NotifyFailure();
		}

		throw CLStatus(-1, NORMAL_ERROR);
	}
	catch(CLStatus& s)
	{
		if((m_pMsg) && (m_bDeleteMsg))
			delete m_pMsg;

		return s;
	}
}
NS_IMETHODIMP
MobileConnectionCallback::NotifyGetCallBarringSuccess(uint16_t aProgram,
        bool aEnabled,
        uint16_t aServiceClass)
{
    MozCallBarringOptions result;
    result.mProgram.Construct().SetValue(aProgram);
    result.mEnabled.Construct().SetValue(aEnabled);
    result.mServiceClass.Construct().SetValue(aServiceClass);

    AutoJSAPI jsapi;
    if (NS_WARN_IF(!jsapi.Init(mWindow))) {
        return NS_ERROR_FAILURE;
    }

    JSContext* cx = jsapi.cx();
    JS::Rooted<JS::Value> jsResult(cx);
    if (!ToJSValue(cx, result, &jsResult)) {
        JS_ClearPendingException(cx);
        return NS_ERROR_TYPE_ERR;
    }

    return NotifySuccess(jsResult);
}
Exemplo n.º 14
0
NS_IMETHODIMP
MobileMessageCallback::NotifySegmentInfoForTextGot(int32_t aSegments,
                                                   int32_t aCharsPerSegment,
                                                   int32_t aCharsAvailableInLastSegment)
{
  AutoJSAPI jsapi;
  if (NS_WARN_IF(!jsapi.Init(mDOMRequest->GetOwner()))) {
    return NotifyError(nsIMobileMessageCallback::INTERNAL_ERROR);
  }

  SmsSegmentInfo info;
  info.mSegments = aSegments;
  info.mCharsPerSegment = aCharsPerSegment;
  info.mCharsAvailableInLastSegment = aCharsAvailableInLastSegment;

  JSContext* cx = jsapi.cx();
  JS::Rooted<JS::Value> val(cx);
  if (!ToJSValue(cx, info, &val)) {
    JS_ClearPendingException(cx);
    return NotifyError(nsIMobileMessageCallback::INTERNAL_ERROR);
  }

  return NotifySuccess(val, true);
}
Exemplo n.º 15
0
NS_IMETHODIMP
MobileMessageCallback::NotifyMessageGot(nsISupports *aMessage)
{
  return NotifySuccess(aMessage);
}
NS_IMETHODIMP
MobileConnectionCallback::NotifySuccess()
{
  return NotifySuccess(JS::UndefinedHandleValue);
}
NS_IMETHODIMP
MobileConnectionCallback::NotifySuccessWithBoolean(bool aResult)
{
  return aResult ? NotifySuccess(JS::TrueHandleValue)
                 : NotifySuccess(JS::FalseHandleValue);
}
NS_IMETHODIMP
MobileMessageCallback::NotifySegmentInfoForTextGot(nsIDOMMozSmsSegmentInfo *aInfo)
{
  return NotifySuccess(aInfo, true);
}