summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp2
-rw-r--r--korganizer/mainwindow.h2
2 files changed, 3 insertions, 1 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index f2e1bf8..ebe761a 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1846,192 +1846,194 @@ void MainWindow::exportVCalendar()
bool createbup = true;
if ( info. exists() ) {
mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
i18n("Overwrite!"), i18n("Cancel"), 0,
0, 1 );
if ( result != 0 ) {
createbup = false;
}
}
if ( createbup ) {
if ( mView->exportVCalendar( fn ) ) {
KOPrefs::instance()->mLastVcalFile = fn;
if ( fn.length() > 20 )
mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
else
mes = i18n("KO/Pi:Exported to %1").arg(fn );
setCaption(mes);
}
}
}
#include <qpushbutton.h>
QString MainWindow::getPassword( )
{
QString retfile = "";
QDialog dia ( this, "input-dialog", true );
QLineEdit lab ( &dia );
lab.setEchoMode( QLineEdit::Password );
QVBoxLayout lay( &dia );
lay.setMargin(7);
lay.setSpacing(7);
lay.addWidget( &lab);
dia.setFixedSize( 230,50 );
dia.setCaption( i18n("Enter password") );
QPushButton pb ( "OK", &dia);
lay.addWidget( &pb );
connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
dia.show();
int res = dia.exec();
if ( res )
retfile = lab.text();
dia.hide();
qApp->processEvents();
return retfile;
}
void MainWindow::enableQuick()
{
QString retfile = "";
QDialog dia ( this, "input-dialog", true );
QLineEdit lab ( &dia );
QVBoxLayout lay( &dia );
lab.setText( KOPrefs::instance()->mPassiveSyncPort );
lay.setMargin(7);
lay.setSpacing(7);
QLabel label ( i18n("Port number (Default: 9197)"), &dia );
lay.addWidget( &label);
lay.addWidget( &lab);
dia.setFixedSize( 230,80 );
dia.setCaption( i18n("Enter port for Easy-Pi-Sync") );
QPushButton pb ( "OK", &dia);
lay.addWidget( &pb );
connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
dia.show();
int res = dia.exec();
if ( res )
retfile = lab.text();
else
return;
dia.hide();
qApp->processEvents();
KOPrefs::instance()->mPassiveSyncPort = retfile;
bool ok;
Q_UINT16 port = retfile.toUInt(&ok);
if ( ! ok ) {
qDebug("no valid port ");
return;
}
qDebug("port %d ", port);
mServerSocket = new KServerSocket ( port ,1 );
qDebug("connected ");
if ( !mServerSocket->ok() ) {
qWarning("Failed to bind to port %d", port);
delete mServerSocket;
mServerSocket = 0;
return;
}
connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) );
connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) );
}
void MainWindow::sendFile(QSocket* socket)
{
setCaption( i18n("Received request for file") );
qDebug("MainWindow::sendFile(QSocket* s) ");
+ if ( mSyncActionDialog )
+ delete mSyncActionDialog;
mSyncActionDialog = new QDialog ( this, "input-dialog", true );
mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING"));
QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog );
QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
lay->addWidget( label);
lay->setMargin(7);
lay->setSpacing(7);
mSyncActionDialog->setFixedSize( 200,100 );
mSyncActionDialog->show();
qApp->processEvents();
qDebug("saving ... ");
save();
QString fileName = defaultFileName();
QFile file( fileName );
if (!file.open( IO_ReadOnly ) ) {
setCaption( i18n("Error open file") );
delete mSyncActionDialog;
mSyncActionDialog = 0;
qDebug("error open cal file ");
return ;
}
setCaption( i18n("Sending file...") );
QTextStream ts( &file );
ts.setCodec( QTextCodec::codecForName("utf8") );
QTextStream os( socket );
os.setCodec( QTextCodec::codecForName("utf8") );
//os.setEncoding( QTextStream::UnicodeUTF8 );
while ( ! ts.atEnd() ) {
os << ts.readLine() << "\n";
}
//os << ts.read();
socket->close();
file.close();
setCaption( i18n("File sent. Waiting to get back synced file") );
qDebug("file sent ");
}
void MainWindow::getFile(QSocket* socket)
{
setCaption( i18n("Receiving synced file...") );
qDebug("MainWindow::sendFile(QSocket* s) ");
QString fileName = defaultFileName();
QFile file( fileName );
if (!file.open( IO_WriteOnly ) ) {
setCaption( i18n("Error open file") );
delete mSyncActionDialog;
mSyncActionDialog = 0;
qDebug("error open cal file ");
return ;
}
mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
QTextStream ts( &file );
ts.setCodec( QTextCodec::codecForName("utf8") );
bool first = true;
while ( socket->canReadLine () || first ) {
first = false;
while ( socket->canReadLine () ) {
ts << socket->readLine ();
}
socket->waitForMore ( 5000 );
}
setCaption( i18n("File received - reloading calendar...") );
file.close();
socket->close();
mView->watchSavedFile();
mView->openCalendar( defaultFileName() );
setCaption( i18n("Easy-Pi-Sync successful!") );
delete mSyncActionDialog;
mSyncActionDialog = 0;
}
void MainWindow::endConnect()
{
setCaption( i18n("No file received - syncing successful") );
delete mSyncActionDialog;
mSyncActionDialog = 0;
}
void MainWindow::performQuick()
{
setCaption( i18n("Please input connection settings") );
QString retfile = "";
QDialog dia ( this, "input-dialog", true );
QLineEdit lab ( &dia );
QVBoxLayout lay( &dia );
QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia );
lay.addWidget( &label);
lab.setText( KOPrefs::instance()->mActiveSyncIP );
lay.setMargin(7);
lay.setSpacing(7);
lay.addWidget( &lab);
QLabel label2 ( i18n("Port number (Default: 9197)"), &dia );
lay.addWidget( &label2);
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 58081f6..9bb2302 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,146 +1,146 @@
#ifndef KORGE_MAINWINDOW_H
#define KORGE_MAINWINDOW_H
#include <qmainwindow.h>
#include <qtimer.h>
#include <qdict.h>
#include <qregexp.h>
#include <libkcal/incidence.h>
#include "simplealarmclient.h"
class QAction;
class CalendarView;
class KSyncProfile;
#ifdef DESKTOP_VERSION
#define QPEToolBar QToolBar
#define QPEMenuBar QMenuBar
#endif
class QPEToolBar;
#include <qserversocket.h>
#include <qsocket.h>
#include <qnetworkprotocol.h>
class KServerSocket : public QServerSocket
{
Q_OBJECT
public:
KServerSocket ( Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ) :
QServerSocket( port, backlog, parent, name ){;};
void newConnection ( int socket )
{
qDebug("KServerSocket:New connection %d ", socket);
QSocket* s = new QSocket( this );
connect( s, SIGNAL(readyRead()), this, SLOT(readClient()) );
connect( s, SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
s->setSocket( socket );
}
signals:
void sendFile(QSocket*);
void getFile(QSocket*);
void endConnect();
private slots:
void discardClient()
{
QSocket* socket = (QSocket*)sender();
delete socket;
- emit endConnect();
+ //emit endConnect();
}
void readClient()
{
qDebug("readClient() ");
QSocket* socket = (QSocket*)sender();
if ( socket->canReadLine() ) {
QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), socket->readLine() );
if ( tokens[0] == "GET" ) {
emit sendFile( socket );
}
if ( tokens[0] == "PUT" ) {
emit getFile( socket );
}
if ( tokens[0] == "STOP" ) {
emit endConnect();
}
}
}
};
namespace KCal {
class CalendarLocal;
}
using namespace KCal;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
~MainWindow();
public slots:
virtual void showMaximized ();
void configureAgenda( int );
void recieve( const QCString& msg, const QByteArray& data );
static QString defaultFileName();
static QString resourcePath();
protected slots:
void setCaptionToDates();
int ringSync();
void multiSync( bool askforPrefs = false );
void about();
void licence();
void faq();
void usertrans();
void features();
void synchowto();
void whatsNew();
void keyBindings();
void aboutAutoSaving();;
void aboutKnownBugs();
void processIncidenceSelection( Incidence * );
void importQtopia();
void importBday();
void importOL();
void importIcal();
void importFile( QString, bool );
void quickImportIcal();
void slotModifiedChanged( bool );
void save();
void configureToolBar( int );
void printSel();
void printCal();
void saveCalendar();
void loadCalendar();
void exportVCalendar();
void fillFilterMenu();
void selectFilter( int );
void slotSyncMenu( int );
void syncSSH();
void confSync();
void syncSharp();
void syncPhone();
void syncLocalFile();
bool syncWithFile( QString, bool );
void quickSyncLocalFile();
protected:
void displayText( QString, QString);
void displayFile( QString, QString);
void enableIncidenceActions( bool );
private slots:
void fillSyncMenu();
void sendFile(QSocket* s);
void getFile(QSocket* socket);
void readFileFromSocket();