status_t DbxImporter::AddMessage( String &cMessage, const String &cFolder ) { if( cMessage != "" ) { /* Add an RFC2822 terminating sequence */ cMessage += "\r\n.\r\n"; /* Create a Mailmessage and send it back down to the application along with the relevent data */ Mailmessage *pcImport = new Mailmessage( cMessage.c_str(), cMessage.size() ); Message *pcImportMessage = new Message( M_IMPORT_NEW ); pcImportMessage->AddPointer( "message", pcImport ); pcImportMessage->AddString( "folder", cFolder ); m_pcMessenger->SendMessage( pcImportMessage ); /* Update the progress dialog & check if the user canceled */ //float vProgress = ( (double)m_nBytes / (double)m_nSize ); float vProgress = ( (double)m_nTotal / (double)m_nCount ); char zMessage[64] = { '\0' }; snprintf( zMessage, 64, "Importing message #%Ld", m_nTotal++ ); m_pcDialog->Lock(); m_pcDialog->SetMessage( zMessage ); m_pcDialog->SetProgress( vProgress ); m_bRun = !m_pcDialog->IsCancelled(); m_pcDialog->Unlock(); } cMessage = ""; return EOK; }
void SettingsWindow::_Save( int nCode ) { /* Collect the current information entered in all the views */ Settings *pcSettings = new Settings(); WebSettings *pcWebSettings = new WebSettings(); std::vector<SettingsView*>::iterator i; for( i = m_vViews.begin(); i != m_vViews.end(); i++ ) (*i)->Store( pcSettings, pcWebSettings ); /* Pass the settings back to the application */ Message *pcNewMessage = new Message( nCode ); pcNewMessage->AddPointer( "settings", (void*)pcSettings ); pcNewMessage->AddPointer( "web_settings", (void*)pcWebSettings ); Messenger cMessenger( m_pcParent ); cMessenger.SendMessage( pcNewMessage ); _SaveGui(); Close(); }
status_t MboxImporter::AddMessage( os::String &cMessage ) { if( cMessage != "" ) { if( m_bDoCrLf ) { /* Convert linefeeds to CRLF pairs */ const char *pStart, *pEnd; int nLf = 0; pStart = cMessage.c_str(); while( ( pEnd = strchr( pStart, '\n' ) ) != NULL ) { nLf++; pStart = pEnd + 1; } char *pMessage = (char*)calloc( 1, cMessage.size() + nLf + 1 ); if( NULL == pMessage ) return ENOMEM; const char *pIn; char *pOut; pIn = cMessage.c_str(); pOut = pMessage; while( '\0' != *pIn ) { if( '\n' == *pIn ) *pOut++ = '\r'; *pOut++ = *pIn++; } cMessage = pMessage; free( pMessage ); } /* Add an RFC2822 terminating sequence */ cMessage += "\r\n.\r\n"; /* Create a Mailmessage and send it back down to the application along with the relevent data */ Mailmessage *pcImport = new Mailmessage( cMessage.c_str(), cMessage.size() ); Message *pcImportMessage = new Message( M_IMPORT_NEW ); pcImportMessage->AddPointer( "message", pcImport ); pcImportMessage->AddString( "folder", m_cFolder ); m_pcMessenger->SendMessage( pcImportMessage ); /* Update the progress dialog & check if the user canceled */ float vProgress = ( (double)m_nBytes / (double)m_nSize ); char zMessage[64] = { '\0' }; snprintf( zMessage, 64, "Importing message #%Ld", m_nCount++ ); m_pcDialog->Lock(); m_pcDialog->SetMessage( zMessage ); m_pcDialog->SetProgress( vProgress ); m_bRun = !m_pcDialog->IsCancelled(); m_pcDialog->Unlock(); } cMessage = ""; return EOK; }