コード例 #1
0
ファイル: test.cpp プロジェクト: TheTypoMaster/ElastosRDK5_0
 /*
 * Ԥ�ڽ��: OK
 *
 * ���з�ʽ: clPushbackReader.ecx 8
 *
 */
  int CTest::TestReadBufferEx(int argc,char *argv[])
{
    ICharArrayReader * ir;

    ArrayOf<Char8>* buffer = ArrayOf<Char8>::Alloc(1024);
    if (buffer == NULL) return E_OUT_OF_MEMORY_ERROR;
    const char * str = (const char*) m_text;
    buffer->Copy((Char8*) str, 1024);

    ECode rt = CCharArrayReader::New(buffer, &ir);

    if (rt == 0) {
        rt = CPushbackReader::New((IReader*)ir, &m_pr);
    }
    Int32 number;
    ArrayOf<Char8> *buf = ArrayOf<Char8>::Alloc(1024);
    if (0 == rt) {
        rt = m_pr->ReadBufferEx(0, 1, buf, &number);
    }
    if (0 == rt) {
        printf("test 8:OK\n");
    }
    else {
        printf("test 8 ERR: rt = %d\n", rt);
    }
    if(ir) ir->Release();
    if(m_pr) m_pr->Release();
    ArrayOf<Char8>::Free(buffer);
    ArrayOf<Char8>::Free(buf);
    return 0;
}
コード例 #2
0
ファイル: CResources.cpp プロジェクト: xianjimli/Elastos
ECode CResources::ObtainAttributes(
    /* [in] */ IAttributeSet* set,
    /* [in] */ const ArrayOf<Int32>& attrs,
    /* [out] */ ITypedArray** array)
{
    VALIDATE_NOT_NULL(set);
    VALIDATE_NOT_NULL(array);
    *array = NULL;

    Int32 len = attrs.GetLength();
    FAIL_RETURN(GetCachedStyledAttributes(len, array));

    // XXX note that for now we only work with compiled XML files.
    // To support generic XML files we will need to manually parse
    // out the attributes from the XML file (applying type information
    // contained in the resources and such).
    AutoPtr<CTypedArray> a = (CTypedArray*)*array;
    AutoPtr<XmlBlock::Parser> parser = (XmlBlock::Parser*)set;
    mAssets->RetrieveAttributes(
            parser->mParseState, attrs, *a->mData, *a->mIndices);

    a->mRsrcs = attrs.Clone();
    a->mXml = parser;

    return NOERROR;
}
コード例 #3
0
ファイル: test.cpp プロジェクト: TheTypoMaster/ElastosRDK5_0
/*
 * Ԥ�ڽ��: OK
 *
 * ���з�ʽ: clPushbackReader.ecx 5
 */
 int CTest::TestIsMarkSupported(int argc,char *argv[])
{
    ICharArrayReader * ir;

    ArrayOf<Char8>* buffer = ArrayOf<Char8>::Alloc(1024);
    if (buffer == NULL) return E_OUT_OF_MEMORY_ERROR;
    const char * str = (const char*) m_text;
    buffer->Copy((Char8*) str, 1024);

    ECode rt = CCharArrayReader::New(buffer, &ir);

    if (rt == 0) {
        rt = CPushbackReader::New((IReader*)ir, &m_pr);
    }
    Boolean supported;
    if (0 == rt) {
        rt = m_pr->IsMarkSupported(&supported);
    }
    if (0 == rt) {
        printf("test 5:OK\n");
    }
    else {
        printf("test 5 ERR: rt = %d\n", rt);
    }
    if(ir) ir->Release();
    if(m_pr) m_pr->Release();
    ArrayOf<Char8>::Free(buffer);
    return 0;
}
コード例 #4
0
    virtual bool write(
        /* [in] */ const void* buffer,
        /* [in] */ size_t size)
    {
        ArrayOf<Byte>* storage = mByteArray;

        while (size > 0) {
            size_t requested = size;
            if (requested > (size_t)mCapacity) {
                requested = mCapacity;
            }

            memcpy(storage->GetPayload(), buffer, requested);

            ECode ec = mOutputStream->Write(storage, 0, requested);
            if (FAILED(ec)) {
                SkDebugf("------- write threw an exception\n");
                return false;
            }

            buffer = (void*)((char*)buffer + requested);
            size -= requested;
            mBytesWritten += requested;
        }
        return true;
    }
コード例 #5
0
ファイル: CursorWindow.cpp プロジェクト: xianjimli/Elastos
Boolean CursorWindow::NativePutBlob(
    /* [in] */ const ArrayOf<Byte>& value,
    /* [in] */ Int32 row,
    /* [in] */ Int32 col)
{
    NativeCursorWindow* window = mNativeWindow;
    field_slot_t* fieldSlot = window->getFieldSlotWithCheck(row, col);
    if (fieldSlot == NULL) {
        // LOG_WINDOW(" getFieldSlotWithCheck error ");
        return FALSE;
    }

    Int32 len = value.GetLength();
    Int32 offset = window->alloc(len);
    if (!offset) {
        // LOG_WINDOW("Failed allocating %u bytes", len);
        return FALSE;
    }
    Byte* bytes = value.GetPayload();
    window->copyIn(offset, (uint8_t const *)bytes, len);

    // This must be updated after the call to alloc(), since that
    // may move the field around in the window
    fieldSlot->type = FIELD_TYPE_BLOB;
    fieldSlot->data.buffer.offset = offset;
    fieldSlot->data.buffer.size = len;
    // LOG_WINDOW("%d,%d is BLOB with %u bytes @ %d", row, col, len, offset);
    return TRUE;
}
コード例 #6
0
ファイル: CAppWidgetHost.cpp プロジェクト: xianjimli/Elastos
ECode CAppWidgetHost::StartListening()
{
    ArrayOf<Int32>* updatedIds;
    AutoPtr<IObjectContainer> updatedViews;

    //try {
    if (mCapsuleName.IsNull()) {
        mContext->GetCapsuleName(&mCapsuleName);
    }
    ECode ec = sService->StartListening(mCallbacks, mCapsuleName, mHostId,
            (IObjectContainer**)&updatedViews, &updatedIds);
    if (FAILED(ec)) {
        return ec;
    }
    // }
    // catch (RemoteException e) {
    //     throw new RuntimeException("system server dead?", e);
    // }

    AutoPtr<IObjectEnumerator> enumerator;
    updatedViews->GetObjectEnumerator((IObjectEnumerator**)&enumerator);
    Boolean hasNext;
    for (Int32 i = 0; i < updatedIds->GetLength(); i++) {
        AutoPtr<IRemoteViews> views;
        enumerator->MoveNext(&hasNext);
        if (hasNext) {
            enumerator->Current((IInterface**)&views);
        }
        UpdateAppWidgetView((*updatedIds)[i], views);
    }

    return NOERROR;
}
コード例 #7
0
ファイル: ODDecodeBlockFile.cpp プロジェクト: MindFy/audacity
/// Read the summary of this alias block from disk.  Since the audio data
/// is elsewhere, this consists of reading the entire summary file.
/// Fill with zeroes and return false if data are unavailable for any reason.
///
/// @param *data The buffer where the summary data will be stored.  It must
///              be at least mSummaryInfo.totalSummaryBytes long.
bool ODDecodeBlockFile::ReadSummary(ArrayOf<char> &data)
{
   //I dont think we need to add a mutex here because only the main thread changes filenames and calls ReadSummary
   if(IsSummaryAvailable())
      return SimpleBlockFile::ReadSummary(data);

   data.reinit( mSummaryInfo.totalSummaryBytes );
   memset(data.get(), 0, mSummaryInfo.totalSummaryBytes);
   return false;
}
コード例 #8
0
ファイル: CContentService.cpp プロジェクト: xianjimli/Elastos
Int32 CContentService::ObserverNode::CountUriSegments(
    /* [in] */ IUri* uri)
{
    if (NULL == uri) {
        return 0;
    }

    ArrayOf<String>* pathSegments;
    FAIL_RETURN(uri->GetPathSegments(&pathSegments));
    return pathSegments->GetLength() + 1;
}
コード例 #9
0
ファイル: CDashPathEffect.cpp プロジェクト: elastos/Elastos5
Int64 CDashPathEffect::NativeCreate(
    /* [in] */ const ArrayOf<Float>& intervalArray,
    /* [in] */ Float phase)
{
    int         count = intervalArray.GetLength() & ~1;  // even number
#ifdef SK_SCALAR_IS_FLOAT
    SkScalar*   intervals = intervalArray.GetPayload();
#else
    #error Need to convert float array to SkScalar array before calling the following function.
#endif
    SkPathEffect* effect = SkDashPathEffect::Create(intervals, count, phase);
    return reinterpret_cast<Int64>(effect);
}
コード例 #10
0
ECode SQLiteProgram::BindBlob(
    /* [in] */ Int32 index,
    /* [in] */ const ArrayOf<Byte>& value)
{
    AutoPtr<IArrayOf> array;
    CArrayOf::New(EIID_IByte, value.GetLength(), (IArrayOf**)&array);
    for (Int32 i = 0; i < value.GetLength(); ++i) {
        AutoPtr<IByte> bv;
        CByte::New(value[i], (IByte**)&bv);
        array->Set(i, bv);
    }
    return Bind(index, array);
}
コード例 #11
0
Int32 CDashPathEffect::NativeCreate(
    /* [in] */ const ArrayOf<Float>& intervals,
    /* [in] */ Float phase)
{
    Int32 count = intervals.GetLength() & ~1;  // even number
    Float* values = intervals.GetPayload();

    SkAutoSTMalloc<32, SkScalar> storage(count);
    SkScalar* nativeIntervals = storage.get();
    for (int i = 0; i < count; i++) {
        nativeIntervals[i] = SkFloatToScalar(values[i]);
    }
    return reinterpret_cast<Int32>(new SkDashPathEffect(
            nativeIntervals, count, SkFloatToScalar(phase)));
}
コード例 #12
0
ファイル: MatrixCursor.cpp プロジェクト: xianjimli/Elastos
void MatrixCursor::EnsureCapacity(
    /* [in] */ Int32 size)
{
    if (size > mData->GetLength()) {
        ArrayOf< AutoPtr<IInterface> >* oldData = mData;
        Int32 newSize = mData->GetLength() * 2;
        if (newSize < size) {
            newSize = size;
        }
        mData = ArrayOf< AutoPtr<IInterface> >::Alloc(newSize);
        memcpy(mData->GetPayload(), oldData->GetPayload(),
                oldData->GetLength() * sizeof(AutoPtr<IInterface>));
        ArrayOf< AutoPtr<IInterface> >::Free(oldData);
    }
}
コード例 #13
0
ECode SyncStateContractHelpers::NewSetOperation(
        /* [in] */ IUri* uri,
        /* [in] */ IAccount* account,
        /* [in] */ const ArrayOf<Byte>& data,
        /* [out] */ IContentProviderOperation** operation)
{
    VALIDATE_NOT_NULL(operation);

    AutoPtr<IContentValues> values;
    FAIL_RETURN(CContentValues::New((IContentValues**)&values))

    AutoPtr<IArrayOf> array;
    FAIL_RETURN(CArrayOf::New(EIID_IByte, data.GetLength(), (IArrayOf**)&array))
    FAIL_RETURN(values->PutBytes(ISyncStateContractColumns::DATA, array))

    AutoPtr<IContentProviderOperationHelper> helper;
    FAIL_RETURN(CContentProviderOperationHelper::AcquireSingleton((IContentProviderOperationHelper**)&helper))
    AutoPtr<IContentProviderOperationBuilder> builder;
    FAIL_RETURN(helper->NewInsert(uri, (IContentProviderOperationBuilder**)&builder))

    String name, type;
    FAIL_RETURN(account->GetName(&name))
    FAIL_RETURN(account->GetType(&type))
    AutoPtr<ICharSequence> cname, ctype;
    FAIL_RETURN(CStringWrapper::New(name, (ICharSequence**)&cname))
    FAIL_RETURN(CStringWrapper::New(type, (ICharSequence**)&ctype))
    FAIL_RETURN(builder->WithValue(ISyncStateContractColumns::ACCOUNT_NAME, (IInterface*)cname))
    FAIL_RETURN(builder->WithValue(ISyncStateContractColumns::ACCOUNT_TYPE, (IInterface*)ctype))
    return builder->Build(operation);
}
コード例 #14
0
ECode SyncStateContractHelpers::Insert(
    /* [in] */ IContentProviderClient* provider,
    /* [in] */ IUri* uri,
    /* [in] */ IAccount* account,
    /* [in] */ const ArrayOf<Byte>& data,
    /* [out] */ IUri** retUri)
{
    VALIDATE_NOT_NULL(retUri);

    AutoPtr<IContentValues> values;
    FAIL_RETURN(CContentValues::New((IContentValues**)&values))

    AutoPtr<IArrayOf> array;
    FAIL_RETURN(CArrayOf::New(EIID_IByte, data.GetLength(), (IArrayOf**)&array))
    FAIL_RETURN(values->PutBytes(ISyncStateContractColumns::DATA, array))
    String name, type;
    FAIL_RETURN(account->GetName(&name))
    FAIL_RETURN(account->GetType(&type))
    AutoPtr<ICharSequence> cname, ctype;
    FAIL_RETURN(CStringWrapper::New(name, (ICharSequence**)&cname))
    FAIL_RETURN(CStringWrapper::New(type, (ICharSequence**)&ctype))
    FAIL_RETURN(values->PutString(ISyncStateContractColumns::ACCOUNT_NAME, cname))
    FAIL_RETURN(values->PutString(ISyncStateContractColumns::ACCOUNT_TYPE, ctype))
    return provider->Insert(uri, values, retUri);
}
コード例 #15
0
ファイル: test.cpp プロジェクト: TheTypoMaster/ElastosRDK5_0
int CTest::testLocales(int argc, char* argv[]) {
    // Just run through them all. Handy as a poor man's benchmark, and a sanity check.
    ArrayOf<ILocale*>* arrloc;
    AutoPtr<ILocaleHelper> lochelp;
    CLocaleHelper::AcquireSingleton((ILocaleHelper **)&lochelp);
    lochelp->GetAvailableLocales(&arrloc);
    for (int i = 0; i < arrloc->GetLength(); i++) {
        AutoPtr<ILocale> l = (*arrloc)[i];
        AutoPtr<ISimpleDateFormat> sdf;
        CSimpleDateFormat::New(String("yyyy-MM-dd HH:mm:ss zzzz"), l , (ISimpleDateFormat **)&sdf);
        AutoPtr<IDate> adate;
        CDate::New(0,(IDate **)&adate);
        String str;
        sdf->FormatDate(adate,&str);
        PFL_EX("str:%s " ,str.string())
    }
}
コード例 #16
0
ファイル: XmlBlock.cpp プロジェクト: XilongPei/Elastos5
XmlBlock::XmlBlock(
    /* [in] */ const ArrayOf<Byte>& data)
    : mOpenCount(1)
    , mOpen(TRUE)
{
    mNative = NativeCreate(data, 0, data.GetLength());
    mStrings = new StringBlock(NativeGetStringBlock(mNative), FALSE);
}
コード例 #17
0
ファイル: CursorWindow.cpp プロジェクト: xianjimli/Elastos
ECode CursorWindow::NativeGetBlob(
    /* [in] */ Int32 row,
    /* [in] */ Int32 column,
    /* [out] */ ArrayOf<Byte>** blob)
{
    ECode ec = NOERROR;
    int32_t err;
    NativeCursorWindow * window = mNativeWindow;
    // LOG_WINDOW("Getting blob for %d,%d from %p", row, column, window);

    field_slot_t field;
    err = window->read_field_slot(row, column, &field);
    if (err != 0) {
        *blob = NULL;
        // throwExceptionWithRowCol(env, row, column);
        return E_ILLEGAL_STATE_EXCEPTION;
    }

    uint8_t type = field.type;
    if (type == FIELD_TYPE_BLOB || type == FIELD_TYPE_STRING) {
        ArrayOf<Byte>* byteArray = ArrayOf<Byte>::Alloc(field.data.buffer.size);
        // LOG_ASSERT(byteArray, "Native could not create new byte[]");
        memcpy(byteArray->GetPayload(), window->offsetToPtr(field.data.buffer.offset),
                field.data.buffer.size);
        *blob = byteArray;
        return NOERROR;
    }
    else if (type == FIELD_TYPE_INTEGER) {
        ec = throw_sqlite3_exception(NULL);
    }
    else if (type == FIELD_TYPE_FLOAT) {
        ec = throw_sqlite3_exception(NULL);
    }
    else if (type == FIELD_TYPE_NULL) {
        // do nothing
    }
    else {
        // throwUnknowTypeException(env, type);
        ec = E_ILLEGAL_STATE_EXCEPTION;
    }
    *blob = NULL;
    return ec;
}
コード例 #18
0
ECode CSurfaceTexture::GetTransformMatrix(
    /* [in] */ const ArrayOf<Float>& mtx)
{
    // Note we intentionally don't check mtx for null, so this will result in a
    // NullPointerException. But it's safe because it happens before the call to native.
    if (mtx.GetLength() != 16) {
        return E_ILLEGAL_ARGUMENT_EXCEPTION;
    }
    NativeGetTransformMatrix(mtx);
    return NOERROR;
}
コード例 #19
0
ファイル: CCursorJoiner.cpp プロジェクト: XilongPei/Elastos5
void CCursorJoiner::PopulateValues(
    /* [in] */ ArrayOf<String>& values,
    /* [in] */ ICursor* cursor,
    /* [in] */ const ArrayOf<Int32>& columnIndicies,
    /* [in] */ Int32 startingIndex)
{
    assert(startingIndex == 0 || startingIndex == 1);
    for (Int32 i = 0; i < columnIndicies.GetLength(); i++) {
        cursor->GetString(columnIndicies[i], &values[startingIndex + i * 2]);
    }
}
コード例 #20
0
ファイル: CDashPathEffect.cpp プロジェクト: elastos/Elastos5
ECode CDashPathEffect::constructor(
    /* [in] */ const ArrayOf<Float>& intervals,
    /* [in] */ Float phase)
{
    if (intervals.GetLength() < 2) {
//        throw new ArrayIndexOutOfBoundsException();
        return E_ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION;
    }
    mNativeInstance = NativeCreate(intervals, phase);
    return NOERROR;
}
コード例 #21
0
void SQLiteDebug::Dump(
    /*[in]*/ IPrinter* printer,
    /*[in]*/ const ArrayOf<String>& args)
{
    Boolean verbose = FALSE;
    for(Int32 i=0; i < args.GetLength(); i++) {
        if((args)[i].Equals("-v")) {
            verbose = TRUE;
        }
    }
    SQLiteDatabase::DumpAll(printer, verbose);
}
コード例 #22
0
ファイル: CStmt.cpp プロジェクト: imace/ElastosRDK5_0
ECode CStmt::Bind(
    /* [in] */ Int32 pos,
    /* [in] */ const ArrayOf<Byte>& value)
{
#if HAVE_SQLITE3 && HAVE_SQLITE_COMPILE
    hvm *v = (hvm *)mHandle;

    if (v && v->vm && v->h) {
        Int32 npar = sqlite3_bind_parameter_count((sqlite3_stmt *) v->vm);
        Int32 ret = 0;
        Int32 len = 0;

        if (pos < 1 || pos > npar) {
            return E_ILLEGAL_ARGUMENT_EXCEPTION;
        }

        if (value.GetPayload()) {
            len = value.GetLength();
            if (len > 0) {
                ret = sqlite3_bind_blob((sqlite3_stmt *) v->vm,
                            pos, value.GetPayload(), len, sqlite3_free);
            } else {
                ret = sqlite3_bind_blob((sqlite3_stmt *) v->vm,
                            pos, "", 0, SQLITE_STATIC);
            }
        } else {
            ret = sqlite3_bind_null((sqlite3_stmt *) v->vm, pos);
        }
        if (ret != SQLITE_OK) {
            mError_code = ret;
            return E_SQL_EXCEPTION;
        }
    } else {
        return E_NULL_POINTER_EXCEPTION;
    }
#else
    return E_SQL_FEATURE_NOT_SUPPORTED_EXCEPTION;
#endif
    return NOERROR;
}
コード例 #23
0
ファイル: test.cpp プロジェクト: TheTypoMaster/ElastosRDK5_0
int main(int argc, char *argv[])
{
    ECode ec = NOERROR;
    ArrayOf<Byte> *buffer = ArrayOf<Byte>::Alloc(1024);
    Int32 len;

    IFileOutputStream *pfo = NULL;
    ec = CFileOutputStream::New(String("/data/data/com.elastos.runtime/elastos/tstbuffer.txt"), &pfo);
    if (FAILED(ec)) {
    	printf("Cann't Create CFileOutputStream, ec = %x\n", ec);
        return -1;
    }


    IBufferedOutputStream *pbos = NULL;
    ec = CBufferedOutputStream::New((IFileOutputStream *)pfo, &pbos);
    if (FAILED(ec)) {
    	printf("Cann't Create CZipOutputStream, ec = %x\n", ec);
        return -1;
    }

    Int32 i = 0;

    buffer->Copy((Byte *)"random", 6);
    while(i < 100) {
        ec = pbos->WriteBufferEx(0, 6, *buffer);
        if (FAILED(ec)) {
            printf("WriteBufferEx Failed! ec = %x\n", ec);
            return -1;
        }
        pbos->Flush();
        //buffer->Copy((Byte *)&i, 4);
        i++;
    }
    printf("==============================================\n");
    pbos->Close();
    return 0;

}
コード例 #24
0
    virtual bool write(const void* buffer, size_t size)
    {
        ArrayOf<Byte>* storage = mByteArray;

        while (size > 0) {
            size_t requested = size;
            if (requested > mCapacity) {
                requested = mCapacity;
            }

            memcpy(storage->GetPayload(), buffer, requested);

            ECode ec = mOutputStream->WriteBytes(*storage, 0, requested);
            if (FAILED(ec)) {
                return FALSE;
            }

            buffer = (void*)((char*)buffer + requested);
            size -= requested;
        }
        return TRUE;
    }
コード例 #25
0
ファイル: StringBlock.cpp プロジェクト: XilongPei/Elastos5
Handle64 StringBlock::NativeCreate(
    /* [in] */ const ArrayOf<Byte>& data,
    /* [in] */ Int32 offset,
    /* [in] */ Int32 size)
{
    Int32 len = data.GetLength();
    if (offset < 0 || offset >= len || size < 0 || size > len || (offset + size) > len) {
        assert(0);
        // jniThrowException(env, "java/lang/IndexOutOfBoundsException", NULL);
        return 0;
    }

    android::ResStringPool* osb = new android::ResStringPool(
            data.GetPayload() + offset, size, TRUE);

    if (osb == NULL || osb->getError() != android::NO_ERROR) {
        assert(0);
        // jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
        return 0;
    }

    return (Handle64)osb;
}
コード例 #26
0
ファイル: CActivityOne.cpp プロジェクト: xianjimli/Elastos
ECode CActivityOne::OnCreate(
    /* [in] */ IBundle* savedInstanceState)
{
    SetContentView(0x7f030000);

    AutoPtr<IView> view = FindViewById(0x7f050000);
    AutoPtr<INumberPicker> numberPicker = INumberPicker::Probe(view);
    assert(numberPicker != NULL);
    ArrayOf<String>* rangs = ArrayOf<String>::Alloc(10);
    (*rangs)[0] = String("0");
    (*rangs)[1] = String("1");
    (*rangs)[2] = String("2");
    (*rangs)[3] = String("3");
    (*rangs)[4] = String("4");
    (*rangs)[5] = String("5");
    (*rangs)[6] = String("6");
    (*rangs)[7] = String("7");
    (*rangs)[8] = String("8");
    (*rangs)[9] = String("9");
    Int32 len = rangs->GetLength();
    numberPicker->SetRangeEx(0, 9, *rangs);
    return NOERROR;
}
コード例 #27
0
ECode CEmbossMaskFilter::constructor(
    /* [in] */ const ArrayOf<Float>& direction,
    /* [in] */ Float ambient,
    /* [in] */ Float specular,
    /* [in] */ Float blurRadius)
{
    if (direction.GetLength() < 3) {
        // throw new ArrayIndexOutOfBoundsException();
        return E_ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION;
    }

    mNativeInstance = NativeConstructor(direction, ambient, specular, blurRadius);
    return NOERROR;
}
コード例 #28
0
ECode SyncStateContractHelpers::Update(
    /* [in] */ IContentProviderClient* provider,
    /* [in] */ IUri* uri,
    /* [in] */ const ArrayOf<Byte>& data)
{
    AutoPtr<IContentValues> values;
    FAIL_RETURN(CContentValues::New((IContentValues**)&values))

    AutoPtr<IArrayOf> array;
    FAIL_RETURN(CArrayOf::New(EIID_IByte, data.GetLength(), (IArrayOf**)&array))
    FAIL_RETURN(values->PutBytes(ISyncStateContractColumns::DATA, array))
    Int32 rowsAffected;
    return provider->Update(uri, values, String(NULL), NULL, &rowsAffected);
}
コード例 #29
0
ファイル: test.cpp プロジェクト: TheTypoMaster/ElastosRDK5_0
/*
 *
 * Ԥ�ڽ��: OK
 *
 * ���з�ʽ: clPushBackInputStream.ecx 2
 */
 int CTest::TestConstructor2(int argc,char *argv[])
{
    IByteArrayInputStream* in;

    ArrayOf<Byte>* buffer = ArrayOf<Byte>::Alloc(3328);
    const char * str = (const char*) m_text;
    buffer->Copy((Byte*) str, 3328);

    ECode rt = CByteArrayInputStream::New(buffer, &in);
    if ( 0 == rt)
        rt = CPushbackInputStream::New((IInputStream*)in, &m_pis);

    if (0 == rt) {
        printf("test 2:OK\n");
    }
    else {
        printf("test 2 ERR: rt = %d\n", rt);
    }
    if(in) in->Release();
    if(m_pis) m_pis->Release();
    ArrayOf<Byte>::Free(buffer);
    return 0;
}
コード例 #30
0
ECode CGeckoSmsManager::OnRecieve(
    IContext *pContext,
    IIntent *pIntent)
{
    // TODO: Try to find the receiver number to be able to populate
    //       SmsMessage.receiver.
    // TODO: Get the id and the date from the stock app saved message.
    //       Using the stock app saved message require us to wait for it to
    //       be saved which can lead to race conditions.
    String action;
    pIntent->GetAction(&action);
    if (action.Equals(GeckoSmsManager_ACTION_SMS_RECEIVED)) {
        AutoPtr<IBundle> bundle;
        pIntent->GetExtras((IBundle**)&bundle);

        if (bundle == NULL) {
          return NOERROR;
        }

        ArrayOf<ArrayOf<Byte>*>* pdus;
        bundle->Get(String("pdus"), (IInterface**)&pdus);

        for (Int32 i = 0; i < pdus->GetLength(); ++i) {
            AutoPtr<ISmsMessage> msg;
            CSmsMessage::CreateFromPdu((*pdus[i], (ISmsMessage**)&msg);
            String smsAddress;
            msg->GetDisplayOriginatingAddress(&smsAddress);
            String messageBody;
            msg->GetDisplayMessageBody(&messageBody);
            // AutoPtr<ISystem> system;
            // Elastos::Core::CSystem::AcquireSingleton((ISystem**)&system);
            // Int64 now;
            // system->GetCurrentTimeMillis(&now);
            GeckoAppShell::NotifySmsReceived(smsAddress, messageBody, GetDisplayMessageBody);
        }
        return NOERROR;
    }