void DiscoveryClient_DiscoveryClientFSM::sendQueryMessageAction(GuiControlEntered msg)
{
	/// Insert User Code HERE
    cout << "Sending query:" << msg.getGuiControlEnteredBody()->getGuiControlEnteredRecord()->getCommand() << endl;
    // see which query message I should send and send it
    // Cmd 1 - Query Identification
    // Cmd 2 - Query Services
    // Cmd 3 - Query Configuration
    // Cmd 4 - Query Subsystem List
    // Cmd 5 - Query Services List
    switch (msg.getGuiControlEnteredBody()->getGuiControlEnteredRecord()->getCommand()) {
        case QUERYIDENTIFICATION: {
            QueryIdentification qry;
            JausAddress recipient(msg.getGuiControlEnteredBody()->getGuiControlEnteredRecord()->getValue());
            cout << "Send QueryIdentification to: " << hex << (unsigned int)recipient.getSubsystemID() << ":"
                 << (unsigned int)recipient.getNodeID() << ":" << (unsigned int)recipient.getComponentID() << endl;
            sendJausMessage( qry, recipient);
        }
        break;
        case QUERYSERVICES: {
            cout << "Send QueryServices." << endl;
            QueryServices qry;
            // broadcast query to specified discovery service
            JausAddress recipient(msg.getGuiControlEnteredBody()->getGuiControlEnteredRecord()->getValue());
            sendJausMessage( qry, recipient);               
        }
        break;
        case QUERYCONFIGURATION:
            cout << "Send QueryConfiguration." << endl;
        break;
        case QUERYSUBSYSTEMLIST:
            cout << "Send QuerySubsystemList." << endl;
        break;
        case QUERYSERVICESLIST:
            cout << "Send QueryServicesList." << endl;
        break;
        default:
            cout << "Unknown GUI command." << endl;
        break;
        
    }
    
}
Пример #2
0
bool DSN::allFailed() const
{
    List<Recipient>::Iterator recipient( recipients() );
    while ( recipient ) {
        if ( recipient->action() != Recipient::Failed )
            return false;
        ++recipient;
    }
    return true;
}
Пример #3
0
bool DSN::deliveriesPending() const
{
    List<Recipient>::Iterator recipient( recipients() );
    while ( recipient ) {
        if ( recipient->action() == Recipient::Unknown ||
             recipient->action() == Recipient::Delayed )
            return true;
        ++recipient;
    }
    return false;
}
Пример #4
0
bool DSN::allOk() const
{
    List<Recipient>::Iterator recipient( recipients() );
    while ( recipient ) {
        if ( recipient->action() != Recipient::Delivered &&
             recipient->action() != Recipient::Relayed &&
             recipient->action() != Recipient::Expanded )
            return false;
        ++recipient;
    }
    return true;
}
Пример #5
0
EString DSN::plainBody() const
{
    EString r;
    List<Recipient>::Iterator recipient( recipients() );
    while ( recipient ) {
        EString tmp = recipient->plainTextParagraph();
        if ( !tmp.isEmpty() ) {
            r.append( tmp.wrapped( 72, "", "", true ).crlf() );
            r.append( "\r\n" );
        }
        ++recipient;
    }

    // this code sneakily ensures that the ideal line wrap point is
    // just before the server name, almost independent of the server
    // name's length. fine for testing.
    r.append( "This message was generated by Archiveopteryx " );
    r.append( Configuration::compiledIn( Configuration::Version ) );
    r.append( ", running on mail server \r\n" );
    r.append( Configuration::hostname() );
    r.append( ".\r\n" );

    if ( arrivalDate() && !receivedFrom().isEmpty() ) {
        EString tmp = "\nThe message arrived at ";
        tmp.append( arrivalDate()->isoDate() );
        tmp.append( ", " );
        tmp.append( arrivalDate()->isoTime() );
        tmp.append( " from host " );
        tmp.append( receivedFrom() );
        tmp.append( "." );
        r.append( tmp.wrapped( 72, "", "", true ).crlf() );
    }
    else if ( arrivalDate() ) {
        EString tmp = "\nThe message arrived at ";
        tmp.append( arrivalDate()->isoDate() );
        tmp.append( "." );
        r.append( tmp.wrapped( 72, "", "", true ).crlf() );
    }
    else if ( !receivedFrom().isEmpty() ) {
        EString tmp = "\nThe message was received from host ";
        tmp.append( receivedFrom() );
        tmp.append( "." );
        r.append( tmp.wrapped( 72, "", "", true ).crlf() );
    }

    return r;
}
//---------------------------------------------------------------
// TestUniDataModelPlugin::createMMS
//---------------------------------------------------------------
void TestUniDataModelMMSPlugin::createMMS(TMsvId pId, TBool subjectField)
    {
    TMsvEntry indexEntry;
    indexEntry.iType = KUidMsvMessageEntry;
    indexEntry.iMtm = KUidMsgTypeMultimedia;
    indexEntry.iServiceId = iServiceId;
    indexEntry.iDate.HomeTime();
    
    // Convert TTime to QDateTime , this will be used for comparing the time of mesage 
    // when fetched from datamodel
    TTime unixEpoch(KUnixEpoch);
    TTimeIntervalSeconds seconds;
    TTime timeStamp = indexEntry.iDate;
    timeStamp.SecondsFrom(unixEpoch, seconds);
    retTimeStamp.setTime_t(seconds.Int());

    TMsvId parentId = pId;
    CMsvEntry* entry = CMsvEntry::NewL(*iMSession,parentId,TMsvSelectionOrdering());
    CleanupStack::PushL(entry);

    entry->SetEntryL(parentId);
    entry->CreateL(indexEntry);
    entry->SetEntryL(indexEntry.Id());
    iMmsClientMtm->SwitchCurrentEntryL(entry->EntryId());

    CMsvStore* store = iMmsClientMtm->Entry().EditStoreL();
    CleanupStack::PushL(store);
      
    //MMS Message ID Saved
    iMessageId = indexEntry.Id();
    
    //Adding Subject
    if(subjectField)
        {
        QString subject(TEST_MSG_SUBJECT);
        HBufC* subj = XQConversions::qStringToS60Desc(subject);
        iMmsClientMtm->SetSubjectL(*subj);
        }

    //Adding Sender
    QString sender(TEST_MSG_FROM1);
    HBufC* addr = XQConversions::qStringToS60Desc(sender);
    
    if (addr)
        {
        CleanupStack::PushL(addr);
        TBuf<32> name;
        name.Copy(addr->Left(32));
        indexEntry.iDetails.Set(name);
        
        iMmsClientMtm->SetSenderL(*addr);
        
        CleanupStack::PopAndDestroy(addr);
        }
    
    //Adding Recipient
    QString recipient(TEST_MSG_RECIEPIENT1);
    HBufC* addr2 = XQConversions::qStringToS60Desc(recipient);
    if (addr2)
        {
        CleanupStack::PushL(addr2);
        iMmsClientMtm->AddAddresseeL(EMsvRecipientTo,*addr2);
        CleanupStack::PopAndDestroy(addr2);
        }
    
    //Adding cCRecipient
    QString recipient2(TEST_MSG_RECIEPIENT2);
    HBufC* addr3 = XQConversions::qStringToS60Desc(recipient2);
    if (addr3)
        {
        CleanupStack::PushL(addr3);
        iMmsClientMtm->AddAddresseeL(EMsvRecipientCc,*addr3);
        CleanupStack::PopAndDestroy(addr3);
        }
      
    //Adding bCCRecipient
    QString recipient3(TEST_MSG_RECIEPIENT3);
	HBufC* addr4 = XQConversions::qStringToS60Desc(recipient3);
	if (addr4)
		{
		CleanupStack::PushL(addr4);
		iMmsClientMtm->AddAddresseeL(EMsvRecipientBcc,*addr4);
		CleanupStack::PopAndDestroy(addr4);
		}
	
    //Create Text Attachment
    TMsvAttachmentId attaId = 0;
    TFileName attachmentFile( _L("story.txt") );
    TBufC<12> story = _L( "Hello world!" );
    
    iMmsClientMtm->CreateTextAttachmentL(*store, attaId, story, attachmentFile, ETrue );
    qDebug() << "Text Attachment id" << attaId;
    
    //Image Attachment added to the message entry
    RFile attaFile;
	// Set filename of attachment
	TFileName name( KPictureFileName );
   
	CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL();
	CleanupStack::PushL( mimeHeaders );
   
	// Set values to mime headers
	mimeHeaders->SetContentTypeL( _L8( "image") );
	mimeHeaders->SetContentSubTypeL( _L8( "jpeg" ) );
   
	_LIT8(KMimeType, "image/jpeg");
	TBufC8<10> mimeType(KMimeType);
	// CreateAttachment2L will set the content type to attachment Info
   
	// Open the attachment file for reading
	attaFile.Open( iFs, name, EFileShareReadersOnly | EFileRead );
	CleanupClosePushL(attaFile);
   
	CMsvAttachment* attaInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
	// attaInfo ownerhip will be transferred to Attachment Manager.
	// It must not be pushed onto the cleanupStack before calling 
	// CreateAttachment2L.
   
	iMmsClientMtm->CreateAttachment2L(*store, attaFile,mimeType,*mimeHeaders,attaInfo,attaId);
	qDebug() << "Image Attachment id" << attaId;
	
	// Now Attachment Manager owns the attaInfo
	CleanupStack::Pop(); // attaFile.Close()
	CleanupStack::PopAndDestroy(); // mimeHeaders
        
    store->CommitL();
    
    CleanupStack::PopAndDestroy(store); // store
    
    iMmsClientMtm->SaveMessageL();
    
    //Saving the message size for future checking
    msgSize = iMmsClientMtm->MessageSize();
    
    CleanupStack::Pop(entry); // entry
    }
Пример #7
0
void IRC::handle(const string& oline) {
    string line = trim(oline);
    printf("%s\n", line.c_str());

    //We are pinged, respond!
    if(line.compare(0, 4, "PING") == 0) {
        onServerPing(line.substr(5));
        return;
    }

    char* cstr = new char[line.size() + 1];
    strcpy(cstr, line.c_str());

    string sender, nick, login, host;

    bool nickOnly = false;
    size_t tokn = 0;
    char *tok = strtok(cstr, " ");
    while(tok != NULL) {
        //For each token, check
        string tmp = tok;
        if(tokn == 0) {
            sender = tmp;
            if(sender[0] == ':')
                sender = sender.substr(1);

            size_t exp = sender.find("!");
            size_t at = sender.find("@");

            //TODO: Add checks for 'exp' and 'at' being string::npos
            //  to avoid calling these when there are (no ill effects
            //  have been seen from not doing so yet, however for sanity sake)
            if(exp == string::npos || at == string::npos) {
                nick = trim(sender);
                login = "";
                host = "";
                nickOnly = true;
            } else {
                nick = trim(sender.substr(0, exp));
                login = trim(sender.substr(exp + 1, at));
                host = trim(sender.substr(at + 1));
            }
        }

        if(tokn == 1) {
            tok = strtok(NULL, " ");
            string target(tok); //AKA channel

            uint32_t code = 0;
            if(tmp.length() == 3 && (code = (uint32_t) atoi(tmp.c_str())) != 0 && code < 1000) {
                string response = line.substr(sender.length()+5+target.length()+1);
                handle_numeric(code,target,response);
                onNumeric(sender,code,target,response);
            } else if(tmp.compare("PRIVMSG") == 0) {
                handle_msg(target, nick, login, host, line.substr(line.find(" :") + 2));
            } else if(tmp.compare("NOTICE") == 0) {
                onNotice(target, nick, login, host, line.substr(line.find(" :") + 2));
            } else if(tmp.compare("JOIN") == 0) {
                //TODO: Add this user to the channel.
                onJoin(target, nick, login, host);
            } else if(tmp.compare("PART") == 0) {
                //TODO: Remove this user from the channel.
                onPart(target, nick, login, host);
            } else if(tmp.compare("TOPIC") == 0) {
                onTopic(target, line.substr(line.find(" :") + 2), nick, time(NULL), true);
            } else if(tmp.compare("KICK") == 0) {
                tok = strtok(NULL, " ");
                string recipient(tok);
                onKick(target, nick, login, host, recipient, line.substr(line.find(" :") + 2));
            } else if(tmp.compare("QUIT") == 0) {
                onQuit(nick, login, host, line.substr(line.find(" :") + 2));
            } else if(tmp.compare("MODE") == 0) {
                tok = strtok(NULL, " ");
                string mode = tok;
                if(mode[0] == ':')
                    mode = mode.substr(1);
                handle_mode(nick, login, host, target, mode);
            }
            //TODO: Add mode handler here
            else {
                onUnknown(line);
            }

            break;
        }

        tok = strtok(NULL, " ");
        ++tokn;
    }

    delete[] cstr;
}
// -----------------------------------------------------------------------------
// CMCETestUIEngineOutRefer::ConstructL()
// -----------------------------------------------------------------------------
//
void CMCETestUIEngineOutRefer::ConstructL(CMCETestUIEngineProfile& /*aProfile*/)
    {
 
     /////////////////////
    //
    // TODO: After implementing wrappers for streams, sinks and sources 
    //       this function should be refactored to make use of them. That will 
    //       also simplify the function to some extent.
    //
    //////////////////////
    
 
    BaseConstructL();
    if(iProfile )
    	{
    	FillProfileRegistrar();
    
    if(ReferParamsL(iReferParams))
    	{
    	// Solve recipient
	    CMCETestUIQuestionDataQuery* question = 
		    CMCETestUIQuestionDataQuery::NewLC();
		question->SetCaptionL( KUserQuestionInputRecipient );
		question->SetDefaultValueL(iReferParams.iRecipentAddress  );
		question->SetAnswerL( iReferParams.iRecipentAddress  );
		TBufC8<100> recipient( question->Answer8() );
		
		CleanupStack::PopAndDestroy( question );
		//solve referTo
		
		CMCETestUIQuestionDataQuery* questionreferto = 
		    CMCETestUIQuestionDataQuery::NewLC();
		questionreferto->SetCaptionL( KUserQuestionInputReferTo );
		questionreferto->SetDefaultValueL(iReferParams.iReferTo  );
		questionreferto->SetAnswerL( iReferParams.iReferTo  );
		TBufC8<100> referTo( questionreferto->Answer8() );
		
		CleanupStack::PopAndDestroy( questionreferto );
	   // solve originator
	   
	   if ( iReferParams.originator.Compare(KNone))
	   	{
		   	HBufC8* orig8 = HBufC8::NewL(iReferParams.originator.Length());
		   	TPtr8 ptr = orig8->Des();
		    ptr.Copy(iReferParams.originator);
		    // Create OutRfer
		    CMceOutRefer* outRefer = CMceOutRefer::NewL(
		       	iEngine.MCEManager(), 
			    iProfile->Profile(),
			    recipient,referTo);
			CleanupStack::PushL(outRefer);
		    CleanupStack::Pop( outRefer );
			iRefer = outRefer;
			iOutRefer = outRefer;        
	   	}
	   else 
	   	{
		   	// Create OutEvent
		    CMceOutRefer* outRefer = CMceOutRefer::NewL(
		       iEngine.MCEManager(),
		       iProfile->Profile(),
			   recipient,referTo );
			CleanupStack::PushL(outRefer);
		    CleanupStack::Pop( outRefer );
			iRefer = outRefer;
			iOutRefer = outRefer;
	   	}
	    // Get identity
	    iId = iEngine.NextOutReferId();
    	}
    	}
    
    
    }