NS_IMETHODIMP
TelephonyRequestParent::NotifyDialMMISuccessWithInteger(const nsAString& aStatusMessage,
        uint16_t aAdditionalInformation)
{
    return SendResponse(DialResponseMMISuccess(nsAutoString(aStatusMessage),
                        AdditionalInformation(aAdditionalInformation)));
}
NS_IMETHODIMP
TelephonyRequestParent::NotifyDialMMIErrorWithInfo(const nsAString& aError,
        uint16_t aInfo)
{
    return SendResponse(DialResponseMMIError(nsAutoString(aError),
                        AdditionalInformation(aInfo)));
}
NS_IMETHODIMP
TelephonyRequestParent::NotifyDialMMI(const nsAString& aServiceCode)
{
    NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);

    return SendNotifyDialMMI(nsAutoString(aServiceCode)) ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
TelephonyRequestParent::NotifyDialCallSuccess(uint32_t aClientId,
        uint32_t aCallIndex,
        const nsAString& aNumber)
{
    return SendResponse(DialResponseCallSuccess(aClientId, aCallIndex,
                        nsAutoString(aNumber)));
}
NS_IMETHODIMP
TelephonyRequestParent::NotifyDialMMISuccessWithCallForwardingOptions(const nsAString& aStatusMessage,
        uint32_t aCount,
        nsIMobileCallForwardingOptions** aAdditionalInformation)
{
    nsTArray<nsIMobileCallForwardingOptions*> additionalInformation;
    for (uint32_t i = 0; i < aCount; i++) {
        additionalInformation.AppendElement(aAdditionalInformation[i]);
    }

    return SendResponse(DialResponseMMISuccess(nsAutoString(aStatusMessage),
                        AdditionalInformation(additionalInformation)));
}
NS_IMETHODIMP
TelephonyRequestParent::NotifyDialMMISuccessWithStrings(const nsAString& aStatusMessage,
        uint32_t aCount,
        const char16_t** aAdditionalInformation)
{
    nsTArray<nsString> additionalInformation;
    for (uint32_t i = 0; i < aCount; i++) {
        additionalInformation.AppendElement(nsDependentString(aAdditionalInformation[i]));
    }

    return SendResponse(DialResponseMMISuccess(nsAutoString(aStatusMessage),
                        AdditionalInformation(additionalInformation)));
}
NS_IMETHODIMP 
nsEntityConverter::LoadVersionPropertyFile()
{
    NS_NAMED_LITERAL_CSTRING(url, "resource://gre/res/entityTables/htmlEntityVersions.properties");
	nsresult rv;
    nsCOMPtr<nsIStringBundleService> bundleService =
        do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);

    if (NS_FAILED(rv)) return rv;
    
    nsCOMPtr<nsIStringBundle> entities;
    rv = bundleService->CreateBundle(url.get(), getter_AddRefs(entities));
    if (NS_FAILED(rv)) return rv;
    
    PRInt32	result;

    nsAutoString key;
    nsXPIDLString value;
    rv = entities->GetStringFromName(NS_LITERAL_STRING("length").get(),
                                     getter_Copies(value));
    NS_ASSERTION(NS_SUCCEEDED(rv),"nsEntityConverter: malformed entity table\n");
    if (NS_FAILED(rv)) return rv;
      
    mVersionListLength = nsAutoString(value).ToInteger(&result);
    NS_ASSERTION(32 >= mVersionListLength,"nsEntityConverter: malformed entity table\n");
    if (32 < mVersionListLength) return NS_ERROR_FAILURE;
    
    mVersionList = new nsEntityVersionList[mVersionListLength];
    if (!mVersionList) return NS_ERROR_OUT_OF_MEMORY;

    for (PRUint32 i = 0; i < mVersionListLength && NS_SUCCEEDED(rv); i++) {
        key.SetLength(0);
        key.AppendInt(i+1, 10);
        rv = entities->GetStringFromName(key.get(), getter_Copies(value));
        PRUint32 len = value.Length();
        if (kVERSION_STRING_LEN < len) return NS_ERROR_UNEXPECTED;
        
        memcpy(mVersionList[i].mEntityListName, value.get(), len*sizeof(PRUnichar));
        mVersionList[i].mEntityListName[len] = 0;
        mVersionList[i].mVersion = (1 << i);
    }

    return NS_OK;
}
already_AddRefed<nsMIMEInfoBase>
nsOSHelperAppService::GetFromType(const nsCString& aMIMEType)
{
	for (int i = 0; mimeTypes[i].type; i++)
	{
		if (strcasecmp(aMIMEType.get(), mimeTypes[i].type) == 0)
		{
			nsCAutoString mimeType(mimeTypes[i].type);
			nsAutoString description = NS_ConvertASCIItoUTF16(mimeTypes[i].description);;

			nsMIMEInfoAmigaOS *mimeInfo = new nsMIMEInfoAmigaOS(mimeType);
			NS_ADDREF(mimeInfo);

			if (mimeTypes[i].handler)
			{
				nsCAutoString path(mimeTypes[i].handler);
				nsAutoString handler = NS_ConvertASCIItoUTF16(mimeTypes[i].handlerDesc);

				nsCOMPtr<nsILocalFile> localFile (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
				localFile->InitWithNativePath(path);

				NS_IF_ADDREF(localFile);

				mimeInfo->SetDescription(nsAutoString(description));
				mimeInfo->SetDefaultApplication(localFile);
				mimeInfo->SetDefaultDescription(handler);
				mimeInfo->SetPreferredAction(nsIMIMEInfo::useHelperApp);
			}
			else
			{
				mimeInfo->SetDescription(description);
				mimeInfo->SetPreferredAction(nsIMIMEInfo::saveToDisk);
			}

			return mimeInfo;
		}
	}

	return nsnull;
}
Exemple #9
0
NS_IMETHODIMP
IccRequestParent::NotifyCardLockError(const nsAString & aErrorMsg,
                                      int32_t aRetryCount)
{
  return SendReply(IccReplyCardLockError(aRetryCount, nsAutoString(aErrorMsg)));
}
Exemple #10
0
NS_IMETHODIMP
IccRequestParent::NotifyError(const nsAString & aErrorMsg)
{
  return SendReply(IccReplyError(nsAutoString(aErrorMsg)));
}
NS_IMETHODIMP
ContainerEnumeratorImpl::HasMoreElements(bool* aResult)
{
    NS_ASSERTION(aResult != nullptr, "null ptr");
    if (! aResult)
        return NS_ERROR_NULL_POINTER;

    nsresult rv;

    // If we've already queued up a next value, then we know there are more elements.
    if (mResult) {
        *aResult = true;
        return NS_OK;
    }

    // Otherwise, we need to grovel

    // Figure out the upper bound so we'll know when we're done. Since it's
    // possible that we're targeting a composite datasource, we'll need to
    // "GetTargets()" and take the maximum value of "nextVal" to know the
    // upper bound.
    //
    // Remember that since nextVal is the next index that we'd assign
    // to an element in a container, it's *one more* than count of
    // elements in the container.
    int32_t max = 0;

    nsCOMPtr<nsISimpleEnumerator> targets;
    rv = mDataSource->GetTargets(mContainer, kRDF_nextVal, true, getter_AddRefs(targets));
    if (NS_FAILED(rv)) return rv;

    while (1) {
        bool hasmore;
        targets->HasMoreElements(&hasmore);
        if (! hasmore)
            break;

        nsCOMPtr<nsISupports> isupports;
        targets->GetNext(getter_AddRefs(isupports));

        nsCOMPtr<nsIRDFLiteral> nextValLiteral = do_QueryInterface(isupports);
        if (! nextValLiteral)
             continue;

         const char16_t *nextValStr;
         nextValLiteral->GetValueConst(&nextValStr);

         nsresult err;
         int32_t nextVal = nsAutoString(nextValStr).ToInteger(&err);

         if (nextVal > max)
             max = nextVal;
    }

    // Now pre-fetch our next value into mResult.
    while (mCurrent || mNextIndex < max) {

        // If mCurrent has been depleted, then conjure up a new one
        if (! mCurrent) {
            rv = gRDFC->IndexToOrdinalResource(mNextIndex, getter_AddRefs(mOrdinalProperty));
            if (NS_FAILED(rv)) return rv;

            rv = mDataSource->GetTargets(mContainer, mOrdinalProperty, true, getter_AddRefs(mCurrent));
            if (NS_FAILED(rv)) return rv;

            ++mNextIndex;
        }

        if (mCurrent) {
            bool hasMore;
            rv = mCurrent->HasMoreElements(&hasMore);
            if (NS_FAILED(rv)) return rv;

            // Is the current enumerator depleted? If so, iterate to
            // the next index.
            if (! hasMore) {
                mCurrent = nullptr;
                continue;
            }

            // "Peek" ahead and pull out the next target.
            nsCOMPtr<nsISupports> result;
            rv = mCurrent->GetNext(getter_AddRefs(result));
            if (NS_FAILED(rv)) return rv;

            mResult = do_QueryInterface(result, &rv);
            if (NS_FAILED(rv)) return rv;

            *aResult = true;
            return NS_OK;
        }
    }

    // If we get here, we ran out of elements. The cursor is empty.
    *aResult = false;
    return NS_OK;
}
NS_IMETHODIMP
TelephonyRequestParent::NotifyDialMMIError(const nsAString& aError)
{
    return SendResponse(DialResponseMMIError(nsAutoString(aError),
                        AdditionalInformation(mozilla::void_t())));
}
NS_IMETHODIMP
TelephonyRequestParent::NotifyDialMMISuccess(const nsAString& aStatusMessage)
{
    return SendResponse(DialResponseMMISuccess(nsAutoString(aStatusMessage),
                        AdditionalInformation(mozilla::void_t())));
}
NS_IMETHODIMP
TelephonyRequestParent::NotifyError(const nsAString& aError)
{
    return SendResponse(ErrorResponse(nsAutoString(aError)));
}