コード例 #1
0
// ---------------------------------------------------------------------------
//  CNSmlDmFotaAdapterDb::SetStrValueL()
//  Sets aValue as the value of aColumn in FW object identified by aObject.
// ---------------------------------------------------------------------------
// 
TInt CNSmlDmFotaAdapterDb::SetStrValueL( const TDesC& aColumn, 
                                         const TDesC8& aValue,
                                         const TNSmlDmFwObjectId aObject )
    {
    _DBG_FILE("CNSmlDmFotaAdapterDb::SetStrValueL(): begin");
    
    HBufC* value = ConvertTo16BitLC( aValue );
    
    DBG_ARGS( _S16("CNSmlDmFotaAdapterDb::SetStrValueL(): ('%S', '%S', %d)"), 
              &aColumn, value, aObject );
    
    TInt ret = UpdateRowL( aObject );
    
    if ( ret == KErrNone )
        {
        // do update
        iView.SetColL( iColSet->ColNo( aColumn ), *value );
        iView.PutL();
        }
    
    CommitAndCompact();
    
    CleanupStack::PopAndDestroy( value );
    
    _DBG_FILE("CNSmlDmFotaAdapterDb::SetStrValueL(): end");
    
    return ret;
    }
コード例 #2
0
// ---------------------------------------------------------------------------
//  CNSmlDmFotaAdapterDb::StrValueL()
//  Returns the value in FW object identified by aObject in column aColumn.
// ---------------------------------------------------------------------------
// 
HBufC8* CNSmlDmFotaAdapterDb::StrValueL( const TDesC& aColumn, 
                                         const TNSmlDmFwObjectId aObject )
    {
    DBG_ARGS( _S16("CNSmlDmFotaAdapterDb::StrValueL('%S', %d): begin"), 
              &aColumn, aObject );
    
    HBufC8* value = NULL;
    
    FetchRowL( aObject );
    
    if ( iView.FirstL() )
        {
        // get value
        iView.GetL();
        TPtrC res = iView.ColDes( iColSet->ColNo( aColumn ) );
        
        // convert to 8-bit
        value = HBufC8::NewL( res.Length() );
        value->Des().Copy( res );
        }
    
    _DBG_FILE("CNSmlDmFotaAdapterDb::StrValueL(): end");
    
    return value;
    }
/*!
 * Fetch contact
 */
TInt CNsmlContactsDataStoreExtensionPrivate::ExportContactsL( const TUid &uid, CBufBase &contactbufbase )
{
    DBG_ARGS(_S("CNsmlContactsDataStoreExtensionPrivate::ExportContactsL: BEGIN: UID: %d"), uid);
   
    TInt error(KErrNone);
    QList<QContact> contacts;
    QBuffer contactsbuf;
    contactsbuf.open(QBuffer::ReadWrite);    
    mWriter->setDevice( &contactsbuf );  
    QContact contact = mContactManager->contact( uid.iUid );
    error = mContactManager->error();
    if( error != QContactManager::NoError )
        {
        DBG_ARGS(_S("CNsmlContactsDataStoreExtensionPrivate::ExportContactsL:Error %d"), error );
        return error; 
        }
	contacts.append( contact );    
    
    if( mExporter->exportContacts( contacts, QVersitDocument::VCard21Type ) )
        {
        QList<QVersitDocument> documents = mExporter->documents();        
        mWriter->startWriting( documents );
        bool status = mWriter->waitForFinished();  
        DBG_ARGS(_S("CNsmlContactsDataStoreExtensionPrivate::ExportContactsL:status %d"), status);  
        HBufC8* buf = XQConversions::qStringToS60Desc8( contactsbuf.data() );
        contactbufbase.InsertL( contactbufbase.Size(), *buf );
        delete buf;
        }
    else
        {
        error = KErrGeneral;
        DBG_ARGS(_S("CNsmlContactsDataStoreExtensionPrivate::ExportContactsL:Error in exporting %d"), error );
        }
    
    TPtr8 ptrbuf(contactbufbase.Ptr(0));
    DBG_DUMP( (void*)ptrbuf.Ptr(), ptrbuf.Length(),
           _S8("CNsmlContactsDataStoreExtensionPrivate::ExportContactsL: From DB:"));  
    
    _DBG_FILE("CNsmlContactsDataStoreExtensionPrivate::ExportContactsL: END");
    
    return error;
}
/*!
 * Store contact
 */
CArrayFixFlat<TUid>* CNsmlContactsDataStoreExtensionPrivate::ImportContactsL( const TDesC8 &contactbufbase )
{
    _DBG_FILE("CNsmlContactsDataStoreExtensionPrivate::ImportContactsL: BEGIN");    

    DBG_DUMP((void*)contactbufbase.Ptr(), contactbufbase.Length(),
        _S8("CNsmlContactsDataStoreExtensionPrivate::ImportContactsL: To DB :"));      
    
    TBool ret( ETrue );
    CArrayFixFlat<TUid>* contactItems = new(ELeave) CArrayFixFlat<TUid>(4);
    QBuffer contactsbuf;
    contactsbuf.open(QBuffer::ReadWrite);
    QByteArray bytearray((char*)contactbufbase.Ptr());
    
    contactsbuf.write(bytearray);
    contactsbuf.seek(0);
    
    mReader->setDevice(&contactsbuf);
    if (mReader->startReading() && mReader->waitForFinished()) 
        {
        DBG_ARGS(_S("CNsmlContactsDataStoreExtensionPrivate::Buffer Count: %d"), mReader->results().count() );
        
        QList<QContact> contacts;
        if ( mImporter->importDocuments( mReader->results() ) )
            {
            contacts = mImporter->contacts();
            QMap<int, QContactManager::Error> errorMap;
            ret = mContactManager->saveContacts( &contacts, &errorMap );           
            DBG_ARGS(_S("CNsmlContactsDataStoreExtensionPrivate::Import Status: %d"), ret );
            }
        if( ret )
            {
            foreach (QContact contact, contacts ) 
                {
                TUint contactid = contact.id().localId();
                
                DBG_ARGS(_S("CNsmlContactsDataStoreExtensionPrivate::Contact ID: %d"), contactid );
                
                contactItems->AppendL( TUid::Uid( contactid ) );
                }
            }
コード例 #5
0
int SQLQueryf( PODBC odbc, CTEXTSTR *result, CTEXTSTR fmt, ... )
{
	int result_code;
	PTEXT cmd;
	PVARTEXT pvt = VarTextCreate();
	va_list args;
	va_start( args, fmt );
	vvtprintf( pvt, fmt, args );
	cmd = VarTextGet( pvt );
	VarTextDestroy( &pvt );
	result_code = SQLQueryEx( odbc, (CTEXTSTR)GetText( cmd ), result DBG_ARGS(SQLQueryf) );
	LineRelease( cmd );
	return result_code;
}
コード例 #6
0
int DoSQLRecordQueryf( int *nResults, CTEXTSTR **result, CTEXTSTR **fields, CTEXTSTR fmt, ... )
{
	int result_code;
	PTEXT cmd;
	PVARTEXT pvt = VarTextCreate();
	va_list args;
	va_start( args, fmt );
	vvtprintf( pvt, fmt, args );
	cmd = VarTextGet( pvt );
	VarTextDestroy( &pvt );
	result_code = SQLRecordQueryEx( NULL, GetText( cmd ), nResults, result, fields DBG_ARGS(DoSQLRecordQueryf) );
	LineRelease( cmd );
	return result_code;
}
コード例 #7
0
int DoSQLCommandf( CTEXTSTR fmt, ... )
{
	int result;
	PTEXT cmd;
	PVARTEXT pvt = VarTextCreate();
	va_list args;
	va_start( args, fmt );
	vvtprintf( pvt, fmt, args );
	cmd = VarTextGet( pvt );
	VarTextDestroy( &pvt );
	result = DoSQLCommandEx( GetText( cmd ) DBG_ARGS(DoSQLCommandf) );
	LineRelease( cmd );
	return result;
}
/*!
 * Constructor
 */
CNsmlContactsDataStoreExtensionPrivate::CNsmlContactsDataStoreExtensionPrivate(const TDesC &manager )
{
    _DBG_FILE("CNsmlContactsDataStoreExtensionPrivate::CNsmlContactsDataStoreExtensionPrivate: BEGIN");
    
    // Get the QString manager
    mManagerName = QString::fromUtf16(manager.Ptr(),manager.Length());
    
    DBG_ARGS(_S("CNsmlContactsDataStoreExtensionPrivate::Manager: %S"), &manager );
    
    mWriter = new QVersitWriter;
    mReader = new QVersitReader;
    mExporter = new QVersitContactExporter;
    mImporter = new QVersitContactImporter;
    
    // Instantiate the Contact Manager
    mContactManager = NULL;
    QStringList availableManagers = QContactManager::availableManagers();  
    
    DBG_ARGS(_S("CNsmlContactsDataStoreExtensionPrivate::Manager Count: %d"), availableManagers.count());
    
    foreach (const QString manager, availableManagers)
    {
        if( mManagerName == manager )
        {
            _DBG_FILE("CNsmlContactsDataStoreExtensionPrivate::Got a Match");
            mContactManager = QContactManager::fromUri(QContactManager::buildUri(manager, QMap<QString, QString>()));
        }
    }
    if( mContactManager == NULL )
    {
    _DBG_FILE("CNsmlContactsDataStoreExtensionPrivate::Did Not Find a Match");
        mContactManager = new QContactManager( mManagerName );
    }
   
   _DBG_FILE("CNsmlContactsDataStoreExtensionPrivate::CNsmlContactsDataStoreExtensionPrivate: END");
}
コード例 #9
0
int SQLCommandf( PODBC odbc, CTEXTSTR fmt, ... )
{
	int result;
	PTEXT cmd;
	PVARTEXT pvt = VarTextCreateExx( 4096, 16384 * 16 );
	va_list args;
	va_start( args, fmt );
	vvtprintf( pvt, fmt, args );
	cmd = VarTextGet( pvt );
	if( cmd )
	{
		VarTextDestroy( &pvt );
		result = SQLCommandEx( odbc, GetText( cmd ) DBG_ARGS(SQLCommandf) );
		LineRelease( cmd );
	}
	else
		lprintf( WIDE("ERROR: Sql format failed: %s"), fmt );
	return result;
}
コード例 #10
0
// ---------------------------------------------------------------------------
//  CNSmlDmFotaAdapterDb::LongStrValueL()
//  Returns the value in FW object identified by aObject in column aColumn.
// ---------------------------------------------------------------------------
// 
HBufC8* CNSmlDmFotaAdapterDb::LongStrValueL( const TDesC& aColumn, 
                                             const TNSmlDmFwObjectId aObject )
    {
    DBG_ARGS( _S16("CNSmlDmFotaAdapterDb::LongStrValueL('%S', %d): begin"), 
              &aColumn, aObject );
    
    HBufC8* value = NULL;
    
    FetchRowL( aObject );
    
    if ( iView.FirstL() )
        {
        // get value
        iView.GetL();
        
        RDbColReadStream rStream;
        rStream.OpenL( iView, iColSet->ColNo( aColumn ) );
        CleanupClosePushL( rStream );
        
        TInt length = 0;
        TRAPD( err, length = rStream.ReadInt32L() );
        
        HBufC* buf = HBufC::NewLC( length );
        TPtr bufPtr = buf->Des();
        
        if ( err == KErrNone )
            {
            rStream.ReadL( bufPtr, length );
            }
        
        // convert to 8-bit
        value = HBufC8::NewL( bufPtr.Length() );
        value->Des().Copy( bufPtr );
        
        CleanupStack::PopAndDestroy( buf );
        CleanupStack::PopAndDestroy( &rStream );
        }
    
    _DBG_FILE("CNSmlDmFotaAdapterDb::LongStrValueL(): end");
    
    return value;
    }
コード例 #11
0
// ---------------------------------------------------------------------------
//  CNSmlDmFotaAdapterDb::IntValueL()
//  Returns the value in FW object identified by aObject in column aColumn.
// ---------------------------------------------------------------------------
// 
TInt CNSmlDmFotaAdapterDb::IntValueL( const TDesC& aColumn,
                                      const TNSmlDmFwObjectId aObject )
    {
    DBG_ARGS( _S16("CNSmlDmFotaAdapterDb::IntValueL('%S', %d): begin"), 
              &aColumn, aObject );
    
    TInt value = KErrNotFound;
    
    FetchRowL( aObject );
    
    if ( iView.FirstL() )
        {
        iView.GetL();
        value = iView.ColInt( iColSet->ColNo( aColumn ) );
        }
    
    _DBG_FILE("CNSmlDmFotaAdapterDb::IntValueL(): end");
    
    return value;
    }
コード例 #12
0
// ---------------------------------------------------------------------------
//  CNSmlDmFotaAdapterDb::SetIntValueL()
//  Sets aValue as the value of aColumn in FW object identified by aObject.
// ---------------------------------------------------------------------------
// 
TInt CNSmlDmFotaAdapterDb::SetIntValueL( const TDesC& aColumn, 
                                         const TInt aValue, 
                                         const TNSmlDmFwObjectId aObject )
    {
    _DBG_FILE("CNSmlDmFotaAdapterDb::SetIntValueL(): begin");
    DBG_ARGS( _S16("CNSmlDmFotaAdapterDb::SetIntValueL(): ('%S', %d, %d)"), 
              &aColumn, aValue, aObject );
    
    TInt ret = UpdateRowL( aObject );
    
    if ( ret == KErrNone )
        {
        // do update
        iView.SetColL( iColSet->ColNo( aColumn ), aValue );
        iView.PutL();
        }
    
    CommitAndCompact();
    
    _DBG_FILE("CNSmlDmFotaAdapterDb::SetIntValueL(): end");
    
    return ret;
    }
コード例 #13
0
// ---------------------------------------------------------------------------
//  CNSmlDmFotaAdapterDb::SetLongStrValueL()
//  Streams aValue and its length as the value of aColumn in FW object 
//  identified by aObject.
// ---------------------------------------------------------------------------
// 
TInt CNSmlDmFotaAdapterDb::SetLongStrValueL( const TDesC& aColumn, 
                                             const TDesC8& aValue, 
                                             const TNSmlDmFwObjectId aObject )
    {
    _DBG_FILE("CNSmlDmFotaAdapterDb::SetLongStrValueL(): begin");
    
    HBufC* value = ConvertTo16BitLC( aValue );
    
    DBG_ARGS( _S16("CNSmlDmFotaAdapterDb::SetStrValueL(): ('%S', '%S', %d)"),
              &aColumn, value, aObject );
    
    TInt ret = UpdateRowL( aObject );
    
    if ( ret == KErrNone )
        {
        // do update
        
        RDbColWriteStream wStream;
        wStream.OpenL( iView, iColSet->ColNo( aColumn ) );
        CleanupClosePushL( wStream );
        
        wStream.WriteInt32L( value->Length() );
        wStream.WriteL( *value, value->Length() );
        
        CleanupStack::PopAndDestroy( &wStream );
        
        iView.PutL();
        }
    
    CommitAndCompact();
    
    CleanupStack::PopAndDestroy( value );
    
    _DBG_FILE("CNSmlDmFotaAdapterDb::SetLongStrValueL(): end");
    
    return ret;
    }
コード例 #14
0
// -----------------------------------------------------------------------------
// CNSmlDsProvisioningAdapter::VisitL
// -----------------------------------------------------------------------------
void CNSmlDsProvisioningAdapter::VisitL( CWPParameter& aParameter)
	{
	_DBG_FILE("CNSmlDsProvisioningAdapter::VisitL(CWPParameter): begin");
	TInt num;
	TInt flag =0;
	
	
	if( iState == CNSmlDsProvisioningAdapter::EStateApplication )
		{
		if( aParameter.ID() == EWPParameterAppID && aParameter.Value().Compare( KNSmlDsProvisioningDMAppIdVal ) == 0 )
			{
			iState = CNSmlDsProvisioningAdapter::EStateDsSettings;

			GetTitleL();

			CNSmlDsProfileElement* dsProfileElement = new(ELeave) CNSmlDsProfileElement;
			CleanupStack::PushL( dsProfileElement );
			
			dsProfileElement->iDisplayName = KNSmlDsProvisioningDefName().AllocL();			
			dsProfileElement->iServerAlertedAction = ESmlConfirmSync;			

			dsProfileElement->iVisitParameter = 0;

			iProfiles.AppendL( dsProfileElement );	
			
			iProfiles[iProfiles.Count()-1]->iProtocolVersion = ESmlVersion1_2;
			CleanupStack::Pop( dsProfileElement );
			}
		else
			{
			iState = CNSmlDsProvisioningAdapter::EStateNull;
			}
		}
	else if( iState == CNSmlDsProvisioningAdapter::EStateDsSettings )
		{
		switch ( aParameter.ID() )
			{
			case EWPParameterName:
			case EWPParameterName1:
			{
				_DBG_FILE("CNSmlDsProvisioningAdapter::VisitL(CWPParameter): Name");
				DBG_ARGS( aParameter.Value().Ptr() );
				
				if ( iProfiles[iProfiles.Count()-1]->iDisplayName )
				    {
				    delete iProfiles[iProfiles.Count()-1]->iDisplayName;
				    iProfiles[iProfiles.Count()-1]->iDisplayName = NULL;
				    }
					/*parameter exceeding 50 characters truncate to 50 and save the item*/
					if(aParameter.Value().Length()>50)
					{
						TPtrC ptr2 = aParameter.Value().Left(50);
						iProfiles[iProfiles.Count()-1]->iDisplayName = ptr2.AllocL();	
					}
					else
				iProfiles[iProfiles.Count()-1]->iDisplayName = aParameter.Value().AllocL();				
					
	    			
					/* parameter is NULL set to default value*/	    		
	    			num = iProfiles[iProfiles.Count()-1]->iDisplayName->Length();
	    			
					
					TInt i;
					/*check for white spaces, If all characters are white spaces set to default*/
					TPtr temp = iProfiles[iProfiles.Count()-1]->iDisplayName->Des();
					for(i=0; i<iProfiles[iProfiles.Count()-1]->iDisplayName->Length(); i++)
	    			{
	    				
	    				
	    				if(temp[i] != ' ')
	    				break;
	    			}
	    			
	    			if(i == num || num == 0 )
	    			  flag =1;
	    			
	    			if(flag)
	    			{
	    				if ( iProfiles[iProfiles.Count()-1]->iDisplayName )
				    	{
				    	delete iProfiles[iProfiles.Count()-1]->iDisplayName;
				    	iProfiles[iProfiles.Count()-1]->iDisplayName = NULL;
				    	}
				    	iProfiles[iProfiles.Count()-1]->iDisplayName = KNSmlDsProvisioningDefName().AllocL();
	    			}
			}
				break;
			
			case EWPParameterToProxy:	
				_DBG_FILE("CNSmlDmProvisioningAdapter::VisitL(CWPParameter): ToProxy");
			case EWPParameterToNapID:
			case EWPParameterToNapID1:
                        {
                        TPtrC ptrToNapID(aParameter.Value());
                        if(ptrToNapID.CompareF(KInternetString)==0)
                        iToNapIDInternetIndicator = ETrue;
                        }
				break;

			case EWPParameterPortNbr:
			case EWPParameterPortNbr1:
				_DBG_FILE("CNSmlDsProvisioningAdapter::VisitL(CWPParameter): PortNbr");
				DBG_ARGS( aParameter.Value().Ptr() );
				iProfiles[iProfiles.Count()-1]->iPort = aParameter.Value().AllocL();
				break;

			case EWPParameterAddr:
				_DBG_FILE("CNSmlDsProvisioningAdapter::VisitL(CWPParameter): Addr");
				DBG_ARGS( aParameter.Value().Ptr() );
				iProfiles[iProfiles.Count()-1]->iHostAddress = aParameter.Value().AllocL();
				break;

			case EWPParameterProviderID:
				_DBG_FILE("CNSmlDsProvisioningAdapter::VisitL(CWPParameter): ProviderId");
				DBG_ARGS( aParameter.Value().Ptr() );
				if(aParameter.Value().Length()<=150)
				{
				iProfiles[iProfiles.Count()-1]->iServerId = ConvertTo8LC( aParameter.Value() ).AllocL();				
				CleanupStack::PopAndDestroy(); // ConvertTo8LC
			  }
				break;
				
			case EWPParameterAProtocol:
				_DBG_FILE("CNSmlDsProvisioningAdapter::VisitL(CWPParameter): AProtocol:Version");
				DBG_ARGS( aParameter.Value().Ptr() );
				//TPtrC ptr(aParameter.Value());
				if(aParameter.Value().Compare(KNSmlVersion112)==0)
				{
					iProfiles[iProfiles.Count()-1]->iProtocolVersion = ESmlVersion1_1_2;	
				}
				
				else 
				if(aParameter.Value().Compare(KNSmlVersion11)==0)
				{
					iProfiles[iProfiles.Count()-1]->iProtocolVersion = ESmlVersion1_1_2;	
				}
				
				else
				{
					iProfiles[iProfiles.Count()-1]->iProtocolVersion = ESmlVersion1_2;	
				}
				
				
				
				break;
			default:
				break;
			}
		
		}
	else if( iState == CNSmlDsProvisioningAdapter::EStateAppAuth )
		{
		switch ( aParameter.ID() )
			{
			case EWPParameterAAuthType:
				_DBG_FILE("CNSmlDsProvisioningAdapter::VisitL(CWPParameter): AuthType");
				DBG_ARGS( aParameter.Value().Ptr() );
				if (( aParameter.Value().Compare( KNSmlDSProvisioningHTTPBasic ) == 0 ) ||
					( aParameter.Value().Compare( KNSmlDSProvisioningHTTPDigest ) == 0 ))
					{
					_DBG_FILE("CNSmlDsProvisioningAdapter::VisitL(CWPParameter): HTTP");
					iAuthLevel = CNSmlDsProvisioningAdapter::EHttp;
					} 
				break;

			case EWPParameterAAuthName:
				_DBG_FILE("CNSmlDsProvisioningAdapter::VisitL(CWPParameter): AuthName");
				DBG_ARGS( aParameter.Value().Ptr() );
				if(aParameter.Value().Length()<=80)
				{
				if ( iAuthLevel == CNSmlDsProvisioningAdapter::EHttp )
					{
					iProfiles[iProfiles.Count()-1]->iHTTPUserName = ConvertTo8LC( aParameter.Value() ).AllocL();
					CleanupStack::PopAndDestroy(); // ConvertTo8LC
					}
				else
					{
					iProfiles[iProfiles.Count()-1]->iUsername = ConvertTo8LC( aParameter.Value() ).AllocL();					
					CleanupStack::PopAndDestroy(); // ConvertTo8LC
					}
				}
				break;

			case EWPParameterAAuthSecret:
				_DBG_FILE("CNSmlDsProvisioningAdapter::VisitL(CWPParameter): AuthSecret");
				DBG_ARGS(aParameter.Value().Ptr());
				if(aParameter.Value().Length()<=22)
				{
					if ( iAuthLevel == CNSmlDsProvisioningAdapter::EHttp )
					{
					iProfiles[iProfiles.Count()-1]->iHTTPPassword = ConvertTo8LC( aParameter.Value() ).AllocL();
					CleanupStack::PopAndDestroy(); // ConvertTo8LC
					}
				else
					{
					iProfiles[iProfiles.Count()-1]->iPassword = ConvertTo8LC( aParameter.Value() ).AllocL();					
					CleanupStack::PopAndDestroy(); // ConvertTo8LC
					}
				iState = CNSmlDsProvisioningAdapter::EStateDsSettings;
			 }
				break;
			default:
				break;
			}
		}

	else if( iState == CNSmlDsProvisioningAdapter::EStateResource )
		{
		TInt iDataProvElementCount = iProfiles[iProfiles.Count()-1]->iDataProvElement.Count(); 
		if( iDataProvElementCount == 0 )
			{
			CNSmlDataProviderElement* dataProviderElement = new(ELeave) CNSmlDataProviderElement;
			CleanupStack::PushL( dataProviderElement );
			iProfiles[iProfiles.Count()-1]->iDataProvElement.AppendL( dataProviderElement );
			CleanupStack::Pop( dataProviderElement );
			}
		else if ( (iProfiles[iProfiles.Count()-1]->iDataProvElement[iDataProvElementCount-1]->iRemoteDBUri != 0) &&
			 	  (iProfiles[iProfiles.Count()-1]->iDataProvElement[iDataProvElementCount-1]->iUid != 0) &&
			 	  ( ( aParameter.ID() == EWPParameterURI ) || ( aParameter.ID() == EWPParameterAAccept ) ) )
		{
			// another resource element recognized
			CNSmlDataProviderElement* dataProviderElement = new(ELeave) CNSmlDataProviderElement;
			CleanupStack::PushL( dataProviderElement );
			iProfiles[iProfiles.Count()-1]->iDataProvElement.AppendL( dataProviderElement );
			CleanupStack::Pop( dataProviderElement );
		}
		
		switch ( aParameter.ID() )
			{
			case EWPParameterName:
			case EWPParameterName1:
				break;

			case EWPParameterURI:
				_DBG_FILE("CNSmlDsProvisioningAdapter::VisitL(CWPParameter): RemoteDBURI");
				DBG_ARGS( aParameter.Value().Ptr() );
				if(aParameter.Value().Length() <= 125)
				{
				iProfiles[iProfiles.Count()-1]->iDataProvElement[iProfiles[iProfiles.Count()-1]->iDataProvElement.Count()-1]->iRemoteDBUri =
						aParameter.Value().AllocL();
				}
				break;

			case EWPParameterAAccept:
				_DBG_FILE("CNSmlDsProvisioningAdapter::VisitL(CWPParameter): AAccept (mime)");
				StoreAttributesL( aParameter.Value() );
				iState = CNSmlDsProvisioningAdapter::EStateDsSettings;
				break;
			default:
				break;
			}
		}
		
	_DBG_FILE("CNSmlDsProvisioningAdapter::VisitL(CWPParameter): end");
	}
コード例 #15
0
// -----------------------------------------------------------------------------
// CNSmlDsProvisioningAdapter::SaveL
// -----------------------------------------------------------------------------
void CNSmlDsProvisioningAdapter::SaveL(TInt aItem)
	{
	_DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): begin");
	TPckgBuf<TUint32> uid;
	
	RSyncMLDataSyncProfile profile;
	TBool ret = EFalse;
	
	if(iProfiles[aItem]->iServerId != NULL)
	{
	RSyncMLDataSyncProfile ProfileToSearch;
	RArray<TSmlProfileId> arr;
    iSession.ListProfilesL( arr, ESmlDataSync );
    
    TInt ProfileId = KErrNotFound;
    CleanupClosePushL(arr);   	
	for ( TInt index = 0; index < arr.Count(); index++ )
		{
	    TRAPD( error, ProfileToSearch.OpenL(iSession, arr[index], ESmlOpenRead ) );
	    if ( error == KErrNone )
	        {	            	            	        
    	        if ( ( iProfiles[aItem]->iServerId->Des()).Compare(ProfileToSearch.ServerId() ) == 0 )
    	            {
    	            
                    ret = ETrue;                    
                    ProfileId = (TInt)arr[index];
                    ProfileToSearch.Close();
                    break;
                    }	            		    
	        }
	      ProfileToSearch.Close();  
		}
    CleanupStack::PopAndDestroy( &arr );
	
	if( ret )
		{
		profile.OpenL(iSession, ProfileId , ESmlOpenReadWrite );	
		}
	else
		{
	profile.CreateL( iSession );
		}
	CleanupClosePushL( profile );	
	}
	else
	{
		
		profile.CreateL( iSession );
		CleanupClosePushL( profile );	
	}
	
	// ui needs this to be set 0
	profile.SetCreatorId(0);//iProfiles[aItem]->iProfile.SetCreatorId(0);
	profile.SetSanUserInteractionL( iProfiles[aItem]->iServerAlertedAction );
	
	if ( iProfiles[aItem]->iDisplayName )
	    {
	    profile.SetDisplayNameL( iProfiles[aItem]->iDisplayName->Des() );    
	    }
	
	if ( iProfiles[aItem]->iServerId )
	    {
	    profile.SetServerIdL( iProfiles[aItem]->iServerId->Des() );    
	    }
	    
	if ( iProfiles[aItem]->iUsername )   
	    {
	    profile.SetUserNameL( iProfiles[aItem]->iUsername->Des() );    
	    }
	
	if ( iProfiles[aItem]->iPassword )
	    {
	    profile.SetPasswordL( iProfiles[aItem]->iPassword->Des() );    
	    }
	    
	// creates profile -> must be done before opening the connection
	profile.UpdateL();
		
	RSyncMLConnection connection;
	connection.OpenL( profile, KUidNSmlMediumTypeInternet.iUid );
	CleanupClosePushL( connection );
		
    if ( (iProfiles[aItem]->iVisitParameter
            && iProfiles[aItem]->iVisitParameter->Data().Length() == uid.MaxLength() )
            || iToNapIDInternetIndicator)
		{
        TUint apId = 0;
        TInt ERROR = KErrNone;
        TInt err1 = KErrNone;

        if (iToNapIDInternetIndicator)
            {
            //Get Access Point from DB or SNAP
            TRAP(err1, apId = WPAdapterUtil::GetAPIDL());
            }

        else
            {
            uid.Copy(iProfiles[aItem]->iVisitParameter->Data() );

            RCmManagerExt  cmmanagerExt;
		    cmmanagerExt.OpenL();
		    CleanupClosePushL(cmmanagerExt);
		    RCmConnectionMethodExt cm;
		    cm = cmmanagerExt.ConnectionMethodL( uid());
		    CleanupClosePushL( cm );

            TRAP( ERROR, apId = cm.GetIntAttributeL(CMManager::ECmIapId) );
            CleanupStack::PopAndDestroy(2); //cmmanager,cm
            }

        //Get default access point in failure of getting AP
        if (ERROR != KErrNone || err1 != KErrNone)
			{
			apId = GetDefaultIAPL();
			}
		
		HBufC8* iapBuf = HBufC8::NewLC( 8 );
		TPtr8 ptrBuf = iapBuf->Des();
		ptrBuf.Num( apId );
		
		connection.SetPropertyL( KNSmlIAPId, *iapBuf );
			
        CleanupStack::PopAndDestroy(); //iapBuf	
		}
		
	if( iProfiles[aItem]->iHostAddress )
		{
		// see if address contains also port
		TBool portFound = EFalse;
		TInt startPos(0);
		if(iProfiles[aItem]->iHostAddress->Find(KNSmlDsProvisioningHTTP)==0)
		    {
		    startPos=KNSmlDsProvisioningHTTP().Length();		    		    
		    }
		else if(iProfiles[aItem]->iHostAddress->Find(KNSmlDsProvisioningHTTPS)==0)
		    {
		    startPos=KNSmlDsProvisioningHTTPS().Length();		    		    
		    }
		TPtrC uriPtr = iProfiles[aItem]->iHostAddress->Mid(startPos);
		
		if(uriPtr.Locate(KNSmlDMColon)!=KErrNotFound)
		    {
			portFound = ETrue;
		    }
	
		if( portFound == EFalse )
			{
			HBufC *uri = 0;
			// port not found from URI -> see if it is given separately				
			if( iProfiles[aItem]->iPort )
				{
				// parse address and port into URI
			
				if( CombineURILC( iProfiles[aItem]->iHostAddress->Des(),
							  iProfiles[aItem]->iPort->Des(), uri ) == KErrNone )
					{
					if(iProfiles[aItem]->iHostAddress)
					{
						delete iProfiles[aItem]->iHostAddress;
						iProfiles[aItem]->iHostAddress = NULL;
					}
					iProfiles[aItem]->iHostAddress = uri->Des().AllocL();
					}
				CleanupStack::PopAndDestroy(); // uri		  
				}
			else
				{
				// use default port
				if( CombineURILC( iProfiles[aItem]->iHostAddress->Des(),
							  KNSmlDsDefaultPort(), uri ) == KErrNone )
					{
					if(iProfiles[aItem]->iHostAddress)
					{
						delete iProfiles[aItem]->iHostAddress;
						iProfiles[aItem]->iHostAddress = NULL;
					}
					iProfiles[aItem]->iHostAddress = uri->Des().AllocL();
					}
				CleanupStack::PopAndDestroy(); // uri		  
				}
			}
		

		connection.SetServerURIL( ConvertTo8LC( iProfiles[aItem]->iHostAddress->Des() ) );
		CleanupStack::PopAndDestroy(); // ConvertTo8LC
		}
		
	// set authtype, HTTPUserName, HTTPPassword
	if( iProfiles[aItem]->iHTTPUserName ||
	    iProfiles[aItem]->iHTTPPassword )
		{
		connection.SetPropertyL( KNSmlHTTPAuth, KNSmlTrueVal );
		
		if( iProfiles[aItem]->iHTTPUserName )
			{
			connection.SetPropertyL( KNSmlHTTPUsername, iProfiles[aItem]->iHTTPUserName->Des() );
			}
		if( iProfiles[aItem]->iHTTPPassword )
			{
			connection.SetPropertyL( KNSmlHTTPPassword, iProfiles[aItem]->iHTTPPassword->Des() );
			}
		}
	else
		{
		connection.SetPropertyL( KNSmlHTTPAuth, KNSmlFalseVal );
		}
		
	connection.UpdateL();
	CleanupStack::PopAndDestroy(); // connection
	
	
		
	
	
	if(iProfiles[aItem]->iProtocolVersion == ESmlVersion1_1_2 || 
			iProfiles[aItem]->iProtocolVersion == ESmlVersion1_2 )
	{
		profile.SetProtocolVersionL(iProfiles[aItem]->iProtocolVersion);
	}

	
	
	
	
		
	TInt iDataProvElementCount = iProfiles[aItem]->iDataProvElement.Count();
	_DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): Resource For loop: before Start");
	for ( TInt i = 0; i < iDataProvElementCount; i++ )
		{
        _DBG_FILE(
                "CNSmlDsProvisioningAdapter::SaveL(): Resource For loop: In");
		RSyncMLDataProvider dataProvider;

        TRAPD(error, dataProvider.OpenL(iSession,
                iProfiles[aItem]->iDataProvElement[i]->iUid));
		if (!error)
		    {
		    CleanupClosePushL(dataProvider);
            if (ret)
                {
                RArray<TSmlTaskId> providers;
                profile.ListTasksL(providers);
                TInt dataprovcount = providers.Count();

                for (TInt i = 0; i < dataprovcount; i++)
                    {
                    TSmlTaskId taskID = providers[i];
                    RSyncMLTask task;
                    task.OpenL(profile, taskID);
                    CleanupClosePushL(task);

                    if (dataProvider.Identifier() == task.DataProvider())
                        {
                        profile.DeleteTaskL(taskID);
                        CleanupStack::PopAndDestroy();
                        break;
                        }

                    CleanupStack::PopAndDestroy();

                    }
                providers.Reset();
                providers.Close();

                }
            HBufC* localDB = dataProvider.DefaultDataStoreName().AllocLC();
            _DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): DB value");
            DBG_ARGS(
                    iProfiles[aItem]->iDataProvElement[i]->iRemoteDBUri->Des().Ptr());

            RSyncMLTask task;
            task.CreateL(
                    profile,
                    iProfiles[aItem]->iDataProvElement[i]->iUid,
                    iProfiles[aItem]->iDataProvElement[i]->iRemoteDBUri->Des(),
                    localDB->Des());
            CleanupClosePushL(task);
            TRAPD(err, task.UpdateL());
            if (err != KErrAlreadyExists && err != KErrNone)
                {
                User::Leave(err);
                }
            CleanupStack::PopAndDestroy(3); // task, localDB, dataProvider
		    }
		
		}
	_DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): Resource For loop: after End");
				
	profile.UpdateL();
	iProfiles[aItem]->iProfileId = profile.Identifier();
	CleanupStack::PopAndDestroy( &profile );
	_DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): end");
	}