-rw-r--r-- | libkcal/sharpformat.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index 820d068..defdb09 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp @@ -414,193 +414,193 @@ bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) status.setText( i18n("Reading todos ...") ); qApp->processEvents(); if ( ! debug ) { fileName = "/tmp/kopitempout"; QString command = "db2file todo -r -c " + codec+ " > " + fileName; system ( command.latin1() ); } else { fileName = "/tmp/todo.txt"; } file.setName( fileName ); if (!file.open( IO_ReadOnly ) ) { return false; } ts.setDevice( &file ); text = ts.read(); file.close(); status.setText( i18n("Processing todos ...") ); status.raise(); qApp->processEvents(); fromString2Cal( calendar, existngCal, text, "Todo" ); return true; } int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) { int retval = -1; QStringList templist; QString tempString; int start = 0; int len = answer.length(); int end = answer.find ("\n",start)+1; bool ok = true; start = end; int ccc = 0; while ( start > 0 ) { templist.clear(); ok = true; int loopCount = 0; while ( ok ) { ++loopCount; if ( loopCount > 25 ) { qDebug("KO: Error in while loop"); ok = false; start = 0; break; } if ( ok ) tempString = getPart( answer, ok, start ); if ( start >= len || start == 0 ) { start = 0; ok = false; } if ( tempString.right(1) =="\n" ) tempString = tempString.left( tempString.length()-1); templist.append( tempString ); } ++ccc; if ( ccc == 2 && loopCount < 25 ) { start = 0; bool ok; int newnum = templist[0].toInt( &ok ); if ( ok && newnum > 0) { retval = newnum; inc->setID( "Sharp_DTM",templist[0] ); inc->setCsum( "Sharp_DTM", QString::number( getCsum( templist ) )); inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); } } } //qDebug("getNumFromRecord returning : %d ", retval); return retval; } bool SharpFormat::save( Calendar *calendar) { QLabel status ( i18n("Processing/adding events ..."), 0 ); int w = status.sizeHint().width()+20 ; if ( w < 200 ) w = 200; int h = status.sizeHint().height()+20 ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); status.setCaption(i18n("Writing DTM Data") ); status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); status.show(); status.raise(); qApp->processEvents(); bool debug = DEBUGMODE; QString codec = "utf8"; QString answer; QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; QString command; QPtrList<Event> er = calendar->rawEvents(); Event* ev = er.first(); - QString fileName = "/tmp/kdepimtempfile"; + QString fileName = "/tmp/kopitempout"; int i = 0; QString changeString = ePrefix; QString deleteString = ePrefix; bool deleteEnt = false; bool changeEnt = false; QString message = i18n("Processing event # "); int procCount = 0; while ( ev ) { //qDebug("i %d ", ++i); if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { status.setText ( message + QString::number ( ++procCount ) ); qApp->processEvents(); QString eString = getEventString( ev ); if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete // deleting empty strings does not work. // we write first and x and then delete the record with the x eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); changeString += eString + "\n"; deleteString += eString + "\n"; deleteEnt = true; changeEnt = true; } else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; system ( command.utf8() ); QFile file( fileName ); if (!file.open( IO_ReadOnly ) ) { return false; } QTextStream ts( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); answer = ts.read(); file.close(); //qDebug("answer \n%s ", answer.latin1()); getNumFromRecord( answer, ev ) ; } else { // change existing //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; changeString += eString + "\n"; changeEnt = true; } } ev = er.next(); } status.setText ( i18n("Changing events ...") ); qApp->processEvents(); //qDebug("changing... "); if ( changeEnt ) { QFile file( fileName ); if (!file.open( IO_WriteOnly ) ) { return false; } QTextStream ts( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); ts << changeString ; file.close(); command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; system ( command.latin1() ); //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); } status.setText ( i18n("Deleting events ...") ); qApp->processEvents(); //qDebug("deleting... "); if ( deleteEnt ) { QFile file( fileName ); if (!file.open( IO_WriteOnly ) ) { return false; } QTextStream ts( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); ts << deleteString; file.close(); command = "db2file datebook -d -c " + codec+ " < "+ fileName; system ( command.latin1() ); // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); } changeString = tPrefix; deleteString = tPrefix; status.setText ( i18n("Processing todos ...") ); qApp->processEvents(); QPtrList<Todo> tl = calendar->rawTodos(); Todo* to = tl.first(); i = 0; message = i18n("Processing todo # "); procCount = 0; while ( to ) { if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |