Exemplo n.º 1
0
/*******************************************************************
* Function Name: externalFunction
* Description: the router gets input from either the "outside" (a new messgae to route) or from the router (next step for routing)
********************************************************************/
Model &Dispatcher::externalFunction( const ExternalMessage &msg ){
	if(VERBOSE) cout<<"external message: "<<msg.value()<<endl;
	if ( this->state() == passive)
	{
		if (msg.port() == msg_in) //putting something in the routing table
		{
			//expecting a message including the peerid and a messageId encoded according to the spec of "complexmessages.h"

			int peer = getPeerId(msg.value());// get originating peer (from value of external msg)
			if(VERBOSE)cout<<" peer :"<<peer<<endl;
			int qq = getMessageId(msg.value()); // get query (encoded as messageid)
			if(VERBOSE)cout<<"  query :"<<qq<<endl;

			//generate new message id
			int msgid;
			msgid = id_counter;
			id_counter = (id_counter + 1)%MAXID; //count

			nextOutput_q = buildMessage(msgid, qq);
			nextOutput_p = buildMessage(msgid, peer);

		}


	} //end if state is passive
	else{
		cout<<"Dispatcher error: message received while in active state"<<endl;
	}
	// we have an instantaneous change back to the passive state (will output the next output values where relevant)
	holdIn( active, Time(0.00f));

	return *this ;
}
void RFIDMonitorDaemon::tcpDisconnected()
{
    if(isConnected){
        QJsonObject obj;
        obj.insert("full", QJsonValue(false));
        // Inform RFIDMonitor that the server is no more connected
        ipcSendMessage(buildMessage(QJsonObject(), "SLEEP").toJson());
        ipcSendMessage(buildMessage(obj, "FULL-READ").toJson());
        isConnected = false;
    }
    // Try to reconnect the server after 5 seconds
    QTimer::singleShot(5000, this, SLOT(tcpConnect()));
}
void sendMessagesToPeers() {
    FRAMEWORK_MESSAGE message;

    memset(&message, 0, sizeof(message));
    message.to = TEAM1;
    buildMessage(&message);
    sendto(broadcast_socket, (char *) &message, sizeof(message), 0, (struct sockaddr *) &broadcast_address, sizeof(broadcast_address));

    memset(&message, 0, sizeof(message));
    message.to = TEAM2;
    buildMessage(&message);
    sendto(broadcast_socket, (char *) &message, sizeof(message), 0, (struct sockaddr *) &broadcast_address, sizeof(broadcast_address));

    /* Send a message to each peer */
}
// ############# Invokable API ########################
void EmailMessage::send()
{
    buildMessage();

    bool stored = false;

    if (!m_msg.id().isValid()) {
        // Message present only on the local device until we externalise or send it
        m_msg.setStatus(QMailMessage::LocalOnly, true);
        stored = QMailStore::instance()->addMessage(&m_msg);
    }
    else {
        stored = QMailStore::instance()->updateMessage(&m_msg);
        m_newMessage = false;
    }

    EmailAgent *emailAgent = EmailAgent::instance();
    if (stored) {
        connect(emailAgent, SIGNAL(sendCompleted()), this, SLOT(onSendCompleted()));
        emailAgent->sendMessages(m_msg.parentAccountId());
        emitSignals();
    }
    else
       qWarning() << "Error: queuing message, stored: " << stored;
}
Exemplo n.º 5
0
/*******************************************************************
* Function Name: outputFunction
********************************************************************/
Model &LTSNetwork::outputFunction( const InternalMessage &msg )
{

	if ( !EvQ.empty() ) // if we have messages to dequeue
        {
		if(VERBOSE) cout<<"LTS: output coming...\n";

		long message = buildMessage(EvQ.top().id, EvQ.top().peerid, EvQ.top().TTL);

		if(EvQ.top().connectEvent) //distinguish the three types of events
			if (EvQ.top().TTL==1)
				sendOutput( msg.time(), out_connect, message); //connect notification
			else
				sendOutput( msg.time(), out_disconnect, message); // disconnect notification
		else
			sendOutput( msg.time(), route_out, message); // message routing

        EvQ.pop(); //remove val from queue

        }
/*	if ( !ConnectionQueue.empty() ) // if we have connect messages to dequeue
        {
         sendOutput( msg.time(), out_connect, ConnectionQueue.front());
         ConnectionQueue.pop(); //remove val from queue
        }
	if ( !DisconnectionQueue.empty() ) // if we have disconnect messages to dequeue
        {
         sendOutput( msg.time(), out_disconnect, DisconnectionQueue.front());
         DisconnectionQueue.pop(); //remove val from queue
        }*/

	return *this;
}
	void executeSysCallOpen(MpsRequest * aReq, ClientConnection * conn){

		char * vdaName = getVdaName(aReq->arg2);
		int * openingMode = aReq->arg1;

		//TODO: se comunica con el FSS para obtener el correspondiente
		//TODO: file descriptor
		int fd = getFileDescriptor(aReq);

		//TODO: se comunica con el FSS para obtener el correspondiente
		//TODO: file size
		int fz = getFileSize(aReq);

		//TODO: si no encuentra un archivo en la tabla hace esto
		//TODO: de lo contrario lo borra y lo abre denuevo

		TddRecord * record = createTddRecord(1 , vdaName , *openingMode , 512);
		record->fileSize = fz;
		addTddRecord(record);
		long idDescriptor = getIdDescriptor(aReq->idDescriptor);

		MpsMessage m = buildMessage( idDescriptor, SUCCESS_RESULT , itoa(fd) );



	}
Exemplo n.º 7
0
/*******************************************************************
* Function Name: outputFunction
********************************************************************/
Model &LTSNetwork::outputFunction( const InternalMessage &msg )
{
	if(VERBOSE) cout<<"LTS: output coming...\n";
	if ( !EvQ.empty() ) // if we have messages to dequeue
        {
		long message = buildMessage(EvQ.front().id, EvQ.front().peerid, EvQ.front().TTL);

		sendOutput( msg.time(), route_out, message);

        EvQ.pop(); //remove val from queue

        }
	if ( !ConnectionQueue.empty() ) // if we have connect messages to dequeue
        {
         sendOutput( msg.time(), out_connect, ConnectionQueue.front());
         ConnectionQueue.pop(); //remove val from queue
        }
	if ( !DisconnectionQueue.empty() ) // if we have disconnect messages to dequeue
        {
         sendOutput( msg.time(), out_disconnect, DisconnectionQueue.front());
         DisconnectionQueue.pop(); //remove val from queue
        }

	return *this;
}
Exemplo n.º 8
0
/*****************************************************************************
 * Message preparation
 *****************************************************************************/
void intf_sys_t::msgAuth()
{
    castchannel::DeviceAuthMessage authMessage;
    authMessage.mutable_challenge();

    buildMessage(NAMESPACE_DEVICEAUTH, authMessage.SerializeAsString(),
                 DEFAULT_CHOMECAST_RECEIVER, castchannel::CastMessage_PayloadType_BINARY);
}
Exemplo n.º 9
0
void intf_sys_t::msgReceiverGetStatus()
{
    std::stringstream ss;
    ss << "{\"type\":\"GET_STATUS\","
       <<  "\"requestId\":" << i_receiver_requestId++ << "}";

    buildMessage(NAMESPACE_RECEIVER, ss.str());
}
Exemplo n.º 10
0
void intf_sys_t::msgReceiverLaunchApp()
{
    std::stringstream ss;
    ss << "{\"type\":\"LAUNCH\","
       <<  "\"appId\":\"" << APP_ID << "\","
       <<  "\"requestId\":" << i_receiver_requestId++ << "}";

    buildMessage(NAMESPACE_RECEIVER, ss.str());
}
Exemplo n.º 11
0
Arquivo: cast.cpp Projeto: Adatan/vlc
static void msgClose(sout_stream_t *p_stream, std::string destinationId)
{
    sout_stream_sys_t *p_sys = p_stream->p_sys;

    std::string s("{\"type\":\"CLOSE\"}");
    castchannel::CastMessage msg = buildMessage("urn:x-cast:com.google.cast.tp.connection",
        castchannel::CastMessage_PayloadType_STRING, s, destinationId);

    p_sys->messagesToSend.push(msg);
}
Exemplo n.º 12
0
Arquivo: cast.cpp Projeto: Adatan/vlc
static void msgPong(sout_stream_t *p_stream)
{
    sout_stream_sys_t *p_sys = p_stream->p_sys;

    std::string s("{\"type\":\"PONG\"}");
    castchannel::CastMessage msg = buildMessage("urn:x-cast:com.google.cast.tp.heartbeat",
        castchannel::CastMessage_PayloadType_STRING, s);

    p_sys->messagesToSend.push(msg);
}
        /**
         * Constructor - Initializes the file name and line number where
         * this message occured.  Sets the message to report, using an 
         * optional list of arguments to parse into the message
         * @param file name where exception occurs
         * @param line number where the exception occurred.
         * @param message to report
         * @param list of primitives that are formatted into the message
         */
        NoSuchElementException( const char* file, 
                                const int lineNumber,
								const std::string msg, ... )
        {
            va_list vargs;
            va_start( vargs, msg );
            buildMessage( msg, vargs );
            
            // Set the first mark for this exception.
            setMark( file, lineNumber );
        }
Exemplo n.º 14
0
// send data
int sendData(SSL& ssl, const void* buffer, int sz)
{
    int sent = 0;

    if (ssl.GetError() == YasslError(SSL_ERROR_WANT_READ))
        ssl.SetError(no_error);

    if (ssl.GetError() == YasslError(SSL_ERROR_WANT_WRITE)) {
        ssl.SetError(no_error);
        ssl.SendWriteBuffered();
        if (!ssl.GetError()) {
            // advance sent to prvevious sent + plain size just sent
            sent = ssl.useBuffers().prevSent + ssl.useBuffers().plainSz;
        }
    }

    ssl.verfiyHandShakeComplete();
    if (ssl.GetError()) return -1;

    for (;;) {
        int len = min(sz - sent, MAX_RECORD_SIZE);
        output_buffer out;
        input_buffer tmp;

        Data data;

        if (sent == sz) break;

        if (ssl.CompressionOn()) {
            if (Compress(static_cast<const opaque*>(buffer) + sent, len,
                         tmp) == -1) {
                ssl.SetError(compress_error);
                return -1;
            }
            data.SetData(tmp.get_size(), tmp.get_buffer());
        }
        else
            data.SetData(len, static_cast<const opaque*>(buffer) + sent);

        buildMessage(ssl, out, data);
        ssl.Send(out.get_buffer(), out.get_size());

        if (ssl.GetError()) {
            if (ssl.GetError() == YasslError(SSL_ERROR_WANT_WRITE)) {
                ssl.useBuffers().plainSz  = len;
                ssl.useBuffers().prevSent = sent;
            }
            return -1;
        }
        sent += len;
    }
    ssl.useLog().ShowData(sent, true);
    return sent;
}
Exemplo n.º 15
0
Arquivo: cast.cpp Projeto: Adatan/vlc
static void msgStatus(sout_stream_t *p_stream)
{
    sout_stream_sys_t *p_sys = p_stream->p_sys;

    std::stringstream ss;
    ss << "{\"type\":\"GET_STATUS\"}";

    castchannel::CastMessage msg = buildMessage("urn:x-cast:com.google.cast.receiver",
        castchannel::CastMessage_PayloadType_STRING, ss.str());

    p_sys->messagesToSend.push(msg);
}
Exemplo n.º 16
0
void
Reporter::header ( char * message, ... )
{
  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
  {
    EnterCriticalSection(&aCriticalSection);
    va_start ( pCurrent, message );
    buildMessage ( message, RPT_HEADER );
    va_end ( pCurrent );
    LeaveCriticalSection(&aCriticalSection);
  }
}
Exemplo n.º 17
0
bool not(bool previousResult) {
	result = !previousResult;

	char desiredBoolString[100];
	char actualBoolString[100];
	sprintf(desiredBoolString,"%s", previousResult ? "true" : "false");
	sprintf(actualBoolString,"%s", result ? "true" : "false");
	addMessageToList(
			buildMessage("not()", desiredBoolString, actualBoolString, result));

	return result;
}
Exemplo n.º 18
0
VirusEsp::ServiceException::ServiceException(
  const std::string& serviceName,
  const std::string& fmt,
  ...
)
: VirusOne::System::Exception()
, serviceName(serviceName)
{
  va_list args;
  va_start(args, fmt);
  buildMessage(serviceName + " " + fmt, args);
  va_end(args);
}
Exemplo n.º 19
0
void
Reporter::msg ( char * message, ... )
{
  // must be initialised and activated
  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
  {
    EnterCriticalSection(&aCriticalSection);
    va_start ( pCurrent, message );
    buildMessage ( message, RPT_MSG );
    va_end ( pCurrent );
    LeaveCriticalSection(&aCriticalSection);
  }
}
Exemplo n.º 20
0
Arquivo: cast.cpp Projeto: Adatan/vlc
/*****************************************************************************
 * Message preparation
 *****************************************************************************/
static void msgAuth(sout_stream_t *p_stream)
{
    sout_stream_sys_t *p_sys = p_stream->p_sys;

    castchannel::DeviceAuthMessage authMessage;
    authMessage.mutable_challenge();
    std::string authMessageString;
    authMessage.SerializeToString(&authMessageString);

    castchannel::CastMessage msg = buildMessage("urn:x-cast:com.google.cast.tp.deviceauth",
        castchannel::CastMessage_PayloadType_BINARY, authMessageString);

    p_sys->messagesToSend.push(msg);
}
Exemplo n.º 21
0
Arquivo: cast.cpp Projeto: Adatan/vlc
static void msgLaunch(sout_stream_t *p_stream)
{
    sout_stream_sys_t *p_sys = p_stream->p_sys;

    std::stringstream ss;
    ss << "{\"type\":\"LAUNCH\","
       <<  "\"appId\":\"" << APP_ID << "\","
       <<  "\"requestId\":" << p_stream->p_sys->i_requestId++ << "}";

    castchannel::CastMessage msg = buildMessage("urn:x-cast:com.google.cast.receiver",
        castchannel::CastMessage_PayloadType_STRING, ss.str());

    p_sys->messagesToSend.push(msg);
}
Exemplo n.º 22
0
char *
Reporter::text ( char * message, ... )
{
  *( buffer ) = '\0';
  
  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
  {
    EnterCriticalSection(&aCriticalSection);
    va_start ( pCurrent, message );
    buildMessage ( message, RPT_TEXT );
    va_end ( pCurrent );
    LeaveCriticalSection(&aCriticalSection);
  }

  return ( buffer );
}
void RFIDMonitorDaemon::initMonitor()
{
    m_process.kill();
    m_process.start(QCoreApplication::applicationDirPath() + "/RFIDMonitor");

    qDebug() << "Process Started, PID: " << m_process.pid();

    connect(this, &RFIDMonitorDaemon::destroyed, &m_process, &QProcess::kill);
    connect(this, &RFIDMonitorDaemon::restartMonitor, [&]()
    {
        // Stop the RFIDMonitor
        ipcSendMessage(buildMessage(QJsonObject(), "STOP").toJson());
        // After 5 seconds try to restart the RFIDMonitor
        QTimer::singleShot(5000, this, SLOT(initMonitor()));
    });
    m_restoreTimer.start();
}
Exemplo n.º 24
0
//DESCRIPTION: A generic function for sending a message to the graphkernel. It takes
//a message type as an argument (found in kernelMessage.h) and 
//a byte array as the payload
//ARGS: operationType: A 32bit unsigned int that indicates the purpose
//of this message to the kernel.
//		payload: The body of the message, usually json
int sendMessage(u_int32_t operationType, void * payload, u_int32_t length, unsigned char ** resultPayload){
	
	int result=OP_FAILED;	//-1 means the operation has failed
	int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);	//first get the socket, TCP for stream behavior
	if (sock < 0){
		perror("Error creating socket");
		return result;
	}
	struct sockaddr_in serverAddress;
	memset(&serverAddress, 0, sizeof(serverAddress));
	serverAddress.sin_family = AF_INET;
	serverAddress.sin_port = htons(SERVER_PORT);
	serverAddress.sin_addr.s_addr = inet_addr("127.0.0.1");		//TODO: make this a param or something
	
	int conn_result = connect(sock, (struct sockaddr *)&serverAddress, sizeof(serverAddress));	//Connect to the server
    if (conn_result < 0){
    	perror("error connecting\n");
    	return result;	
    }
   
	unsigned char * message = (unsigned char *)buildMessage(operationType, payload, length);	//build the message header
	int sentBytes = send(sock, message, ((KernelMessageHeader *)message)->length + sizeof(KernelMessageHeader), 0);
	if (sentBytes > 0)	//the size is calculated from the payload size in the header
    {
    	printf("Message was sent %d\n", sentBytes);
    	unsigned char * resultBuffer = malloc(sizeof(KernelMessageHeader));
    	if (recv(sock, resultBuffer, sizeof(KernelMessageHeader), 0) > 0){
    		printf("Got a result\n");
    		int payloadLength = ((KernelMessageHeader *)resultBuffer)->length;
    		result = ((KernelMessageHeader *)resultBuffer)->operationType;
    		printf("payload length is %d and result is %d\n", payloadLength, result);
    		if (payloadLength > 0){
    			resultBuffer = malloc(payloadLength);
    			if (recv(sock, resultBuffer, payloadLength, 0) >= payloadLength){
    				printf("Got payload\n");
    				//print_debug_ints(resultBuffer, payloadLength/sizeof(int));
    				*resultPayload = resultBuffer;
    			}
    		}
    	}
    }
    
    close(sock);
	return result;
}
void RFIDMonitorDaemon::readDatagrams()
{
    QByteArray datagram;
    datagram.resize(m_udpSocket->pendingDatagramSize());
    QHostAddress sender;

    m_udpSocket->readDatagram(datagram.data(), datagram.size(), &sender);

    QJsonDocument broacast(QJsonDocument::fromJson(datagram));
#if QT_VERSION < 0x050200
    m_tcpAppSocket->connectToHost(sender, broacast.object().value("port").toVariant().toInt());
#else
    m_tcpAppSocket->connectToHost(sender, broacast.object().value("port").toInt());
#endif
    if(m_tcpAppSocket->waitForConnected())
        tcpSendMessage(m_tcpAppSocket, buildMessage(m_configManager->identification(), "SYN").toJson());
    else
        qDebug() <<  QString("Could not connect with %1").arg(sender.toString());
}
Exemplo n.º 26
0
void TCPHandshakeService::tcpClientHandler(int clientSock){

    char* recvMsgBuf = (char*) malloc((TCP_HANDSHAKE_BUFSIZE+1) * sizeof(char));
    char* sendMsgBuf;
    int recvMsgSize;
    int sendMsgSize;

    /* Receive message from client */
    if ((recvMsgSize = recv(clientSock, recvMsgBuf, TCP_HANDSHAKE_BUFSIZE, 0)) < 0){
        LOG_ERROR("recv() failed");
    }
    /* Terminate received message  */
    recvMsgBuf[recvMsgSize] = '\0';

    LOG_DEBUG("Received: \""<< recvMsgBuf <<"\" (" << recvMsgSize << "bytes)\n");

    if (recvMsgSize > 0){

        /* Check if message received equals expected message */
        if(!strncmp(TCP_HANDSHAKE_RECVMSG, recvMsgBuf, sizeof(TCP_HANDSHAKE_RECVMSG))){

            std::string msg;
            buildMessage(msg);

            LOG_DEBUG("Sending: \""<< msg << "\"\n");

            send_all(clientSock,  msg.c_str(), msg.size());

        } else if(!strncmp(TCP_HANDSHAKE_QUIT, recvMsgBuf, sizeof(TCP_HANDSHAKE_QUIT))) {
        	LOG_DEBUG("Quit message received. Shutting down TCP Handshake!");

        	setServiceState(ui::STOPPED);
        } else{
            sendMsgBuf = (char*) malloc(TCP_HANDSHAKE_BUFSIZE * sizeof(char));
            sendMsgSize = snprintf(sendMsgBuf, TCP_HANDSHAKE_BUFSIZE, "Unknown command:\"%s\"\n", recvMsgBuf);
            fprintf(stderr, "%s", sendMsgBuf);
            send_all(clientSock, sendMsgBuf, sendMsgSize);
            free(sendMsgBuf);
        }
    }

    close(clientSock);
}
Exemplo n.º 27
0
void intf_sys_t::msgPlayerLoad()
{
    char *psz_mime = var_GetNonEmptyString(p_stream, SOUT_CFG_PREFIX "mime");
    if (psz_mime == NULL)
        return;

    std::stringstream ss;
    ss << "{\"type\":\"LOAD\","
       <<  "\"media\":{\"contentId\":\"http://" << serverIP << ":"
           << var_InheritInteger(p_stream, SOUT_CFG_PREFIX"http-port")
           << "/stream\","
       <<             "\"streamType\":\"LIVE\","
       <<             "\"contentType\":\"" << std::string(psz_mime) << "\"},"
       <<  "\"requestId\":" << i_requestId++ << "}";

    free(psz_mime);

    buildMessage(NAMESPACE_MEDIA, ss.str(), appTransportId);
}
Exemplo n.º 28
0
/*******************************************************************
* Function Name: outputFunction
********************************************************************/
Model &LTSNetwork::outputFunction( const InternalMessage &msg )
{
	//if(VERBOSE) cout<<"output coming...\n";
	if ( !EvQ.empty() ) // if we have messages to dequeue
        {
		long message = buildMessage(EvQ.front().id, EvQ.front().peerid, EvQ.front().TTL);
		 //if(VERBOSE) cout<<"outpupu\n";
         sendOutput( msg.time(), route_out, message);
        // if(VERBOSE) cout<<"outpopu\n";

        // if(VERBOSE) cout<<"output done !! "<<message<<endl;
         EvQ.pop(); //remove val from queue

        }
      else
        {
    	 // sendOutput( msg.time(), route_out, 999 );
    	  //(no output for graph construction)
    	}
	return *this;
}
Exemplo n.º 29
0
void chat(char* clientMsg, char* buffer, int newsockfd, char* serverHandle, char* serverMsg, int handleLen)
{
    
    int clientHere = 1;  //set flag to true
    int bytes_recv, bytes_sent, len;
  
    while(clientHere == 1){
          
            memset(clientMsg, 0, MAXDATASIZE);
            memset(buffer, 0, MAXDATASIZE);

            //recieve message and erro check
            if((bytes_recv = recv(newsockfd, clientMsg, MAXDATASIZE-1, 0)) <= 0){
                if(bytes_recv == 0){ //client closed the connection
                    clientHere = 0;
                }
                else  //there is an error connecting
                    error("ERROR recieving from socket\n");
            }
            else{  //get data from client
            printf("%s\n", clientMsg); //print clients message

            printf("%s> ", serverHandle);
            bzero(serverMsg,MAXDATASIZE);
            fgets(serverMsg,MAXDATASIZE,stdin);//get user's message to send to server

            bzero(buffer,MAXDATASIZE);

            //prepend handle to message
            buildMessage(serverMsg, serverHandle, handleLen, buffer);

            len = strlen(buffer);
            //send message to client
            bytes_sent = send(newsockfd, buffer, len, 0);
            if(bytes_sent == -1)
                error("ERROR sending to socket\n");
            }
    }
            
}
Exemplo n.º 30
0
void EmailMessage::saveDraft()
{
    buildMessage();

    QMailAccount account(m_msg.parentAccountId());
    QMailFolderId draftFolderId = account.standardFolder(QMailFolder::DraftsFolder);

    if (draftFolderId.isValid()) {
        m_msg.setParentFolderId(draftFolderId);
        //local storage set on buildMessage step
        qWarning() << "Drafts folder not found, saving to local storage(Outbox)!";
    }

    bool saved = false;

    // Unset outgoing and outbox so it wont really send
    // when we sync to the server Drafts folder
    m_msg.setStatus(QMailMessage::Outgoing, false);
    m_msg.setStatus(QMailMessage::Outbox, false);
    m_msg.setStatus(QMailMessage::Draft, true);
    // This message is present only on the local device until we externalise or send it
    m_msg.setStatus(QMailMessage::LocalOnly, true);

    if (!m_msg.id().isValid()) {
        saved = QMailStore::instance()->addMessage(&m_msg);
    } else {
        saved = QMailStore::instance()->updateMessage(&m_msg);
        m_newMessage = false;
    }
    // Sync to the server, so the message will be in the remote Drafts folder
    if (saved) {
        QMailDisconnected::flagMessage(m_msg.id(), QMailMessage::Draft, QMailMessage::Temporary,
                                       "Flagging message as draft");
        QMailDisconnected::moveToFolder(QMailMessageIdList() << m_msg.id(), m_msg.parentFolderId());
        EmailAgent::instance()->exportUpdates(m_msg.parentAccountId());
        emitSignals();
    } else {
        qWarning() << "Failed to save message!";
    }
}