summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mail2/mainwindow.cpp
blob: ce8039133224e6f208c36f17c377ae0a00a94d90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include <qmessagebox.h>
#include <qaction.h>
#include <qapplication.h>

#include <qpe/qcopenvelope_qws.h>

#include "mailstatusbar.h"
#include "folderwidget.h"
#include "mainwindow.h"
#include "configdiag.h"
#include "configfile.h"
#include "searchdiag.h"
#include "mailtable.h"
#include "composer.h"
#include "viewmail.h"
#include "mailfactory.h"

MainWindow::MainWindow(QWidget *parent, const char *name, WFlags fl)
	: MainWindowBase(parent, name, fl)
{
	status->setStopEnabled(false);

	connect(folderView, SIGNAL(status(const QString&)), status, SLOT(setStatusText(const QString&)));
	connect(folderView, SIGNAL(folderSelected(Folder)), mailView, SLOT(setFolder(Folder)));

	connect(mailView, SIGNAL(mailClicked(IMAPResponseFETCH,IMAPHandler*)), SLOT(mailClicked(IMAPResponseFETCH,IMAPHandler*)));
	connect(mailView, SIGNAL(status(const QString&)), status, SLOT(setStatusText(const QString&)));
	connect(mailView, SIGNAL(totalSteps(int)), status, SLOT(setProgressTotalSteps(int)));
	connect(mailView, SIGNAL(progress(int)), status, SLOT(setProgress(int)));
	connect(mailView, SIGNAL(resetProgress()), status, SLOT(resetProgress()));
	connect(mailView, SIGNAL(stopEnabled(bool)), status, SLOT(setStopEnabled(bool)));

	connect(status, SIGNAL(stop()), mailView, SLOT(stop()));

	connect(compose, SIGNAL(activated()), SLOT(slotComposeNoParams()));
	connect(sendQueue, SIGNAL(activated()), SLOT(slotSendQueued()));
	connect(findmails, SIGNAL(activated()), SLOT(slotSearch()));
	connect(configure, SIGNAL(activated()), SLOT(slotConfigure()));

	// Added by Stefan Eilers to allow starting by addressbook..
#if !defined(QT_NO_COP) 
// 	QCopChannel *addressChannel = new QCopChannel("QPE/Application/mail" , this );
// 	connect (addressChannel, SIGNAL( received(const QCString&,const QByteArray&)),
// 		 this, SLOT ( appMessage(const QCString&,const QByteArray&) ) );
	connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ),
	         this, SLOT( appMessage(const QCString&,const QByteArray&) ) );
#endif
}

// Added by Stefan Eilers to allow starting by addressbook..
void MainWindow::appMessage(const QCString &msg, const QByteArray &data)
{
	if (msg == "writeMail(QString,QString)") {
		QDataStream stream(data,IO_ReadOnly);
		QString name, email;
		stream >> name >> email;

		qWarning("opie-mail:: Should send mail to %s with address %s", name.latin1(), email.latin1() );

		slotCompose( name, email );
		
	}else{
		QString str_message = msg;
		qWarning("opie-mail:: Received unknown QCop-Message: %s", str_message.latin1() );
	}
}

void MainWindow::slotCompose( const QString& name, const QString& email )
{
	Composer composer(this, 0, true);

	// If there is a mailaddress given, create message..
	if ( ! name.isEmpty() ){
		qWarning("opie-mail:: Compose mail for %s with address %s", name.latin1(), email.latin1() );
		SendMail compMail;
		compMail.setTo( "\"" + name + "\"" + " " + "<"+ email + ">");
		composer.setSendMail( compMail );
	}
	composer.showMaximized();
	composer.exec();
}

void MainWindow::slotComposeNoParams()
{
	slotCompose( 0l, 0l);
}

void MainWindow::slotSendQueued()
{
	Composer composer(this, 0, true, true);
// 	composer.sendQueue();
	composer.showMaximized();
	composer.exec();
//	composer.close();
}

void MainWindow::slotSearch()
{
	SearchDiag searchDiag(this, 0, true);
	searchDiag.showMaximized();
	searchDiag.exec();
}

void MainWindow::slotConfigure()
{
	ConfigDiag configDiag(this, 0, true);
	configDiag.showMaximized();
	configDiag.exec();

	connect(&configDiag, SIGNAL(changed()), folderView, SLOT(update()));
}

void MainWindow::mailClicked(IMAPResponseFETCH mail, IMAPHandler *handler)
{
	ViewMail viewMail(mail, handler, this, 0, true);
	viewMail.showMaximized();
	viewMail.exec();
}