Import release 2.0rc1

This commit is contained in:
Mario Fetka
2009-07-17 15:44:01 +00:00
parent 919dbe2a0f
commit 9d0ee5010b
187 changed files with 41747 additions and 39906 deletions
+37 -69
View File
@@ -839,23 +839,29 @@ void Chat::saveChatAutomatically( bool saveExternalFile )
QString fileCount;
QString savePath( dir.absolutePath() + "/" );
bool nextFileExists = KMessShared::selectNextFile( savePath, fileName, fileCount, extension, fileNumber );
// We need to get the current (last) logging file; if it's not too big we'll append
// to it; if it is too big or there is no current/last logging file, we'll create a new one.
bool lastFileExists = KMessShared::selectNextFile( savePath, fileName, fileCount, extension, fileNumber );
// this is the last file as pointed to by selectNextFile; lastFileExists should be the same as file.exists()
QFile file( savePath + fileName + fileCount + "." + extension );
// There are log files already for this contact: verify if we can
// append to the last one: logs should not be too big
if( nextFileExists && file.size() > 2000000L )
// append to the last one: logs should not be too big (2MB max)
if( lastFileExists && file.size() > Chat::MAX_LOG_FILE_SIZE )
{
#ifdef KMESSDEBUG_CHAT_GENERAL
kDebug() << "Last file" << file.fileName() << "is too big, choosing next one";
kDebug() << "Last file" << file.fileName() << "is too big, creating a new file";
#endif
// Find the first file after the one we can't append to
KMessShared::selectNextFile( savePath, fileName, fileCount, extension, fileNumber );
// so automatically choose the next file name.
file.setFileName( savePath + fileName + "." + QString::number( fileNumber ) + "." + extension );
}
// if lastFileExists == false. then the base file is available for writing.
// use it.
#ifdef KMESSDEBUG_CHAT_GENERAL
kDebug() << "Chat file:" << file.fileName();
kDebug() << "Saving to chat log file:" << file.fileName();
#endif
// Save the chat in the format requested by the user
@@ -863,17 +869,33 @@ void Chat::saveChatAutomatically( bool saveExternalFile )
false, /* Don't overwrite */
false /* No user interaction */ ) )
{
#ifdef KMESSDEBUG_CHAT_GENERAL
kDebug() << "Save failed. Trying next file name";
#endif
// If saving fails (due to a corrupted file for example) just save the chat
// If saving fails (due to a corrupted file for example) try to save the chat
// with the next available file name
KMessShared::selectNextFile( savePath, fileName, fileCount, extension, fileNumber );
file.setFileName( savePath + fileName + "." + QString::number( fileNumber ) + "." + extension );
// Possible race condition but we'll take it: since we can assume the
// returned file above was indeed the last file, the next file must be
// nonexistant, so we use that as a new file now
// This time warn the user if saving fails again
saveChatToFile( file.fileName(), format, true, true );
// Another thing is that if we were *already* creating a new file and the
// save failed, we will try to save to the same file yet again. However,
// when saving to a new file already fails, whatever we do it probably
// won't work with a different filename either.
// TODO: make this more robust.
file.setFileName( savePath + fileName + "." + QString::number( fileNumber ) + "." + extension );
kWarning() << "Save failed. Trying next file name=" << file.fileName();
// Try to save it again, this time warning the user if it fails once more
if( ! saveChatToFile( file.fileName(), format, false, true ) )
{
kWarning() << "Second save failed too.";
}
#ifdef KMESSDEBUG_CHAT_GENERAL
else
{
kDebug() << "Second save attempt succeeded.";
}
#endif
}
if( saveExternalFile == false && currentAccount_->getSaveChatsToFile() )
@@ -1702,58 +1724,4 @@ void Chat::startChat()
//Start voice conversation
void Chat::startConversation()
{
if( KMESS_NULL(msnSwitchboardConnection_) )
{
#ifdef KMESSDEBUG_CHAT_GENERAL
kWarning() << "Tried to open a conversation without a switchboard!";
#endif
return;
}
kWarning() << "not implemented!";
// msnSwitchboardConnection_->startApp( MsnSwitchboardConnection::VOICECONVERSATION );
}
// Start GnomeMeeting with a contact.
void Chat::startMeeting()
{
// Choose the contact.
const QString& handle( chooseContact() );
if( KMESS_NULL(msnSwitchboardConnection_) )
{
#ifdef KMESSDEBUG_CHAT_GENERAL
kWarning() << "Tried to open a meeting with \'" << handle << "\' without a switchboard!";
#endif
return;
}
emit requestNetMeeting(handle);
}
// Send webcam data to a contact.
void Chat::startWebcamTransfer()
{
// Choose the contact.
const QString& handle( chooseContact() );
if( KMESS_NULL(msnSwitchboardConnection_) )
{
#ifdef KMESSDEBUG_CHAT_GENERAL
kWarning() << "Tried to open a meeting with \'" << handle << "\' without a switchboard!";
#endif
return;
}
emit requestWebcamTransfer(handle);
}
#include "chat.moc"