summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-08-09 17:00:23 (UTC)
committer kergoth <kergoth>2003-08-09 17:00:23 (UTC)
commitc33d5ec60361238e50a4a9d6e0eec03e396dce60 (patch) (side-by-side diff)
tree31c0c85dc4262044db90c7918014bc45265ef420
parent78c296d534589835801fb6374ac9d43d44b2b1c9 (diff)
downloadopie-c33d5ec60361238e50a4a9d6e0eec03e396dce60.zip
opie-c33d5ec60361238e50a4a9d6e0eec03e396dce60.tar.gz
opie-c33d5ec60361238e50a4a9d6e0eec03e396dce60.tar.bz2
Merge from BRANCH_1_0
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mailit/config.in2
-rw-r--r--noncore/net/mailit/popclient.cpp3
-rw-r--r--noncore/net/mailit/resource.cpp136
-rw-r--r--noncore/net/mailit/resource.h80
-rw-r--r--noncore/net/mailit/smtpclient.cpp6
-rw-r--r--noncore/net/mailit/viewatt.cpp2
-rw-r--r--noncore/net/opieftp/opieftp.pro2
-rw-r--r--noncore/net/opieirc/config.in2
-rw-r--r--noncore/net/opieirc/ircchannellist.cpp11
-rw-r--r--noncore/net/opieirc/ircchannellist.h1
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp1
-rw-r--r--noncore/net/opieirc/ircmessageparser.cpp17
-rw-r--r--noncore/net/opieirc/ircservertab.cpp24
-rw-r--r--noncore/net/opieirc/ircsession.cpp4
-rw-r--r--noncore/net/opieirc/ircsession.h1
-rw-r--r--noncore/net/opietooth/blue-pin/pindlg.cc1
-rw-r--r--noncore/net/opietooth/blue-pin/pindlg.h9
-rw-r--r--noncore/net/opietooth/blue-pin/pindlgbase.ui184
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp2
-rw-r--r--noncore/net/ubrowser/httpfactory.cpp12
-rw-r--r--noncore/net/ubrowser/mainview.cpp6
-rw-r--r--noncore/net/ubrowser/opie-ubrowser.control10
-rw-r--r--noncore/unsupported/mailit/config.in2
-rw-r--r--noncore/unsupported/mailit/popclient.cpp3
-rw-r--r--noncore/unsupported/mailit/resource.cpp136
-rw-r--r--noncore/unsupported/mailit/resource.h80
-rw-r--r--noncore/unsupported/mailit/smtpclient.cpp6
-rw-r--r--noncore/unsupported/mailit/viewatt.cpp2
28 files changed, 222 insertions, 523 deletions
diff --git a/noncore/net/mailit/config.in b/noncore/net/mailit/config.in
index 142b840..2b56b5f 100644
--- a/noncore/net/mailit/config.in
+++ b/noncore/net/mailit/config.in
@@ -1,4 +1,4 @@
config MAILIT
- boolean "opie-mailit (a simple POP3 email client)"
+ boolean "mailit"
default "n"
depends ( LIBQPE || LIBQPE-X11 )
diff --git a/noncore/net/mailit/popclient.cpp b/noncore/net/mailit/popclient.cpp
index 5da3bcb..1df6b2b 100644
--- a/noncore/net/mailit/popclient.cpp
+++ b/noncore/net/mailit/popclient.cpp
@@ -1,331 +1,332 @@
/**********************************************************************
** Copyright (C) 2001 Trolltech AS. All rights reserved.
**
** This file is part of Qt Palmtop Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "popclient.h"
#include "emailhandler.h"
//#define APOP_TEST
extern "C" {
#include "md5.h"
}
#include <qcstring.h>
PopClient::PopClient()
{
socket = new QSocket(this, "popClient");
connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
stream = new QTextStream(socket);
receiving = FALSE;
synchronize = FALSE;
lastSync = 0;
headerLimit = 0;
+ mailList = 0;
preview = FALSE;
}
PopClient::~PopClient()
{
delete socket;
delete stream;
}
void PopClient::newConnection(const QString &target, int port)
{
if (receiving) {
qWarning("socket in use, connection refused");
return;
}
status = Init;
socket->connectToHost(target, port);
receiving = TRUE;
//selected = FALSE;
emit updateStatus(tr("DNS lookup"));
}
void PopClient::setAccount(const QString &popUser, const QString &popPasswd)
{
popUserName = popUser;
popPassword = popPasswd;
}
void PopClient::setSynchronize(int lastCount)
{
synchronize = TRUE;
lastSync = lastCount;
}
void PopClient::removeSynchronize()
{
synchronize = FALSE;
lastSync = 0;
}
void PopClient::headersOnly(bool headers, int limit)
{
preview = headers;
headerLimit = limit;
}
void PopClient::setSelectedMails(MailList *list)
{
selected = TRUE;
mailList = list;
}
void PopClient::connectionEstablished()
{
emit updateStatus(tr("Connection established"));
}
void PopClient::errorHandling(int status)
{
errorHandlingWithMsg( status, QString::null );
}
void PopClient::errorHandlingWithMsg(int status, const QString & Msg )
{
emit updateStatus(tr("Error Occured"));
emit errorOccurred(status, Msg);
socket->close();
receiving = FALSE;
}
void PopClient::incomingData()
{
QString response, temp, temp2, timeStamp;
QString md5Source;
int start, end;
// char *md5Digest;
char md5Digest[16];
// if ( !socket->canReadLine() )
// return;
response = socket->readLine();
switch(status) {
//logging in
case Init: {
#ifdef APOP_TEST
start = response.find('<',0);
end = response.find('>', start);
if( start >= 0 && end > start )
{
timeStamp = response.mid( start , end - start + 1);
md5Source = timeStamp + popPassword;
md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]);
for(int j =0;j < MD5_DIGEST_LENGTH ;j++)
{
printf("%x", md5Digest[j]);
}
printf("\n");
// qDebug(md5Digest);
*stream << "APOP " << popUserName << " " << md5Digest << "\r\n";
// qDebug("%s", stream);
status = Stat;
}
else
#endif
{
timeStamp = "";
*stream << "USER " << popUserName << "\r\n";
status = Pass;
}
break;
}
case Pass: {
*stream << "PASS " << popPassword << "\r\n";
status = Stat;
break;
}
//ask for number of messages
case Stat: {
if (response[0] == '+') {
*stream << "STAT" << "\r\n";
status = Mcnt;
} else errorHandlingWithMsg(ErrLoginFailed, response);
break;
}
//get count of messages, eg "+OK 4 900.." -> int 4
case Mcnt: {
if (response[0] == '+') {
temp = response.replace(0, 4, "");
int x = temp.find(" ", 0);
temp.truncate((uint) x);
newMessages = temp.toInt();
messageCount = 1;
status = List;
if (synchronize) {
//messages deleted from server, reload all
if (newMessages < lastSync)
lastSync = 0;
messageCount = 1;
}
- if (selected) {
+ if (selected && mailList ) {
int *ptr = mailList->first();
if (ptr != 0) {
newMessages++; //to ensure no early jumpout
messageCount = *ptr;
} else newMessages = 0;
}
} else errorHandlingWithMsg(ErrUnknownResponse, response);
}
//Read message number x, count upwards to messageCount
case List: {
if (messageCount <= newMessages) {
*stream << "LIST " << messageCount << "\r\n";
status = Size;
temp2.setNum(newMessages - lastSync);
temp.setNum(messageCount - lastSync);
if (!selected) {
emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
} else {
//completing a previously closed transfer
/* if ( (messageCount - lastSync) <= 0) {
temp.setNum(messageCount);
emit updateStatus(tr("Previous message ") + temp);
} else {*/
emit updateStatus(tr("Completing message ") + temp);
//}
}
break;
} else {
emit updateStatus(tr("No new Messages"));
status = Quit;
}
}
//get size of message, eg "500 characters in message.." -> int 500
case Size: {
if (status != Quit) { //because of idiotic switch
if (response[0] == '+') {
temp = response.replace(0, 4, "");
int x = temp.find(" ", 0);
temp = temp.right(temp.length() - ((uint) x + 1) );
mailSize = temp.toInt();
emit currentMailSize(mailSize);
status = Retr;
} else {
//qWarning(response);
errorHandlingWithMsg(ErrUnknownResponse, response);
}
}
}
//Read message number x, count upwards to messageCount
case Retr: {
if (status != Quit) {
if ((selected)||(mailSize <= headerLimit))
{
*stream << "RETR " << messageCount << "\r\n";
} else { //only header
*stream << "TOP " << messageCount << " 0\r\n";
}
messageCount++;
status = Ignore;
break;
} }
case Ignore: {
if (status != Quit) { //because of idiotic switch
if (response[0] == '+') {
message = "";
status = Read;
if (!socket->canReadLine()) //sync. problems
break;
response = socket->readLine();
} else errorHandlingWithMsg(ErrUnknownResponse, response);
}
}
//add all incoming lines to body. When size is reached, send
//message, and go back to read new message
case Read: {
if (status != Quit) { //because of idiotic switch
message += response;
while ( socket->canReadLine() ) {
response = socket->readLine();
message += response;
}
emit downloadedSize(message.length());
int x = message.find("\r\n.\r\n",-5);
if (x == -1) {
break;
} else { //message reach entire size
if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active
{
emit newMessage(message, messageCount-1, mailSize, TRUE);
} else { //incomplete mail downloaded
emit newMessage(message, messageCount-1, mailSize, FALSE);
}
if ((messageCount > newMessages)||(selected)) //last message ?
{
status = Quit;
if (selected) { //grab next from queue
newMessages--;
status = Quit;
}
}
else
{
*stream << "LIST " << messageCount << "\r\n";
status = Size;
temp2.setNum(newMessages - lastSync);
temp.setNum(messageCount - lastSync);
emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
break;
}
}
}
if (status != Quit)
break;
}
case Quit: {
*stream << "Quit\r\n";
status = Done;
int newM = newMessages - lastSync;
if (newM > 0) {
temp.setNum(newM);
emit updateStatus(temp + tr(" new messages"));
} else {
emit updateStatus(tr("No new messages"));
}
socket->close();
receiving = FALSE;
emit mailTransfered(newM);
break;
}
}
}
diff --git a/noncore/net/mailit/resource.cpp b/noncore/net/mailit/resource.cpp
deleted file mode 100644
index dc19880..0000000
--- a/noncore/net/mailit/resource.cpp
+++ b/dev/null
@@ -1,136 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
-#include "qpeapplication.h"
-#include "resource.h"
-#include <qdir.h>
-#include <qfile.h>
-#include <qregexp.h>
-#include <qpixmapcache.h>
-#include <qpainter.h>
-
-#include "inlinepics_p.h"
-
-/*!
- \class Resource resource.h
- \brief The Resource class provides access to named resources.
-
- The resources may be provided from files or other sources.
-*/
-
-/*!
- \fn Resource::Resource()
- \internal
-*/
-
-/*!
- Returns the QPixmap named \a pix. You should avoid including
- any filename type extension (eg. .png, .xpm).
-*/
-QPixmap Resource::loadPixmap( const QString &pix )
-{
- QPixmap pm;
- QString key="QPE_"+pix;
- if ( !QPixmapCache::find(key,pm) ) {
- pm.convertFromImage(loadImage(pix));
- QPixmapCache::insert(key,pm);
- }
- return pm;
-}
-
-/*!
- Returns the QBitmap named \a pix. You should avoid including
- any filename type extension (eg. .png, .xpm).
-*/
-QBitmap Resource::loadBitmap( const QString &pix )
-{
- QBitmap bm;
- bm = loadPixmap(pix);
- return bm;
-}
-
-/*!
- Returns the filename of a pixmap named \a pix. You should avoid including
- any filename type extension (eg. .png, .xpm).
-
- Normally you will use loadPixmap() rather than this function.
-*/
-QString Resource::findPixmap( const QString &pix )
-{
- QString picsPath = QPEApplication::qpeDir() + "pics/";
-
- if ( QFile( picsPath + pix + ".png").exists() )
- return picsPath + pix + ".png";
- else if ( QFile( picsPath + pix + ".xpm").exists() )
- return picsPath + pix + ".xpm";
- else if ( QFile( picsPath + pix ).exists() )
- return picsPath + pix;
-
- //qDebug("Cannot find pixmap: %s", pix.latin1());
- return QString();
-}
-
-/*!
- Returns a sound file for a sound named \a name.
- You should avoid including any filename type extension (eg. .wav, .au, .mp3).
-*/
-QString Resource::findSound( const QString &name )
-{
- QString picsPath = QPEApplication::qpeDir() + "sounds/";
-
- QString result;
- if ( QFile( (result = picsPath + name + ".wav") ).exists() )
- return result;
-
- return QString();
-}
-
-/*!
- Returns a list of all sound names.
-*/
-QStringList Resource::allSounds()
-{
- QDir resourcedir( QPEApplication::qpeDir() + "sounds/", "*.wav" );
- QStringList entries = resourcedir.entryList();
- QStringList result;
- for (QStringList::Iterator i=entries.begin(); i != entries.end(); ++i)
- result.append((*i).replace(QRegExp("\\.wav"),""));
- return result;
-}
-
-/*!
- Returns the QImage named \a name. You should avoid including
- any filename type extension (eg. .png, .xpm).
-*/
-QImage Resource::loadImage( const QString &name)
-{
- QImage img = qembed_findImage(name.latin1());
- if ( img.isNull() )
- return QImage(findPixmap(name));
- return img;
-}
-
-/*!
- \fn QIconSet Resource::loadIconSet( const QString &name )
-
- Returns a QIconSet for the pixmap named \a name. A disabled icon is
- generated that conforms to the Qtopia look & feel. You should avoid
- including any filename type extension (eg. .png, .xpm).
-*/
diff --git a/noncore/net/mailit/resource.h b/noncore/net/mailit/resource.h
deleted file mode 100644
index 982c58a..0000000
--- a/noncore/net/mailit/resource.h
+++ b/dev/null
@@ -1,80 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-#ifndef PIXMAPLOADER_H
-#define PIXMAPLOADER_H
-
-#include <qimage.h>
-#include <qbitmap.h>
-#include <qiconset.h>
-#include <qstringlist.h>
-
-class Resource
-{
-public:
- Resource() {}
-
- static QImage loadImage( const QString &name);
-
- static QPixmap loadPixmap( const QString &name );
- static QBitmap loadBitmap( const QString &name );
- static QString findPixmap( const QString &name );
-
- static QIconSet loadIconSet( const QString &name );
-
- static QString findSound( const QString &name );
- static QStringList allSounds();
-};
-
-// Inline for compatibility with SHARP ROMs
-inline QIconSet Resource::loadIconSet( const QString &pix )
-{
- QImage img = loadImage( pix );
- QPixmap pm;
- pm.convertFromImage( img );
- QIconSet is( pm );
- QIconSet::Size size = pm.width() <= 22 ? QIconSet::Small : QIconSet::Large;
-
- QPixmap dpm = loadPixmap( pix + "_disabled" );
-
-#ifndef QT_NO_DEPTH_32 // have alpha-blended pixmaps
- if ( dpm.isNull() ) {
- QImage dimg( img.width(), img.height(), 32 );
- for ( int y = 0; y < img.height(); y++ ) {
- for ( int x = 0; x < img.width(); x++ ) {
- QRgb p = img.pixel( x, y );
- uint a = (p & 0xff000000) / 3;
- p = (p & 0x00ffffff) | (a & 0xff000000);
- dimg.setPixel( x, y, p );
- }
- }
-
- dimg.setAlphaBuffer( TRUE );
- dpm.convertFromImage( dimg );
- }
-#endif
-
- if ( !dpm.isNull() )
- is.setPixmap( dpm, size, QIconSet::Disabled );
-
- return is;
-}
-
-
-#endif
diff --git a/noncore/net/mailit/smtpclient.cpp b/noncore/net/mailit/smtpclient.cpp
index 5b5ef52..51ca50b 100644
--- a/noncore/net/mailit/smtpclient.cpp
+++ b/noncore/net/mailit/smtpclient.cpp
@@ -1,170 +1,170 @@
/**********************************************************************
** Copyright (C) 2001 Trolltech AS. All rights reserved.
**
** This file is part of Qt Palmtop Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "smtpclient.h"
#include "emailhandler.h"
SmtpClient::SmtpClient()
{
socket = new QSocket(this, "smtpClient");
stream = new QTextStream(socket);
mailList.setAutoDelete(TRUE);
connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
sending = FALSE;
}
SmtpClient::~SmtpClient()
{
delete socket;
delete stream;
}
void SmtpClient::newConnection(const QString &target, int port)
{
if (sending) {
qWarning("socket in use, connection refused");
return;
}
status = Init;
sending = TRUE;
socket->connectToHost(target, port);
emit updateStatus(tr("DNS lookup"));
}
void SmtpClient::addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body)
{
RawEmail *mail = new RawEmail;
mail->from = from;
mail->subject = subject;
mail->to = to;
mail->body = body;
mailList.append(mail);
}
void SmtpClient::connectionEstablished()
{
emit updateStatus(tr("Connection established"));
}
void SmtpClient::errorHandling(int status)
{
errorHandlingWithMsg( status, QString::null );
}
void SmtpClient::errorHandlingWithMsg(int status, const QString & EMsg )
{
emit errorOccurred(status, EMsg );
socket->close();
mailList.clear();
sending = FALSE;
}
void SmtpClient::incomingData()
{
QString response;
if (!socket->canReadLine())
return;
response = socket->readLine();
switch(status) {
case Init: {
if (response[0] == '2') {
status = From;
mailPtr = mailList.first();
*stream << "HELO there\r\n";
} else errorHandlingWithMsg(ErrUnknownResponse,response);
break;
}
case From: {
if (response[0] == '2') {
qDebug(mailPtr->from);
- *stream << "MAIL FROM: <" << mailPtr->from << ">\r\n";
+ *stream << "MAIL FROM: " << mailPtr->from << "\r\n";
status = Recv;
} else errorHandlingWithMsg(ErrUnknownResponse, response );
break;
}
case Recv: {
if (response[0] == '2') {
it = mailPtr->to.begin();
if (it == NULL) {
errorHandlingWithMsg(ErrUnknownResponse,response);
}
- *stream << "RCPT TO: <" << *it << ">\r\n";
+ *stream << "RCPT TO: " << *it << "\r\n";
status = MRcv;
} else errorHandlingWithMsg(ErrUnknownResponse,response);
break;
}
case MRcv: {
if (response[0] == '2') {
it++;
if ( it != mailPtr->to.end() ) {
- *stream << "RCPT TO: <" << *it << ">\r\n";
+ *stream << "RCPT TO: " << *it << "\r\n";
break;
} else {
status = Data;
}
} else errorHandlingWithMsg(ErrUnknownResponse,response);
}
case Data: {
if (response[0] == '2') {
*stream << "DATA\r\n";
status = Body;
emit updateStatus(tr("Sending: ") + mailPtr->subject);
} else errorHandlingWithMsg(ErrUnknownResponse,response);
break;
}
case Body: {
if (response[0] == '3') {
*stream << mailPtr->body << "\r\n.\r\n";
mailPtr = mailList.next();
if (mailPtr != NULL) {
status = From;
} else {
status = Quit;
}
} else errorHandlingWithMsg(ErrUnknownResponse,response);
break;
}
case Quit: {
if (response[0] == '2') {
*stream << "QUIT\r\n";
status = Done;
QString temp;
temp.setNum(mailList.count());
emit updateStatus(tr("Sent ") + temp + tr(" messages"));
emit mailSent();
mailList.clear();
sending = FALSE;
socket->close();
} else errorHandlingWithMsg(ErrUnknownResponse,response);
break;
}
}
}
diff --git a/noncore/net/mailit/viewatt.cpp b/noncore/net/mailit/viewatt.cpp
index 293e137..3515ba5 100644
--- a/noncore/net/mailit/viewatt.cpp
+++ b/noncore/net/mailit/viewatt.cpp
@@ -1,121 +1,121 @@
/**********************************************************************
** Copyright (C) 2001 Trolltech AS. All rights reserved.
**
** This file is part of Qt Palmtop Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
-#include "resource.h"
+#include <qpe/resource.h>
#include "viewatt.h"
#include <qwhatsthis.h>
#include <qpe/applnk.h>
#include <qpe/mimetype.h>
ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f)
: QMainWindow(parent, name, f)
{
setCaption(tr("Exploring attatchments"));
setToolBarsMovable( FALSE );
bar = new QToolBar(this);
installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 );
connect(installButton, SIGNAL(activated()), this, SLOT(install()) );
installButton->setWhatsThis(tr("Click here to install the attachment to your Documents"));
listView = new QListView(this, "AttView");
listView->addColumn( tr("Attatchment") );
listView->addColumn( tr("Type") );
listView->addColumn( tr("Installed") );
setCentralWidget(listView);
QWhatsThis::add(listView,QWidget::tr("This is an overview about all attachments in the mail"));
}
void ViewAtt::update(Email *mailIn, bool inbox)
{
QListViewItem *item;
Enclosure *ePtr;
listView->clear();
if (inbox) {
bar->clear();
installButton->addTo( bar );
bar->show();
} else {
bar->hide();
}
mail = mailIn;
for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
QString isInstalled = tr("No");
if (ePtr->installed)
isInstalled = tr("Yes");
item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled);
const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute;
MimeType mt(mtypeDef);
item->setPixmap(0, mt.pixmap());
/*
if (ePtr->contentType == "TEXT") {
actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0);
actions->addTo(bar);
}
if (ePtr->contentType == "AUDIO") {
actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0);
actions->addTo(bar);
item->setPixmap(0, Resource::loadPixmap("play"));
}
if (ePtr->contentType == "IMAGE") {
actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0);
actions->addTo(bar);
item->setPixmap(0, Resource::loadPixmap("pixmap"));
}*/
}
}
void ViewAtt::install()
{
Enclosure *ePtr, *selPtr;
QListViewItem *item;
QString filename;
DocLnk d;
item = listView->selectedItem();
if (item != NULL) {
filename = item->text(0);
selPtr = NULL;
for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
if (ePtr->originalName == filename)
selPtr = ePtr;
}
if (selPtr == NULL) {
qWarning("Internal error, file is not installed to documents");
return;
}
d.setName(selPtr->originalName);
d.setFile(selPtr->path + selPtr->name);
d.setType(selPtr->contentType + "/" + selPtr->contentAttribute);
d.writeLink();
selPtr->installed = TRUE;
item->setText(2, tr("Yes"));
}
}
diff --git a/noncore/net/opieftp/opieftp.pro b/noncore/net/opieftp/opieftp.pro
index dbccd98..ac16819 100644
--- a/noncore/net/opieftp/opieftp.pro
+++ b/noncore/net/opieftp/opieftp.pro
@@ -1,31 +1,31 @@
TEMPLATE = app
CONFIG += qt warn_on release
-HEADERS = opieftp.h inputDialog.h ftplib.h
+HEADERS = opieftp.h inputDialog.h
SOURCES = opieftp.cpp inputDialog.cpp main.cpp
TARGET = opieftp
DESTDIR = $(OPIEDIR)/bin
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lftplib
TRANSLATIONS = ../../../i18n/de/opieftp.ts \
../../../i18n/nl/opieftp.ts \
../../../i18n/da/opieftp.ts \
../../../i18n/xx/opieftp.ts \
../../../i18n/en/opieftp.ts \
../../../i18n/es/opieftp.ts \
../../../i18n/fr/opieftp.ts \
../../../i18n/hu/opieftp.ts \
../../../i18n/ja/opieftp.ts \
../../../i18n/ko/opieftp.ts \
../../../i18n/no/opieftp.ts \
../../../i18n/pl/opieftp.ts \
../../../i18n/pt/opieftp.ts \
../../../i18n/pt_BR/opieftp.ts \
../../../i18n/sl/opieftp.ts \
../../../i18n/zh_CN/opieftp.ts \
../../../i18n/zh_TW/opieftp.ts
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/net/opieirc/config.in b/noncore/net/opieirc/config.in
index 30184a9..7c6949d 100644
--- a/noncore/net/opieirc/config.in
+++ b/noncore/net/opieirc/config.in
@@ -1,4 +1,4 @@
config OPIEIRC
- boolean "opieirc"
+ boolean "opie-irc (chat via your favorite IRC server)"
default "y"
depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE
diff --git a/noncore/net/opieirc/ircchannellist.cpp b/noncore/net/opieirc/ircchannellist.cpp
index e592d05..566b223 100644
--- a/noncore/net/opieirc/ircchannellist.cpp
+++ b/noncore/net/opieirc/ircchannellist.cpp
@@ -1,37 +1,48 @@
#include <qpe/resource.h>
#include <qpixmap.h>
#include "ircchannellist.h"
IRCChannelList::IRCChannelList(IRCChannel *channel, QWidget *parent, const char *name, WFlags f) : QListBox(parent, name, f) {
m_channel = channel;
}
void IRCChannelList::update() {
QPixmap op = Resource::loadPixmap("opieirc/op");
QPixmap hop = Resource::loadPixmap("opieirc/hop");
QPixmap voice = Resource::loadPixmap("opieirc/voice");
QListIterator<IRCChannelPerson> it = m_channel->people();
clear();
for (; it.current(); ++it) {
IRCChannelPerson *person = it.current();
if (person->flags & PERSON_FLAG_OP) {
insertItem(op, person->person->nick());
} else if (person->flags & PERSON_FLAG_HALFOP) {
insertItem(op, person->person->nick());
} else if (person->flags & PERSON_FLAG_VOICE) {
insertItem(voice, person->person->nick());
} else {
insertItem(person->person->nick());
}
}
sort();
}
bool IRCChannelList::hasPerson(QString nick) {
for (unsigned int i=0; i<count(); i++) {
if (text(i) == nick)
return TRUE;
}
return FALSE;
}
+
+bool IRCChannelList::removePerson(QString nick) {
+ for (unsigned int i=0; i<count(); i++) {
+ if (text(i) == nick){
+ removeItem(i);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
diff --git a/noncore/net/opieirc/ircchannellist.h b/noncore/net/opieirc/ircchannellist.h
index fa3c8cd..deab649 100644
--- a/noncore/net/opieirc/ircchannellist.h
+++ b/noncore/net/opieirc/ircchannellist.h
@@ -1,36 +1,37 @@
/*
OpieIRC - An embedded IRC client
Copyright (C) 2002 Wenzel Jakob
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __IRCCHANNELLIST_H
#define __IRCCHANNELLIST_H
#include <qlistbox.h>
#include "ircchannel.h"
class IRCChannelList : public QListBox {
public:
IRCChannelList(IRCChannel *channel, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
void update();
bool hasPerson(QString nick);
+ bool removePerson(QString nick);
protected:
IRCChannel *m_channel;
};
#endif /* __IRCCHANNELLIST_H */
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp
index beb8bce..2b8b65e 100644
--- a/noncore/net/opieirc/ircchanneltab.cpp
+++ b/noncore/net/opieirc/ircchanneltab.cpp
@@ -1,166 +1,167 @@
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qcursor.h>
#include <qwhatsthis.h>
#include <qhbox.h>
#include "ircchanneltab.h"
#include "ircservertab.h"
IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
m_mainWindow = mainWindow;
m_parentTab = parentTab;
m_channel = channel;
m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>");
QHBox *hbox = new QHBox(this);
m_textview = new QTextView(hbox);
m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
m_listVisible = TRUE;
m_listButton = new QPushButton(">", m_textview);
m_textview->setCornerWidget(m_listButton);
m_textview->setTextFormat(RichText);
QWhatsThis::add(m_textview, tr("Channel discussion"));
connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList()));
m_list = new IRCChannelList(m_channel, hbox);
m_list->update();
m_list->setMaximumWidth(LISTWIDTH);
m_field = new IRCHistoryLineEdit(this);
QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion"));
m_popup = new QPopupMenu(m_list);
m_lines = 0;
/* Required so that embedded-style "right" clicks work */
QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold);
connect(m_list, SIGNAL(mouseButtonPressed(int, QListBoxItem *, const QPoint&)), this, SLOT(mouseButtonPressed(int, QListBoxItem *, const QPoint &)));
/* Construct the popup menu */
QPopupMenu *ctcpMenu = new QPopupMenu(m_list);
m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu);
m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery()));
ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing()));
ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion()));
ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois()));
connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
m_layout->add(hbox);
hbox->show();
m_layout->add(m_field);
m_field->setFocus();
connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
settingsChanged();
}
void IRCChannelTab::scrolling(){
m_textview->ensureVisible(0, m_textview->contentsHeight());
}
void IRCChannelTab::appendText(QString text) {
/* not using append because it creates layout problems */
QString txt = m_textview->text() + text + "\n";
if (m_maxLines > 0 && m_lines >= m_maxLines) {
int firstBreak = txt.find('\n');
if (firstBreak != -1) {
txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
}
} else {
m_lines++;
}
+ m_textview->ensureVisible(0, m_textview->contentsHeight());
m_textview->setText(txt);
m_textview->ensureVisible(0, m_textview->contentsHeight());
emit changed(this);
}
IRCChannelTab::~IRCChannelTab() {
m_parentTab->removeChannelTab(this);
}
void IRCChannelTab::processCommand() {
QString text = m_field->text();
if (text.length()>0) {
if (session()->isSessionActive()) {
if (text.startsWith("/") && !text.startsWith("//")) {
/* Command mode */
m_parentTab->executeCommand(this, text);;
} else {
if (text.startsWith("//"))
text = text.right(text.length()-1);
session()->sendMessage(m_channel, m_field->text());
appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>");
}
} else {
appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>");
}
}
m_field->clear();
}
void IRCChannelTab::settingsChanged() {
m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
m_lines = 0;
}
void IRCChannelTab::toggleList() {
if (m_listVisible) {
m_list->setMaximumWidth(0);
m_listButton->setText("<");
} else {
m_list->setMaximumWidth(LISTWIDTH);
m_listButton->setText(">");
}
m_listVisible = !m_listVisible;
}
void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) {
switch (mouse) {
case 1:
break;
case 2:
m_popup->popup(point);
break;
};
}
void IRCChannelTab::popupQuery() {
if (m_list->currentItem() != -1) {
IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text());
if (person) {
IRCQueryTab *tab = m_parentTab->getTabForQuery(person);
if (!tab) {
tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent());
m_parentTab->addQueryTab(tab);
m_mainWindow->addTab(tab);
}
}
}
}
void IRCChannelTab::popupPing() {
//HAHA, no wonder these don't work
}
void IRCChannelTab::popupVersion() {
}
void IRCChannelTab::popupWhois() {
}
QString IRCChannelTab::title() {
return m_channel->channelname();
}
IRCSession *IRCChannelTab::session() {
return m_parentTab->session();
}
void IRCChannelTab::remove() {
if (session()->isSessionActive()) {
session()->part(m_channel);
} else {
m_mainWindow->killTab(this);
}
}
IRCChannel *IRCChannelTab::channel() {
return m_channel;
}
IRCChannelList *IRCChannelTab::list() {
return m_list;
}
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp
index 6b88f34..400ff41 100644
--- a/noncore/net/opieirc/ircmessageparser.cpp
+++ b/noncore/net/opieirc/ircmessageparser.cpp
@@ -1,521 +1,536 @@
#include <qtextstream.h>
#include "ircmessageparser.h"
#include "ircversion.h"
/* Lookup table for literal commands */
IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = {
{ "PING", FUNC(parseLiteralPing) },
{ "NOTICE", FUNC(parseLiteralNotice) },
{ "JOIN", FUNC(parseLiteralJoin) },
{ "PRIVMSG", FUNC(parseLiteralPrivMsg) },
{ "NICK", FUNC(parseLiteralNick) },
{ "PART", FUNC(parseLiteralPart) },
{ "QUIT", FUNC(parseLiteralQuit) },
{ "ERROR", FUNC(parseLiteralError) },
{ "ERROR:", FUNC(parseLiteralError) },
{ "MODE", FUNC(parseLiteralMode) },
{ "KICK", FUNC(parseLiteralKick) },
{ "TOPIC", FUNC(parseLiteralTopic) },
{ 0 , 0 }
};
/* Lookup table for literal commands */
IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = {
{ "PING", FUNC(parseCTCPPing) },
{ "VERSION", FUNC(parseCTCPVersion) },
{ "ACTION", FUNC(parseCTCPAction) },
{ 0 , 0 }
};
/* Lookup table for numerical commands */
IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = {
{ 1, FUNC(parseNumerical001) }, // RPL_WELCOME
{ 2, FUNC(parseNumerical002) }, // RPL_YOURHOST
{ 3, FUNC(parseNumerical003) }, // RPL_CREATED
{ 4, FUNC(parseNumerical004) }, // RPL_MYINFO
{ 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL
{ 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT
{ 252, FUNC(parseNumericalStats) }, // RPL_LUSEROP
{ 265, FUNC(parseNumericalStats) }, // RPL_LOCALUSERS
{ 266, FUNC(parseNumericalStats) }, // RPL_GLOBALUSERS
{ 250, FUNC(parseNumericalStats) }, // RPL_STATSCONN
{ 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS
{ 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME
{ 332, FUNC(parseNumericalTopic) }, // RPL_TOPIC
{ 333, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME
{ 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY
{ 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES
{ 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART
{ 372, FUNC(parseNumericalStats) }, // RPL_MOTD
{ 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD
{ 377, FUNC(parseNumericalStats) }, // RPL_MOTD2
{ 378, FUNC(parseNumericalStats) }, // RPL_MOTD3
{ 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK
{ 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK
{ 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND
{ 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE
{ 0, 0 }
};
IRCMessageParser::IRCMessageParser(IRCSession *session) {
m_session = session;
}
void IRCMessageParser::parse(IRCMessage *message) {
/* Find out what kind of message we have here and call the appropriate handler using
the parser tables. If no handler can be found, print out an error message */
if (message->isNumerical()) {
for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) {
if (message->commandNumber() == numericalParserProcTable[i].commandNumber) {
(this->*(numericalParserProcTable[i].proc))(message);
return;
}
}
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command: %1").arg( QString::number(message->commandNumber()) )));
} else if (message->isCTCP()) {
for (int i=0; ctcpParserProcTable[i].commandName; i++) {
if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) {
(this->*(ctcpParserProcTable[i].proc))(message);
return;
}
}
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command: %1").arg( message->ctcpCommand())) );
} else {
for (int i=0; literalParserProcTable[i].commandName; i++) {
if (message->command() == literalParserProcTable[i].commandName) {
(this->*(literalParserProcTable[i].proc))(message);
return;
}
}
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command: %1").arg( message->command()) ));
}
}
void IRCMessageParser::nullFunc(IRCMessage *) {
/* Do nothing */
}
void IRCMessageParser::parseLiteralPing(IRCMessage *message) {
m_session->m_connection->sendLine("PONG " + message->allParameters());
}
void IRCMessageParser::parseLiteralNotice(IRCMessage *message) {
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters()));
}
void IRCMessageParser::parseLiteralJoin(IRCMessage *message) {
QString channelName = message->param(0).lower();
IRCPerson mask(message->prefix());
IRCChannel *channel = m_session->getChannel(channelName);
if (!channel) {
/* We joined */
if (mask.nick() == m_session->m_server->nick()) {
channel = new IRCChannel(channelName);
m_session->addChannel(channel);
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?")));
}
} else {
/* Someone else joined */
if (mask.nick() != m_session->m_server->nick()) {
if (!channel->getPerson(mask.nick())) {
IRCChannelPerson *chanperson = new IRCChannelPerson();
IRCPerson *person = m_session->getPerson(mask.nick());
if (!person) {
person = new IRCPerson(message->prefix());
m_session->addPerson(person);
}
chanperson->flags = 0;
chanperson->person = person;
channel->addPerson(chanperson);
IRCOutput output(OUTPUT_OTHERJOIN ,tr("%1 joined channel %2").arg( mask.nick() ).arg( channelName ));
output.addParam(channel);
output.addParam(chanperson);
emit outputReady(output);
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?")));
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?")));
}
}
}
void IRCMessageParser::parseLiteralPart(IRCMessage *message) {
QString channelName = message->param(0).lower();
IRCChannel *channel = m_session->getChannel(channelName);
IRCPerson mask(message->prefix());
if (channel) {
if (mask.nick() == m_session->m_server->nick()) {
m_session->removeChannel(channel);
IRCOutput output(OUTPUT_SELFPART, tr("You left channel %1").arg( channelName ));
output.addParam(channel);
emit outputReady(output);
delete channel;
} else {
IRCChannelPerson *person = channel->getPerson(mask.nick());
if (person) {
channel->removePerson(person);
IRCOutput output(OUTPUT_OTHERPART, tr("%1 left channel %2").arg( mask.nick() ).arg( channelName) );
output.addParam(channel);
output.addParam(person);
emit outputReady(output);
delete person;
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?")));
}
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?")));
}
}
void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) {
if (m_session->m_server->nick() == message->param(0)) {
/* IRC Query message detected, verify sender and display it */
IRCPerson mask(message->prefix());
IRCPerson *person = m_session->getPerson(mask.nick());
if (!person) {
/* Person not yet known, create and add to the current session */
person = new IRCPerson(message->prefix());
m_session->addPerson(person);
}
IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1));
output.addParam(person);
emit outputReady(output);
} else if (message->param(0).at(0) == '#' || message->param(0).at(0) == '+') {
/* IRC Channel message detected, verify sender, channel and display it */
IRCChannel *channel = m_session->getChannel(message->param(0).lower());
if (channel) {
IRCPerson mask(message->prefix());
IRCChannelPerson *person = channel->getPerson(mask.nick());
if (person) {
IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1));
output.addParam(channel);
output.addParam(person);
emit outputReady(output);
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender")));
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel %1").arg(message->param(0).lower()) ));
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type")));
}
}
void IRCMessageParser::parseLiteralNick(IRCMessage *message) {
- IRCPerson mask(message->prefix());
+ IRCPerson mask(message->prefix());
+ /* this way of handling nick changes really sucks */
if (mask.nick() == m_session->m_server->nick()) {
/* We are changing our nickname */
m_session->m_server->setNick(message->param(0));
IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0)));
output.addParam(0);
emit outputReady(output);
} else {
/* Someone else is */
IRCPerson *person = m_session->getPerson(mask.nick());
if (person) {
+ //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0)));
+
+ /* new code starts here -- this removes the person from all channels */
+ QList<IRCChannel> channels;
+ m_session->getChannelsByPerson(person, channels);
+ QListIterator<IRCChannel> it(channels);
+ for (;it.current(); ++it) {
+ IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
+ it.current()->removePerson(chanperson);
+ chanperson->person->setNick(message->param(0));
+ it.current()->addPerson(chanperson);
IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0 )));
output.addParam(person);
emit outputReady(output);
+ }
+ /* new code ends here */
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person")));
}
}
}
void IRCMessageParser::parseLiteralQuit(IRCMessage *message) {
IRCPerson mask(message->prefix());
IRCPerson *person = m_session->getPerson(mask.nick());
if (person) {
QList<IRCChannel> channels;
m_session->getChannelsByPerson(person, channels);
QListIterator<IRCChannel> it(channels);
for (;it.current(); ++it) {
IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
it.current()->removePerson(chanperson);
delete chanperson;
}
m_session->removePerson(person);
IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) ));
output.addParam(person);
emit outputReady(output);
delete person;
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?")));
}
}
void IRCMessageParser::parseLiteralTopic(IRCMessage *message) {
IRCPerson mask(message->prefix());
IRCChannel *channel = m_session->getChannel(message->param(0).lower());
if (channel) {
IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\"");
output.addParam(channel);
emit outputReady(output);
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?")));
}
}
void IRCMessageParser::parseLiteralError(IRCMessage *message) {
emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters()));
}
void IRCMessageParser::parseCTCPPing(IRCMessage *message) {
IRCPerson mask(message->prefix());
m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters());
emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick()));
}
void IRCMessageParser::parseCTCPVersion(IRCMessage *message) {
IRCPerson mask(message->prefix());
m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR);
emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick()));
}
void IRCMessageParser::parseCTCPAction(IRCMessage *message) {
IRCPerson mask(message->prefix());
QString dest = message->ctcpDestination();
if (dest.startsWith("#")) {
IRCChannel *channel = m_session->getChannel(dest.lower());
if (channel) {
IRCChannelPerson *person = channel->getPerson(mask.nick());
if (person) {
IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0));
output.addParam(channel);
output.addParam(person);
emit outputReady(output);
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?")));
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?")));
}
} else {
if (message->ctcpDestination() == m_session->m_server->nick()) {
IRCPerson *person = m_session->getPerson(mask.nick());
if (!person) {
/* Person not yet known, create and add to the current session */
person = new IRCPerson(message->prefix());
m_session->addPerson(person);
}
IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0));
output.addParam(person);
emit outputReady(output);
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient")));
}
}
}
void IRCMessageParser::parseLiteralMode(IRCMessage *message) {
IRCPerson mask(message->prefix());
if (message->param(0).startsWith("#")) {
IRCChannel *channel = m_session->getChannel(message->param(0).lower());
if (channel) {
QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1);
QTextIStream stream(&parameters);
bool set = FALSE;
while (!stream.atEnd()) {
stream >> temp;
if (temp.startsWith("+")) {
set = TRUE;
temp = temp.right(1);
} else if (temp.startsWith("-")) {
set = FALSE;
temp = temp.right(1);
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type")));
return;
}
if (temp == "o") {
stream >> temp;
IRCChannelPerson *person = channel->getPerson(temp);
if (person) {
if (set) {
person->flags |= PERSON_FLAG_OP;
IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick()));
output.addParam(channel);
output.addParam(person);
emit outputReady(output);
} else {
person->flags &= 0xFFFF - PERSON_FLAG_OP;
IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick()));
output.addParam(channel);
output.addParam(person);
emit outputReady(output);
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?")));
}
} else if (temp == "v") {
stream >> temp;
IRCChannelPerson *person = channel->getPerson(temp);
if (person) {
if (set) {
person->flags |= PERSON_FLAG_VOICE;
IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives voice to " + person->person->nick()));
output.addParam(channel);
output.addParam(person);
emit outputReady(output);
} else {
person->flags &= 0xFFFF - PERSON_FLAG_VOICE;
IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes voice from " + person->person->nick()));
output.addParam(channel);
output.addParam(person);
emit outputReady(output);
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?")));
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown flag")));
}
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown kannel - Desynchronized?")));
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("User modes not supported yet")));
}
}
void IRCMessageParser::parseLiteralKick(IRCMessage *message) {
IRCPerson mask(message->prefix());
IRCChannel *channel = m_session->getChannel(message->param(0).lower());
if (channel) {
IRCChannelPerson *person = channel->getPerson(message->param(1));
if (person) {
if (person->person->nick() == m_session->m_server->nick()) {
m_session->removeChannel(channel);
IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")");
output.addParam(channel);
emit outputReady(output);
} else {
+ /* someone else got kicked */
channel->removePerson(person);
IRCOutput output(OUTPUT_OTHERKICK, person->person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")");
output.addParam(channel);
output.addParam(person);
emit outputReady(output);
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?")));
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?")));
}
}
void IRCMessageParser::parseNumerical001(IRCMessage *message) {
/* Welcome to IRC message, display */
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1)));
}
void IRCMessageParser::parseNumerical002(IRCMessage *message) {
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1)));
}
void IRCMessageParser::parseNumerical003(IRCMessage *message) {
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1)));
}
void IRCMessageParser::parseNumerical004(IRCMessage *message) {
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters()));
}
void IRCMessageParser::parseNumerical005(IRCMessage *message) {
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters()));
}
void IRCMessageParser::parseNumericalStats(IRCMessage *message) {
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1)));
}
void IRCMessageParser::parseNumericalNames(IRCMessage *message) {
/* Name list sent when joining a channel */
IRCChannel *channel = m_session->getChannel(message->param(2).lower());
if (channel != 0) {
QString people = message->param(3);
QTextIStream stream(&people);
QString temp;
while (!stream.atEnd()) {
stream >> temp;
char flagch = temp.at(0).latin1();
int flag = 0;
QString nick;
/* Parse person flags */
if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') {
nick = temp.right(temp.length()-1);
switch (flagch) {
case '@': flag = PERSON_FLAG_OP; break;
case '+': flag = PERSON_FLAG_VOICE; break;
case '%': flag = PERSON_FLAG_HALFOP; break;
default : flag = 0; break;
}
} else {
nick = temp;
}
IRCChannelPerson *chan_person = new IRCChannelPerson();
IRCPerson *person = m_session->getPerson(nick);
if (person == 0) {
person = new IRCPerson();
person->setNick(nick);
m_session->addPerson(person);
}
chan_person->person = person;
chan_person->flags = flag;
channel->addPerson(chan_person);
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel")));
}
}
void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) {
/* Done syncing to channel */
IRCChannel *channel = m_session->getChannel(message->param(1).lower());
if (channel) {
channel->setHasPeople(TRUE);
/* Yes, we want the names before anything happens inside the GUI */
IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname());
output.addParam(channel);
emit outputReady(output);
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel")));
}
}
void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname")));
m_session->endSession();
}
void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname")));
}
void IRCMessageParser::parseNumericalTopic(IRCMessage *message) {
IRCChannel *channel = m_session->getChannel(message->param(1).lower());
if (channel) {
IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + channel->channelname() + " is \"" + message->param(2) + "\""));
output.addParam(channel);
emit outputReady(output);
} else {
IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + message->param(1) + " is \"" + message->param(2) + "\""));
output.addParam(0);
emit outputReady(output);
}
}
void IRCMessageParser::parseNumericalTopicWhoTime(IRCMessage *) {
}
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp
index 1d9520a..2c28507 100644
--- a/noncore/net/opieirc/ircservertab.cpp
+++ b/noncore/net/opieirc/ircservertab.cpp
@@ -1,368 +1,374 @@
#include <qpe/config.h>
#include <qtextstream.h>
#include <qwhatsthis.h>
#include "ircservertab.h"
IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
m_server = server;
m_session = new IRCSession(&m_server);
m_mainWindow = mainWindow;
m_close = FALSE;
m_lines = 0;
m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>");
m_textview = new QTextView(this);
m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
m_textview->setTextFormat(RichText);
QWhatsThis::add(m_textview, tr("Server messages"));
m_layout->add(m_textview);
m_field = new IRCHistoryLineEdit(this);
QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help"));
m_layout->add(m_field);
connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
m_field->setFocus();
connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
settingsChanged();
}
void IRCServerTab::scrolling(){
m_textview->ensureVisible(0, m_textview->contentsHeight());
}
void IRCServerTab::appendText(QString text) {
/* not using append because it creates layout problems */
QString txt = m_textview->text() + text + "\n";
if (m_maxLines > 0 && m_lines >= m_maxLines) {
int firstBreak = txt.find('\n');
if (firstBreak != -1) {
txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
}
} else {
m_lines++;
}
m_textview->setText(txt);
m_textview->ensureVisible(0, m_textview->contentsHeight());
emit changed(this);
}
IRCServerTab::~IRCServerTab() {
delete m_session;
}
void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
m_channelTabs.remove(tab);
}
void IRCServerTab::removeQueryTab(IRCQueryTab *tab) {
m_queryTabs.remove(tab);
}
void IRCServerTab::addQueryTab(IRCQueryTab *tab) {
m_queryTabs.append(tab);
}
QString IRCServerTab::title() {
return "Server";
}
IRCSession *IRCServerTab::session() {
return m_session;
}
/*
QString *IRCServerTab::mynick() {
return (*m_server->nick());
} */
IRCServer *IRCServerTab::server() {
return &m_server;
}
void IRCServerTab::settingsChanged() {
m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
m_lines = 0;
}
void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
QTextIStream stream(&line);
QString command;
stream >> command;
command = command.upper().right(command.length()-1);
//JOIN
if (command == "JOIN" || command == "J") {
QString channel;
stream >> channel;
if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) {
m_session->join(channel);
} else {
tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>");
}
}
//KICK
else if (command == "KICK"){
QString nickname;
stream >> nickname;
if (nickname.length() > 0) {
if (line.length() > 7 + nickname.length()) {
QString text = line.right(line.length()-nickname.length()-7);
IRCPerson person;
person.setNick(nickname);
m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text);
} else {
IRCPerson person;
person.setNick(nickname);
m_session->kick(((IRCChannelTab *)tab)->channel(), &person);
}
}
}
else if (command == "OP"){
QString nickname;
stream >> nickname;
if (nickname.length() > 0) {
- if (line.length() > 7 + nickname.length()) {
- QString text = line.right(line.length()-nickname.length()-7);
+ QString text = line.right(line.length()-nickname.length()-5);
IRCPerson person;
person.setNick(nickname);
- m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text);
- } else {
- IRCPerson person;
- person.setNick(nickname);
- m_session->kick(((IRCChannelTab *)tab)->channel(), &person);
- }
+ m_session->op(((IRCChannelTab *)tab)->channel(), &person);
}
}
//SEND MODES
else if (command == "MODE"){
QString text = line.right(line.length()-6);
if (text.length() > 0) {
m_session->mode(text);
} else {
tab->appendText("<font color=\"" + m_errorColor + "\">/mode channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask]<br>/mode nickname {[+|-]|i|w|s|o}</font><br>");
}
}
//SEND RAW MESSAGE TO SERVER, COMPLETELY UNCHECKED - anything in the RFC...or really anything you want
else if (command == "RAW"){
QString text = line.right(line.length()-5);
if (text.length() > 0) {
m_session->raw(text);
}
}
else if (command == "SUSPEND"){
QString text = line.right(line.length()-9);
if (text.upper() == "ON") {
QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
}
else if (text.upper() == "OFF"){
QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
} else {
tab->appendText("<font color=\"" + m_errorColor + "\">Line: "+ line +"</font><br>Text: "+text);
}
}
else if (command == "QUIT"){
QString text = line.right(line.length()-6);
if (text.length() > 0) {
m_session->quit(text);
} else {
m_session->quit();
}
}
//SEND ACTION
else if (command == "ME") {
QString text = line.right(line.length()-4);
if (text.length() > 0) {
if (tab->isA("IRCChannelTab")) {
tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
m_session->sendAction(((IRCChannelTab *)tab)->channel(), text);
} else if (tab->isA("IRCQueryTab")) {
tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
m_session->sendAction(((IRCQueryTab *)tab)->person(), text);
} else {
tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>");
}
}
}
//SEND PRIVMSG
else if (command == "MSG") {
QString nickname;
stream >> nickname;
if (nickname.length() > 0) {
if (line.length() > 6 + nickname.length()) {
QString text = line.right(line.length()-nickname.length()-6);
IRCPerson person;
person.setNick(nickname);
tab->appendText("<font color=\"" + m_textColor + "\">&gt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">&lt; "+IRCOutput::toHTML(text)+"</font><br>");
m_session->sendMessage(&person, text);
}
}
}
else {
tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>");
}
}
void IRCServerTab::processCommand() {
QString text = m_field->text();
if (text.startsWith("/") && !text.startsWith("//")) {
/* Command mode */
executeCommand(this, text);
}
m_field->clear();
}
void IRCServerTab::doConnect() {
m_session->beginSession();
}
void IRCServerTab::remove() {
/* Close requested */
if (m_session->isSessionActive()) {
/* While there is a running session */
m_close = TRUE;
m_session->endSession();
} else {
/* Session has previously been closed */
m_channelTabs.first();
while (m_channelTabs.current() != 0) {
m_mainWindow->killTab(m_channelTabs.current());
}
m_queryTabs.first();
while (m_queryTabs.current() != 0) {
m_mainWindow->killTab(m_queryTabs.current());
}
m_mainWindow->killTab(this);
}
}
IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) {
QListIterator<IRCChannelTab> it(m_channelTabs);
for (; it.current(); ++it) {
if (it.current()->channel() == channel)
return it.current();
}
return 0;
}
IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) {
QListIterator<IRCQueryTab> it(m_queryTabs);
for (; it.current(); ++it) {
if (it.current()->person()->nick() == person->nick())
return it.current();
}
return 0;
}
void IRCServerTab::display(IRCOutput output) {
/* All messages to be displayed inside the GUI get here */
switch (output.type()) {
case OUTPUT_CONNCLOSE:
if (m_close) {
m_channelTabs.first();
while (m_channelTabs.current() != 0) {
m_mainWindow->killTab(m_channelTabs.current());
}
m_queryTabs.first();
while (m_queryTabs.current() != 0) {
m_mainWindow->killTab(m_queryTabs.current());
}
m_mainWindow->killTab(this);
} else {
appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>");
QListIterator<IRCChannelTab> it(m_channelTabs);
for (; it.current(); ++it) {
it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>");
}
}
break;
case OUTPUT_SELFJOIN: {
IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
m_channelTabs.append(channeltab);
m_mainWindow->addTab(channeltab);
}
break;
case OUTPUT_CHANPRIVMSG: {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
channelTab->appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage()+"</font><br>");
}
break;
case OUTPUT_QUERYACTION:
case OUTPUT_QUERYPRIVMSG: {
IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0));
if (!queryTab) {
queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
m_queryTabs.append(queryTab);
m_mainWindow->addTab(queryTab);
}
queryTab->display(output);
}
break;
case OUTPUT_SELFPART: {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
if (channelTab)
m_mainWindow->killTab(channelTab);
}
break;
case OUTPUT_SELFKICK: {
appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
if (channelTab)
m_mainWindow->killTab(channelTab);
}
break;
case OUTPUT_CHANACTION: {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>");
}
break;
case OUTPUT_TOPIC: {
IRCChannel *channel = (IRCChannel *) output.getParam(0);
if (channel) {
IRCChannelTab *channelTab = getTabForChannel(channel);
if (channelTab) {
channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
return;
}
}
appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
}
break;
case OUTPUT_QUIT: {
QString nick = ((IRCPerson *)output.getParam(0))->nick();
QListIterator<IRCChannelTab> it(m_channelTabs);
for (; it.current(); ++it) {
if (it.current()->list()->hasPerson(nick)) {
it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
it.current()->list()->update();
}
}
}
break;
- case OUTPUT_OTHERJOIN:
+/* case OUTPUT_NICKCHANGE: {
+ //WAS HERE
+ QString nick = ((IRCPerson *)output.getParam(0))->nick();
+ QListIterator<IRCChannelTab> it(m_channelTabs);
+ for (; it.current(); ++it) {
+ if (it.current()->list()->hasPerson(nick)) {
+ it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
+ it.current()->list()->update();
+ }
+ }
+ }
+ break;
+ */ case OUTPUT_OTHERJOIN:
case OUTPUT_OTHERKICK:
case OUTPUT_CHANPERSONMODE:
case OUTPUT_OTHERPART: {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
channelTab->list()->update();
}
break;
case OUTPUT_CTCP:
appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>");
break;
case OUTPUT_ERROR:
appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
break;
default:
appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>");
break;
}
}
diff --git a/noncore/net/opieirc/ircsession.cpp b/noncore/net/opieirc/ircsession.cpp
index 1cc1ee2..6404d71 100644
--- a/noncore/net/opieirc/ircsession.cpp
+++ b/noncore/net/opieirc/ircsession.cpp
@@ -1,146 +1,150 @@
#include "ircsession.h"
#include "ircmessageparser.h"
#include "ircversion.h"
IRCSession::IRCSession(IRCServer *server) {
m_server = server;
m_connection = new IRCConnection(m_server);
m_parser = new IRCMessageParser(this);
connect(m_connection, SIGNAL(messageArrived(IRCMessage *)), this, SLOT(handleMessage(IRCMessage *)));
connect(m_parser, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput)));
connect(m_connection, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput)));
}
IRCSession::~IRCSession() {
/* We want this to get deleted automatically */
m_channels.setAutoDelete(TRUE);
m_people.setAutoDelete(TRUE);
delete m_parser;
delete m_connection;
}
void IRCSession::beginSession() {
m_connection->doConnect();
}
void IRCSession::join(QString channelname) {
m_connection->sendLine("JOIN "+channelname);
}
void IRCSession::quit(){
m_connection->sendLine("QUIT :[OI] I'm too good to need a reason");
}
void IRCSession::quit(QString message){
m_connection->sendLine("QUIT :" + message);
}
void IRCSession::topic(IRCChannel *channel, QString message){
m_connection->sendLine("TOPIC :" + channel->channelname() + " " + message);
}
void IRCSession::mode(IRCChannel *channel, QString message){
m_connection->sendLine("MODE " + channel->channelname() + " " + message);
}
void IRCSession::mode(IRCPerson *person, QString message){
m_connection->sendLine("MODE " + person->nick() + " " + message);
}
void IRCSession::mode(QString message){
m_connection->sendLine("MODE " + message);
}
void IRCSession::raw(QString message){
m_connection->sendLine(message);
}
void IRCSession::kick(IRCChannel *channel, IRCPerson *person) {
m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :0wn3d - no reason");
}
+void IRCSession::op(IRCChannel *channel, IRCPerson *person) {
+ m_connection->sendLine("MODE "+ channel->channelname() + " +ooo " + person->nick());
+}
+
void IRCSession::kick(IRCChannel *channel, IRCPerson *person, QString message) {
m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :" + message);
}
void IRCSession::sendMessage(IRCPerson *person, QString message) {
m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message);
}
void IRCSession::sendMessage(IRCChannel *channel, QString message) {
m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message);
}
void IRCSession::sendAction(IRCChannel *channel, QString message) {
m_connection->sendLine("PRIVMSG " + channel->channelname() + " :\001ACTION " + message + "\001");
}
void IRCSession::sendAction(IRCPerson *person, QString message) {
m_connection->sendLine("PRIVMSG " + person->nick() + " :\001ACTION " + message + "\001");
}
bool IRCSession::isSessionActive() {
return m_connection->isConnected();
}
void IRCSession::endSession() {
if (m_connection->isLoggedIn())
m_connection->sendLine("QUIT :" APP_VERSION);
else
m_connection->close();
}
void IRCSession::part(IRCChannel *channel) {
m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION);
}
IRCChannel *IRCSession::getChannel(QString channelname) {
QListIterator<IRCChannel> it(m_channels);
for (; it.current(); ++it) {
if (it.current()->channelname() == channelname) {
return it.current();
}
}
return 0;
}
IRCPerson *IRCSession::getPerson(QString nickname) {
QListIterator<IRCPerson> it(m_people);
for (; it.current(); ++it) {
if (it.current()->nick() == nickname) {
return it.current();
}
}
return 0;
}
void IRCSession::getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels) {
QListIterator<IRCChannel> it(m_channels);
for (; it.current(); ++it) {
if (it.current()->getPerson(person->nick()) != 0) {
channels.append(it.current());
}
}
}
void IRCSession::addPerson(IRCPerson *person) {
m_people.append(person);
}
void IRCSession::addChannel(IRCChannel *channel) {
m_channels.append(channel);
}
void IRCSession::removeChannel(IRCChannel *channel) {
m_channels.remove(channel);
}
void IRCSession::removePerson(IRCPerson *person) {
m_people.remove(person);
}
void IRCSession::handleMessage(IRCMessage *message) {
m_parser->parse(message);
}
diff --git a/noncore/net/opieirc/ircsession.h b/noncore/net/opieirc/ircsession.h
index a6a3e50..f6330d8 100644
--- a/noncore/net/opieirc/ircsession.h
+++ b/noncore/net/opieirc/ircsession.h
@@ -1,83 +1,84 @@
/*
OpieIRC - An embedded IRC client
Copyright (C) 2002 Wenzel Jakob
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __IRCSESSION_H
#define __IRCSESSION_H
#include <qstring.h>
#include <qlist.h>
#include "ircserver.h"
#include "ircconnection.h"
#include "ircmessage.h"
#include "ircchannel.h"
#include "ircoutput.h"
class IRCMessageParser;
/* The IRCSession stores all information relating to the connection
to one IRC server. IRCSession makes it possible to run multiple
IRC server connections from within the same program */
class IRCSession : public QObject {
friend class IRCMessageParser;
Q_OBJECT
public:
IRCSession(IRCServer *server);
~IRCSession();
void join(QString channel);
void quit(QString message);
void quit();
void raw(QString message);
void topic(IRCChannel *channel, QString message);
void mode(IRCChannel *channel, QString message);
void mode(IRCPerson *person, QString message);
void mode(QString message);
void part(IRCChannel *channel);
+ void op(IRCChannel *channel, IRCPerson *person);
void kick(IRCChannel *channel, IRCPerson *person);
void kick(IRCChannel *channel, IRCPerson *person, QString message);
void beginSession();
bool isSessionActive();
void endSession();
void sendMessage(IRCPerson *person, QString message);
void sendMessage(IRCChannel *channel, QString message);
void sendAction(IRCPerson *person, QString message);
void sendAction(IRCChannel *channel, QString message);
IRCChannel *getChannel(QString channelname);
IRCPerson *getPerson(QString nickname);
protected:
void addPerson(IRCPerson *person);
void addChannel(IRCChannel *channel);
void removeChannel(IRCChannel *channel);
void removePerson(IRCPerson *person);
void getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels);
protected slots:
void handleMessage(IRCMessage *message);
signals:
void outputReady(IRCOutput output);
protected:
IRCServer *m_server;
IRCConnection *m_connection;
IRCMessageParser *m_parser;
QList<IRCChannel> m_channels;
QList<IRCPerson> m_people;
};
#endif /* __IRCSESSION_H */
diff --git a/noncore/net/opietooth/blue-pin/pindlg.cc b/noncore/net/opietooth/blue-pin/pindlg.cc
index 54f096e..7d60d6c 100644
--- a/noncore/net/opietooth/blue-pin/pindlg.cc
+++ b/noncore/net/opietooth/blue-pin/pindlg.cc
@@ -1,53 +1,54 @@
#include <stdio.h>
#include <qcheckbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qtimer.h>
#include <qpe/config.h>
#include "pindlg.h"
using namespace OpieTooth;
PinDlg::PinDlg( const QString& status,
const QString& mac, QWidget* parent,
const char* name )
: PinDlgBase( parent, name, WType_Modal )
{
m_mac = mac;
test( mac );
txtStatus->setText(status);
+ showMaximized();
}
PinDlg::~PinDlg() {
}
void PinDlg::setMac( const QString& mac ) {
txtStatus->setText( mac );
}
QString PinDlg::pin() const{
return lnePin->text();
}
void PinDlg::test( const QString& mac ) {
if (!mac.isEmpty() ) {
Config cfg("bluepin");
cfg.setGroup(mac);
lnePin->setText(cfg.readEntryCrypt("pin", QString::null ) );
if ( !lnePin->text().isEmpty() ) {
//QTimer::singleShot(100, this, SLOT(accept() ) );
}
}
}
void PinDlg::accept() {
if ( ckbPin->isChecked() ) {
Config cfg("bluepin");
cfg.setGroup(m_mac );
cfg.writeEntryCrypt("pin", lnePin->text() );
}
QDialog::accept();
}
diff --git a/noncore/net/opietooth/blue-pin/pindlg.h b/noncore/net/opietooth/blue-pin/pindlg.h
index b4f5ff8..5e5a763 100644
--- a/noncore/net/opietooth/blue-pin/pindlg.h
+++ b/noncore/net/opietooth/blue-pin/pindlg.h
@@ -1,26 +1,29 @@
#include <qdialog.h>
-
#include "pindlgbase.h"
namespace OpieTooth {
+
class PinDlg : public PinDlgBase {
+
Q_OBJECT
+
public:
PinDlg(const QString& text,
const QString& mac,
QWidget* parent = 0,
const char* name= 0 );
~PinDlg();
void setMac( const QString& );
QString pin() const;
+
private:
void test( const QString& mac );
QString m_mac;
+
protected slots:
void accept();
- };
-
};
+};
diff --git a/noncore/net/opietooth/blue-pin/pindlgbase.ui b/noncore/net/opietooth/blue-pin/pindlgbase.ui
index 6966a03..889a25e 100644
--- a/noncore/net/opietooth/blue-pin/pindlgbase.ui
+++ b/noncore/net/opietooth/blue-pin/pindlgbase.ui
@@ -1,198 +1,274 @@
<!DOCTYPE UI><UI>
<class>PinDlgBase</class>
<author>zecke</author>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>Form1</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>248</width>
- <height>167</height>
+ <width>258</width>
+ <height>245</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Please enter pin</string>
</property>
- <grid>
+ <vbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
- <widget row="0" column="0" >
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>txtStatus</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string></string>
+ </property>
+ <property stdset="1">
+ <name>textFormat</name>
+ <enum>RichText</enum>
+ </property>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer4_2</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Vertical</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout6</cstring>
</property>
- <grid>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel3</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Please enter PIN:</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout5</cstring>
+ </property>
+ <hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
- <widget row="3" column="0" rowspan="1" colspan="3" >
+ <widget>
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>lnePin</cstring>
</property>
<property stdset="1">
<name>echoMode</name>
<enum>Password</enum>
</property>
</widget>
- <spacer row="5" column="4" >
+ <spacer>
<property>
<name>name</name>
- <cstring>Spacer2</cstring>
+ <cstring>Spacer4</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Fixed</enum>
</property>
<property>
<name>sizeHint</name>
<size>
- <width>16</width>
+ <width>21</width>
<height>20</height>
</size>
</property>
</spacer>
- <spacer row="5" column="0" >
+ </hbox>
+ </widget>
+ <widget>
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>ckbPin</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Save pin</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
<property>
<name>name</name>
- <cstring>Spacer1</cstring>
+ <cstring>Spacer5</cstring>
</property>
<property stdset="1">
<name>orientation</name>
- <enum>Horizontal</enum>
+ <enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
- <enum>Fixed</enum>
+ <enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
- <width>30</width>
+ <width>20</width>
<height>20</height>
</size>
</property>
</spacer>
- <spacer row="3" column="3" >
+ <widget>
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout7</cstring>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <spacer>
<property>
<name>name</name>
- <cstring>Spacer4</cstring>
+ <cstring>Spacer1</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Fixed</enum>
</property>
<property>
<name>sizeHint</name>
<size>
- <width>21</width>
+ <width>30</width>
<height>20</height>
</size>
</property>
</spacer>
- <widget row="0" column="0" rowspan="1" colspan="5" >
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>txtStatus</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string></string>
- </property>
- <property stdset="1">
- <name>textFormat</name>
- <enum>RichText</enum>
- </property>
- </widget>
- <widget row="2" column="0" rowspan="1" colspan="5" >
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>TextLabel3</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Please enter PIN:</string>
- </property>
- </widget>
- <widget row="5" column="1" >
+ <widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>PushButton1</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Ok</string>
</property>
</widget>
- <widget row="5" column="2" rowspan="1" colspan="2" >
+ <widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>PushButton2</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Cancel</string>
</property>
</widget>
- <widget row="4" column="0" rowspan="1" colspan="5" >
- <class>QCheckBox</class>
- <property stdset="1">
+ <spacer>
+ <property>
<name>name</name>
- <cstring>ckbPin</cstring>
+ <cstring>Spacer2</cstring>
</property>
<property stdset="1">
- <name>text</name>
- <string>Save pin</string>
+ <name>orientation</name>
+ <enum>Horizontal</enum>
</property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Fixed</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
</widget>
- </grid>
- </widget>
- </grid>
+ </vbox>
</widget>
<connections>
<connection>
<sender>PushButton1</sender>
<signal>clicked()</signal>
<receiver>Form1</receiver>
<slot>accept()</slot>
</connection>
<connection>
<sender>PushButton2</sender>
<signal>clicked()</signal>
<receiver>Form1</receiver>
<slot>reject()</slot>
</connection>
</connections>
</UI>
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 935c11a..54808fa 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -1,610 +1,610 @@
/*
* bluebase.cpp *
* ---------------------
*
* copyright : (c) 2002 by Maximilian Reiß
* email : max.reiss@gmx.de
*
*/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "bluebase.h"
#include "scandialog.h"
#include "hciconfwrapper.h"
#include "devicehandler.h"
#include "btconnectionitem.h"
#include <remotedevice.h>
#include <services.h>
#include <stdlib.h>
#include <qframe.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qtabwidget.h>
#include <qscrollview.h>
#include <qvbox.h>
#include <qmessagebox.h>
#include <qcheckbox.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qdir.h>
#include <qpopupmenu.h>
#include <qtimer.h>
#include <qlist.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qpe/config.h>
using namespace OpieTooth;
BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
: BluetoothBase( parent, name, fl ) {
m_localDevice = new Manager( "hci0" );
connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) );
connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) );
// not good since lib is async
// connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ),
// this, SLOT( addServicesToDevice( QListViewItem * ) ) );
connect( ListView2, SIGNAL( clicked( QListViewItem* )),
this, SLOT( startServiceActionClicked( QListViewItem* ) ) );
connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ),
this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) );
connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) );
connect( m_localDevice, SIGNAL( available( const QString&, bool ) ),
this, SLOT( deviceActive( const QString& , bool ) ) );
connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ),
this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) );
connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ),
this, SLOT( addSignalStrength( const QString&, const QString& ) ) );
// let hold be rightButtonClicked()
QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold);
QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold);
//Load all icons needed
m_offPix = Resource::loadPixmap( "opietooth/notconnected" );
m_onPix = Resource::loadPixmap( "opietooth/connected" );
m_findPix = Resource::loadPixmap( "opietooth/find" );
QPalette pal = this->palette();
QColor col = pal.color( QPalette::Active, QColorGroup::Background );
pal.setColor( QPalette::Active, QColorGroup::Button, col );
pal.setColor( QPalette::Inactive, QColorGroup::Button, col );
pal.setColor( QPalette::Normal, QColorGroup::Button, col );
pal.setColor( QPalette::Disabled, QColorGroup::Button, col );
this->setPalette( pal );
setCaption( tr( "Bluetooth Manager" ) );
readConfig();
initGui();
ListView2->setRootIsDecorated(true);
writeToHciConfig();
// search conncetions
addConnectedDevices();
addSignalStrength();
m_iconLoader = new BTIconLoader();
readSavedDevices();
}
/**
* Reads all options from the config file
*/
void BlueBase::readConfig() {
Config cfg( "bluetoothmanager" );
cfg.setGroup( "bluezsettings" );
m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with
m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak
m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE );
m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE );
m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE );
m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE );
}
/**
* Writes all options to the config file
*/
void BlueBase::writeConfig() {
Config cfg( "bluetoothmanager" );
cfg.setGroup( "bluezsettings" );
cfg.writeEntry( "name" , m_deviceName );
cfg.writeEntryCrypt( "passkey" , m_defaultPasskey );
cfg.writeEntry( "useEncryption" , m_useEncryption );
cfg.writeEntry( "enableAuthentification" , m_enableAuthentification );
cfg.writeEntry( "enablePagescan" , m_enablePagescan );
cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan );
writeToHciConfig();
}
/**
* Modify the hcid.conf file to our needs
*/
void BlueBase::writeToHciConfig() {
qWarning("writeToHciConfig");
HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" );
hciconf.load();
- hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" );
+ hciconf.setPinHelper( "/opt/QtPalmtop/bin/bluepin" );
hciconf.setName( m_deviceName );
hciconf.setEncrypt( m_useEncryption );
hciconf.setAuth( m_enableAuthentification );
hciconf.setPscan( m_enablePagescan );
hciconf.setIscan( m_enableInquiryscan );
hciconf.save();
}
/**
* Read the list of allready known devices
*/
void BlueBase::readSavedDevices() {
QValueList<RemoteDevice> loadedDevices;
DeviceHandler handler;
loadedDevices = handler.load();
addSearchedDevices( loadedDevices );
}
/**
* Write the list of allready known devices
*/
void BlueBase::writeSavedDevices() {
QListViewItemIterator it( ListView2 );
BTListItem* item;
BTDeviceItem* device;
RemoteDevice::ValueList list;
for ( ; it.current(); ++it ) {
item = (BTListItem*)it.current();
if(item->typeId() != BTListItem::Device )
continue;
device = (BTDeviceItem*)item;
list.append( device->remoteDevice() );
}
/*
* if not empty save the List through DeviceHandler
*/
if ( list.isEmpty() )
return;
DeviceHandler handler;
handler.save( list );
}
/**
* Set up the gui
*/
void BlueBase::initGui() {
StatusLabel->setText( status() ); // maybe move it to getStatus()
cryptCheckBox->setChecked( m_useEncryption );
authCheckBox->setChecked( m_enableAuthentification );
pagescanCheckBox->setChecked( m_enablePagescan );
inquiryscanCheckBox->setChecked( m_enableInquiryscan );
deviceNameLine->setText( m_deviceName );
passkeyLine->setText( m_defaultPasskey );
// set info tab
setInfo();
}
/**
* Get the status informations and returns it
* @return QString the status informations gathered
*/
QString BlueBase::status()const{
QString infoString = tr( "<b>Device name : </b> Ipaq" );
infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" );
infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" );
return (infoString);
}
/**
* Read the current values from the gui and invoke writeConfig()
*/
void BlueBase::applyConfigChanges() {
m_deviceName = deviceNameLine->text();
m_defaultPasskey = passkeyLine->text();
m_useEncryption = cryptCheckBox->isChecked();
m_enableAuthentification = authCheckBox->isChecked();
m_enablePagescan = pagescanCheckBox->isChecked();
m_enableInquiryscan = inquiryscanCheckBox->isChecked();
writeConfig();
QMessageBox::information( this, tr("Test") , tr("Changes were applied.") );
}
/**
* Add fresh found devices from scan dialog to the listing
*
*/
void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) {
BTDeviceItem * deviceItem;
QValueList<RemoteDevice>::ConstIterator it;
for( it = newDevices.begin(); it != newDevices.end() ; ++it ) {
if (find( (*it) )) // is already inserted
continue;
deviceItem = new BTDeviceItem( ListView2 , (*it) );
deviceItem->setPixmap( 1, m_findPix );
deviceItem->setExpandable ( true );
// look if device is avail. atm, async
deviceActive( (*it) );
// ggf auch hier?
addServicesToDevice( deviceItem );
}
}
/**
* Action that is toggled on entrys on click
*/
void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) {
}
/**
* Action that are toggled on hold (mostly QPopups i guess)
*/
void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) {
if (!item )
return;
QPopupMenu *menu = new QPopupMenu();
int ret=0;
if ( ((BTListItem*)item)->type() == "device") {
QPopupMenu *groups = new QPopupMenu();
menu->insertItem( ((BTDeviceItem*)item)->name(),0 );
menu->insertSeparator(1);
menu->insertItem( tr("rescan sevices"), 2);
menu->insertItem( tr("to group"), groups , 3);
menu->insertItem( tr("delete"), 4);
ret = menu->exec( point , 0);
switch(ret) {
case -1:
break;
case 2:
addServicesToDevice( (BTDeviceItem*)item );
break;
case 4:
// deletes childs too
delete item;
break;
}
delete groups;
}
/*
* We got service sensitive PopupMenus in our factory
* We will create one through the factory and will insert
* our Separator + ShowInfo into the menu or create a new
* one if the factory returns 0
* PopupMenu deletion is kind of weird.
* If escaped( -1 ) or any of our items were chosen we'll
* delete the PopupMenu otherwise it's the responsibility of
* the PopupMenu to delete itself
*
*/
else if ( ((BTListItem*)item)->type() == "service") {
BTServiceItem* service = (BTServiceItem*)item;
QMap<int, QString> list = service->services().classIdList();
QMap<int, QString>::Iterator it = list.begin();
QPopupMenu *popup =0l;
if ( it != list.end() ) {
qWarning("Searching id %d %s", it.key(), it.data().latin1() );
popup = m_popHelper.find( it.key(),
service->services(),
(BTDeviceItem*)service->parent() );
}else {
qWarning("Empty");
}
if ( popup == 0l ) {
qWarning("factory returned 0l");
popup = new QPopupMenu();
}
int test1 = popup->insertItem( tr("Test1:"), 2);
ret = popup->exec( point );
qWarning("returned from exec() ");
if ( ret == -1 ) {
;
} else if ( ret == test1 ) {
;
}
delete popup;
}
delete menu;
}
/**
* Search and display avail. services for a device (on expand from device listing)
* @param item the service item returned
*/
void BlueBase::addServicesToDevice( BTDeviceItem * item ) {
qDebug("addServicesToDevice");
// row of mac adress text(3)
RemoteDevice device = item->remoteDevice();
m_deviceList.insert( item->mac() , item );
// and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back
m_localDevice->searchServices( device );
}
/**
* Overloaded. This one it the one that is
ted to the foundServices signal
* @param device the mac address of the remote device
* @param servicesList the list with the service the device has.
*/
void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) {
qDebug("fill services list");
QMap<QString,BTDeviceItem*>::Iterator it;
BTDeviceItem* deviceItem = 0;
// get the right devices which requested the search
it = m_deviceList.find( device );
if( it == m_deviceList.end() )
return;
deviceItem = it.data();
// remove previous entries
QList<QListViewItem> tempList;
tempList.setAutoDelete( true );
QListViewItem * child = deviceItem->firstChild();
while( child ) {
tempList.append( child );
child = child->nextSibling();
}
tempList.clear();
QValueList<OpieTooth::Services>::Iterator it2;
BTServiceItem* serviceItem;
if (!servicesList.isEmpty() ) {
// add services
QMap<int, QString> list;
QMap<int, QString>::Iterator classIt;
for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
serviceItem = new BTServiceItem( deviceItem, (*it2) );
list = (*it2).classIdList();
classIt = list.begin();
int classId=0;
if ( classIt != list.end() ) {
classId = classIt.key();
}
serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) );
}
} else {
Services s1;
s1.setServiceName( tr("no services found") );
serviceItem = new BTServiceItem( deviceItem, s1 );
}
// now remove them from the list
m_deviceList.remove( it );
}
void BlueBase::addSignalStrength() {
QListViewItemIterator it( ListView4 );
for ( ; it.current(); ++it ) {
m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() );
}
QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) );
}
void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) {
QListViewItemIterator it( ListView4 );
for ( ; it.current(); ++it ) {
if( ((BTConnectionItem*)it.current())->connection().mac() == mac ) {
((BTConnectionItem*)it.current() )->setSignalStrength( strength );
}
}
}
/**
* Add the existing connections (pairs) to the connections tab.
* This one triggers the search
*/
void BlueBase::addConnectedDevices() {
m_localDevice->searchConnections();
}
/**
* This adds the found connections to the connection tab.
* @param connectionList the ValueList with all current connections
*/
void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) {
QValueList<OpieTooth::ConnectionState>::Iterator it;
BTConnectionItem * connectionItem;
if ( !connectionList.isEmpty() ) {
for (it = connectionList.begin(); it != connectionList.end(); ++it) {
QListViewItemIterator it2( ListView4 );
bool found = false;
for ( ; it2.current(); ++it2 ) {
if( ( (BTConnectionItem*)it2.current())->connection().mac() == (*it).mac() ) {
found = true;
}
}
if ( found == false ) {
connectionItem = new BTConnectionItem( ListView4, (*it) );
if( m_deviceList.find((*it).mac()).data() ) {
connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() );
}
}
}
QListViewItemIterator it2( ListView4 );
for ( ; it2.current(); ++it2 ) {
bool found = false;
for (it = connectionList.begin(); it != connectionList.end(); ++it) {
if( ( ((BTConnectionItem*)it2.current())->connection().mac() ) == (*it).mac() ) {
found = true;
}
}
if ( !found ) {
delete it2.current();
}
}
} else {
ListView4->clear();
ConnectionState con;
con.setMac( tr("No connections found") );
connectionItem = new BTConnectionItem( ListView4 , con );
}
// recall connection search after some time
QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) );
}
/**
* Find out if a device can currently be reached
* @param device
*/
void BlueBase::deviceActive( const RemoteDevice &device ) {
// search by mac, async, gets a signal back
// We should have a BTDeviceItem there or where does it get added to the map -zecke
m_localDevice->isAvailable( device.mac() );
}
/**
* The signal catcher. Set the avail. status on device.
* @param device - the mac address
* @param connected - if it is avail. or not
*/
void BlueBase::deviceActive( const QString& device, bool connected ) {
qDebug("deviceActive slot");
QMap<QString,BTDeviceItem*>::Iterator it;
it = m_deviceList.find( device );
if( it == m_deviceList.end() )
return;
BTDeviceItem* deviceItem = it.data();
if ( connected ) {
deviceItem->setPixmap( 1, m_onPix );
} else {
deviceItem->setPixmap( 1, m_offPix );
}
m_deviceList.remove( it );
}
/**
* Open the "scan for devices" dialog
*/
void BlueBase::startScan() {
ScanDialog *scan = new ScanDialog( this, "ScanDialog",
true, WDestructiveClose );
QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ),
this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) );
scan->showMaximized();
}
/**
* Set the informations about the local device in information Tab
*/
void BlueBase::setInfo() {
StatusLabel->setText( status() );
}
/**
* Decontructor
*/
BlueBase::~BlueBase() {
writeSavedDevices();
delete m_iconLoader;
}
/**
* find searches the ListView for a BTDeviceItem containig
* the same Device if found return true else false
* @param dev RemoteDevice to find
* @return returns true if found
*/
bool BlueBase::find( const RemoteDevice& rem ) {
QListViewItemIterator it( ListView2 );
BTListItem* item;
BTDeviceItem* device;
for (; it.current(); ++it ) {
item = (BTListItem*) it.current();
if ( item->typeId() != BTListItem::Device )
continue;
device = (BTDeviceItem*)item;
if ( rem.equals( device->remoteDevice() ) )
return true;
}
return false; // not found
}
diff --git a/noncore/net/ubrowser/httpfactory.cpp b/noncore/net/ubrowser/httpfactory.cpp
index b57149f..369f206 100644
--- a/noncore/net/ubrowser/httpfactory.cpp
+++ b/noncore/net/ubrowser/httpfactory.cpp
@@ -1,376 +1,376 @@
/*
Opie-uBrowser. a very small web browser, using on QTextBrowser for html display/parsing
Copyright (C) 2002 Thomas Stephens
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "httpfactory.h"
HttpFactory::HttpFactory(QTextBrowser *newBrowser):QMimeSourceFactory()
{
// socket = new QSocket;
text = new QTextDrag;
browser=newBrowser;
// comm = new HttpComm(socket, browser);
image = new QImageDrag;
}
const QMimeSource * HttpFactory::data(const QString &abs_name) const
{
printf("HttpFactory::data: using absolute data func\n");
int port=80, addrEnd, portSep;
QString host, file, portS, name, tempString;
bool done=false, isText=true;
// comm->setUp((QString *)&abs_name);
name = abs_name;
// name = name.lower();
name = name.stripWhiteSpace();
// printf("%s\n", name.latin1());
if(name.startsWith("http://"))
{
name = name.remove(0, 7);
}
else
{
name.prepend(browser->context());
name = name.remove(0, 7);
}
addrEnd = name.find('/');
if(addrEnd == -1)
{
name += '/';
addrEnd = name.length()-1;
}
host = name;
file = name;
host.truncate(addrEnd);
file.remove(0, addrEnd);
portSep = host.find(':');
if(portSep != -1)
{
portS=host;
host.truncate(portSep);
portS.remove(0, portSep+1);
port = portS.toInt();
}
// printf("%s %s %d\n", host.latin1(), file.latin1(), port);
if(port == 80)
{
portS="80";
}
// if(file.find(".png", file.length()-4) != -1 || file.find(".gif", file.length()-4) != -1 || file.find(".jpg", file.length()-4) != -1)
// {
// isImage=true;
// }
// comm->setStuff(host, portS, file, text, image, isImage);
// socket->connectToHost(host, port);
int con, bytesSent;
struct sockaddr_in serverAddr;
struct hostent * serverInfo = gethostbyname( host.latin1() );
if( serverInfo == NULL )
{
- QMessageBox *mb = new QMessageBox("Error!",
- "couldnt find ip address",
+ QMessageBox *mb = new QMessageBox(QObject::tr("Error!"),
+ QObject::tr("IP-Address not found"),
QMessageBox::NoIcon,
QMessageBox::Ok,
QMessageBox::NoButton,
QMessageBox::NoButton);
mb->exec();
perror("HttpFactory::data:");
return 0;
}
QByteArray data;
// printf( "HttpFactory::data: %s\n", inet_ntoa(*((struct in_addr *)serverInfo->h_addr )) );
QString request("GET " + file + " HTTP/1.1\r\nHost: " + host + ':' + portS + "\r\nConnection: close\r\n\r\n");
con = socket( AF_INET, SOCK_STREAM, 0 );
if( con == -1 )
{
- QMessageBox *mb = new QMessageBox("Error!",
- "couldnt create socket",
+ QMessageBox *mb = new QMessageBox(QObject::tr("Error!"),
+ QObject::tr("Error creating socket"),
QMessageBox::NoIcon,
QMessageBox::Ok,
QMessageBox::NoButton,
QMessageBox::NoButton);
mb->exec();
perror("HttpFactory::data:");
return 0;
}
serverAddr.sin_family = AF_INET;
serverAddr.sin_port = htons( port );
serverAddr.sin_addr.s_addr = inet_addr( inet_ntoa(*((struct in_addr *)serverInfo->h_addr )) );
memset( &(serverAddr.sin_zero), '\0', 8 );
if(::connect( con, (struct sockaddr *)&serverAddr, sizeof(struct sockaddr)) == -1 )
{
- QMessageBox *mb = new QMessageBox("Error!",
- "couldnt connect to socket",
+ QMessageBox *mb = new QMessageBox(QObject::tr("Error!"),
+ QObject::tr("Error connecting to socket"),
QMessageBox::NoIcon,
QMessageBox::Ok,
QMessageBox::NoButton,
QMessageBox::NoButton);
mb->exec();
perror("HttpFactory::data:");
return 0;
}
bytesSent = send( con, request.latin1(), request.length(), 0);
// printf("HttpFactory::data: bytes written: %d out of: %d\n", bytesSent, request.length() );
// printf("HttpFactory::data: request sent:\n%s", request.latin1());
data = this->processResponse( con, isText );
::close( con );
if(isText)
{
text->setText( QString( data ) );
return text;
}
else
{
image->setImage( QImage( data ) );
return image;
}
}
const QMimeSource * HttpFactory::data(const QString &abs_or_rel_name, const QString & context) const
{
printf("HttpFactory::data: using relative data func\n");
if(abs_or_rel_name.startsWith(context))
{
return data(abs_or_rel_name);
}
else
{
return data(context + abs_or_rel_name);
}
return 0;
}
const QByteArray HttpFactory::processResponse( int sockfd, bool &isText ) const
{
QByteArray inputBin( 1 );
QByteArray conClosedErr( 27 );
char conClosedErrMsg[] = "Connection to server closed";
QString currentLine;
bool done=false, chunked=false;
int dataLength = 0;
for( int i = 0; i < 27; i++)
{
conClosedErr[i] = conClosedErrMsg[i];
}
while( !done )
{
recv( sockfd, inputBin.data(), inputBin.size(), 0 );
currentLine += *(inputBin.data());
if( *(inputBin.data()) == '\n' )
{
if( currentLine.isEmpty() || currentLine.startsWith( "\r") )
{
printf( "HttpFactory::processResponse: end of header\n" );
if( chunked )
{
return recieveChunked( sockfd );
} else {
return recieveNormal( sockfd, dataLength );
}
done = true;
}
if( currentLine.contains( "Transfer-Encoding: chunked", false) >= 1 )
{
chunked = true;
// printf( "HttpFactory::processResponse: chunked encoding\n" );
}
if( currentLine.contains( "Content-Type: text", false ) >= 1 )
{
isText = true;
// printf( "HttpFactory::processResponse: content type text\n" );
if( currentLine.contains( "html", false ) >= 1)
{
browser->setTextFormat(Qt::RichText);
// printf( "HttpFactory::processResponse: content type html\n" );
}
}
if( currentLine.contains( "Content-Type: image", false ) >= 1 )
{
isText = false;
// printf( "HttpFactory::processResponse: content type image\n" );
}
if( currentLine.contains( "Content-Length", false ) >= 1 )
{
currentLine.remove( 0, 16 );
dataLength = currentLine.toInt();
// printf( "HttpFactory::processResponse: content length: %d\n", dataLength );
}
if( currentLine.contains( "404", false ) >= 1 )
{
// printf( "HttpFactory::processResponse: 404 error\n" );
return 0;
}
currentLine = "";
// printf("HttpFactory::processResponse: reseting currentLine: %s\n", currentLine.latin1() );
}
}
}
const QByteArray HttpFactory::recieveNormal( int sockfd, int dataLen ) const
{
// printf( "HttpFactory::recieveNormal: recieving w/out chunked encoding\n" );
QByteArray data( dataLen );
QByteArray temp( dataLen );
int recieved, i;
recieved = recv( sockfd, temp.data(), temp.size(), 0 );
// printf( "HttpFactory::recieveNormal: found some data: %s\n", (char *)temp.data() );
for( i = 0; i < recieved; i++ )
{
data[i] = temp[i];
}
dataLen -= recieved;
while( dataLen > 0 )
{
recieved = recv( sockfd, temp.data(), temp.size(), 0 );
dataLen -= recieved;
// printf( "HttpFactory::recieveNormal: found some more data: %s\n", (char *)temp.data() );
for( int j = 0; j < recieved; j++ )
{
data[i] = temp[j];
i++;
}
temp.fill('\0');
}
// printf( "HttpFactory::recieveNormal: end of data\n" );
return data;
}
const QByteArray HttpFactory::recieveChunked( int sockfd ) const
{
// printf( "HttpFactory::recieveChunked: recieving data with chunked encoding\n" );
QByteArray data;
QByteArray temp( 1 );
int recieved, i = 0, cSize = 0;
QString cSizeS;
// printf( "HttpFactory::recieveChunked: temp.size(): %d\n", temp.size() );
recv( sockfd, temp.data(), temp.size(), 0 );
while( *(temp.data()) != '\n' && *(temp.data()) != ';' )
{
// printf( "HttpFactory::recieveChunked: temp.size(): %d\n", temp.size() );
// printf( "HttpFactory::recieveChunked: temp.data(): %c\n", temp[0] );
cSizeS += temp[0];
recv( sockfd, temp.data(), temp.size(), 0 );
}
// printf( "HttpFactory::recieveChunked: cSizeS: %s\n", cSizeS.latin1() );
cSize = cSizeS.toInt( 0, 16 );
// printf( "HttpFactory::recieveChunked: first chunk of size: %d\n", cSize );
if( *(temp.data()) == ';' )
{
while( *(temp.data()) != '\n' )
{
recv( sockfd, temp.data(), temp.size(), 0 );
}
}
temp.fill( '\0', cSize );
data.fill( '\0', cSize );
while( cSize > 0 )
{
while( cSize > 0 )
{
recieved = recv( sockfd, temp.data(), temp.size(), 0 );
cSize -= recieved;
for( int j = 0; j < recieved; j++ )
{
data[i] = temp[j];
i++;
}
temp.fill('\0', cSize);
}
// printf( "HttpFactory::recieveChunked: current data:\n%s", data.data() );
temp.fill('\0', 1);
cSizeS = "";
cSize = 0;
recv( sockfd, temp.data(), temp.size(), 0 );
if( *(temp.data()) == '\r' )
{
recv( sockfd, temp.data(), temp.size(), 0 );
}
recv( sockfd, temp.data(), temp.size(), 0 );
while( *(temp.data()) != '\n' && *(temp.data()) != ';' )
{
// printf( "HttpFactory::recieveChunked: temp.size(): %d\n", temp.size() );
// printf( "HttpFactory::recieveChunked: temp.data(): %d\n", temp[0] );
cSizeS += temp[0];
recv( sockfd, temp.data(), temp.size(), 0 );
}
// printf( "HttpFactory::recieveChunked: cSizeS: %s\n", cSizeS.latin1() );
cSize = cSizeS.toInt( 0, 16 );
// printf( "HttpFactory::recieveChunked: next chunk of size: %d\n", cSize );
if( *(temp.data()) == ';' )
{
while( *(temp.data()) != '\n' )
{
recv( sockfd, temp.data(), temp.size(), 0 );
}
}
temp.fill( '\0', cSize );
data.resize( data.size() + cSize );
}
// printf( "HttpFactory::recieveChunked: end of data\n" );
return data;
}
diff --git a/noncore/net/ubrowser/mainview.cpp b/noncore/net/ubrowser/mainview.cpp
index f68c5db..9302f05 100644
--- a/noncore/net/ubrowser/mainview.cpp
+++ b/noncore/net/ubrowser/mainview.cpp
@@ -1,121 +1,121 @@
/*
Opie-uBrowser. a very small web browser, using on QTextBrowser for html display/parsing
Copyright (C) 2002 Thomas Stephens
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mainview.h"
MainView::MainView(QWidget *parent, const char *name) : QMainWindow(parent, name)
{
setIcon( Resource::loadPixmap( "remote" ) );
- setCaption("uBrowser");
+ setCaption(tr("uBrowser"));
setToolBarsMovable( false );
QPEToolBar *toolbar = new QPEToolBar(this, "toolbar");
back = new QToolButton(Resource::loadPixmap("ubrowser/back"), 0, 0, 0, 0, toolbar, "back");
forward = new QToolButton(Resource::loadPixmap("ubrowser/forward"), 0, 0, 0, 0, toolbar, "forward");
home = new QToolButton(Resource::loadPixmap("ubrowser/home"), 0, 0, 0, 0, toolbar, "home");
location = new QComboBox(true, toolbar, "location");
go = new QToolButton(Resource::loadPixmap("ubrowser/go"), 0, 0, 0, 0, toolbar, "go");
toolbar->setStretchableWidget(location);
toolbar->setHorizontalStretchable(true);
location->setAutoCompletion( true );
addToolBar(toolbar);
browser = new QTextBrowser(this, "browser");
setCentralWidget(browser);
//make the button take you to the location
connect(go, SIGNAL(clicked()), this, SLOT(goClicked()) );
connect(location->lineEdit(), SIGNAL(returnPressed()), this, SLOT(goClicked()) );
//make back, forward and home do their thing (isnt QTextBrowser great?)
connect(back, SIGNAL(clicked()), browser, SLOT(backward()) );
connect(forward, SIGNAL(clicked()), browser, SLOT(forward()) );
connect(home, SIGNAL(clicked()), browser, SLOT(home()) );
//make back and forward buttons be enabled, only when you can go back or forward (again, i love QTextBrowser)
//this doesnt seem to work, but doesnt break anything either...
connect(browser, SIGNAL(backwardAvailable(bool)), back, SLOT(setOn(bool)) );
connect(browser, SIGNAL(forwardAvailable(bool)), forward, SLOT(setOn(bool)) );
//notify me when the text of the browser has changed (like when the user clicks a link)
connect(browser, SIGNAL(textChanged()), this, SLOT(textChanged()) );
http = new HttpFactory(browser);
if( qApp->argc() > 1 )
{
char **argv = qApp->argv();
int i = 0;
QString *openfile = new QString( argv[0] );
while( openfile->contains( "ubrowser" ) == 0 && i < qApp->argc() )
{
i++;
*openfile = argv[i];
}
*openfile = argv[i+1];
if( !openfile->startsWith( "http://" ) && !openfile->startsWith( "/" ) )
{
openfile->insert( 0, QDir::currentDirPath()+"/" );
}
location->setEditText( *openfile );
goClicked();
}
}
void MainView::goClicked()
{
location->insertItem( location->currentText() );
if(location->currentText().startsWith("http://") )
{
location->setEditText(location->currentText().lower());
browser->setMimeSourceFactory(http);
printf("MainView::goClicked: using http source factory\n");
}
else
{
browser->setMimeSourceFactory(QMimeSourceFactory::defaultFactory());
printf("MainView::goClicked: using default source factory\n");
}
browser->setSource(location->currentText());
}
void MainView::textChanged()
{
if(browser->documentTitle().isNull())
{
- setCaption(browser->source() + " - uBrowser");
+ setCaption( tr("%1 - uBrowser").arg( browser->source() ) );
}
else
{
- setCaption(browser->documentTitle() + " - uBrowser");
+ setCaption(tr(" - uBrowser").arg( browser->documentTitle() ));
}
location->setEditText(browser->source());
}
void MainView::setDocument( const QString& applnk_filename )
{
DocLnk *file = new DocLnk( applnk_filename );
location->setEditText( file->file() );
goClicked();
}
diff --git a/noncore/net/ubrowser/opie-ubrowser.control b/noncore/net/ubrowser/opie-ubrowser.control
new file mode 100644
index 0000000..61a6cde
--- a/dev/null
+++ b/noncore/net/ubrowser/opie-ubrowser.control
@@ -0,0 +1,10 @@
+Package: opie-ubrowser
+Files: bin/ubrowser apps/Applications/ubrowser.desktop pics/ubrowser/*.png
+Priority: optional
+Section: opie/applications
+Maintainer: Thomas Stephens <spiralman@softhome.net>
+Architecture: arm
+Version: 0.1-$SUB_VERSION
+Depends: task-opie-minimal
+License: GPL
+Description: a very small web browser
diff --git a/noncore/unsupported/mailit/config.in b/noncore/unsupported/mailit/config.in
index 2b56b5f..142b840 100644
--- a/noncore/unsupported/mailit/config.in
+++ b/noncore/unsupported/mailit/config.in
@@ -1,4 +1,4 @@
config MAILIT
- boolean "mailit"
+ boolean "opie-mailit (a simple POP3 email client)"
default "n"
depends ( LIBQPE || LIBQPE-X11 )
diff --git a/noncore/unsupported/mailit/popclient.cpp b/noncore/unsupported/mailit/popclient.cpp
index 5da3bcb..1df6b2b 100644
--- a/noncore/unsupported/mailit/popclient.cpp
+++ b/noncore/unsupported/mailit/popclient.cpp
@@ -1,331 +1,332 @@
/**********************************************************************
** Copyright (C) 2001 Trolltech AS. All rights reserved.
**
** This file is part of Qt Palmtop Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "popclient.h"
#include "emailhandler.h"
//#define APOP_TEST
extern "C" {
#include "md5.h"
}
#include <qcstring.h>
PopClient::PopClient()
{
socket = new QSocket(this, "popClient");
connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
stream = new QTextStream(socket);
receiving = FALSE;
synchronize = FALSE;
lastSync = 0;
headerLimit = 0;
+ mailList = 0;
preview = FALSE;
}
PopClient::~PopClient()
{
delete socket;
delete stream;
}
void PopClient::newConnection(const QString &target, int port)
{
if (receiving) {
qWarning("socket in use, connection refused");
return;
}
status = Init;
socket->connectToHost(target, port);
receiving = TRUE;
//selected = FALSE;
emit updateStatus(tr("DNS lookup"));
}
void PopClient::setAccount(const QString &popUser, const QString &popPasswd)
{
popUserName = popUser;
popPassword = popPasswd;
}
void PopClient::setSynchronize(int lastCount)
{
synchronize = TRUE;
lastSync = lastCount;
}
void PopClient::removeSynchronize()
{
synchronize = FALSE;
lastSync = 0;
}
void PopClient::headersOnly(bool headers, int limit)
{
preview = headers;
headerLimit = limit;
}
void PopClient::setSelectedMails(MailList *list)
{
selected = TRUE;
mailList = list;
}
void PopClient::connectionEstablished()
{
emit updateStatus(tr("Connection established"));
}
void PopClient::errorHandling(int status)
{
errorHandlingWithMsg( status, QString::null );
}
void PopClient::errorHandlingWithMsg(int status, const QString & Msg )
{
emit updateStatus(tr("Error Occured"));
emit errorOccurred(status, Msg);
socket->close();
receiving = FALSE;
}
void PopClient::incomingData()
{
QString response, temp, temp2, timeStamp;
QString md5Source;
int start, end;
// char *md5Digest;
char md5Digest[16];
// if ( !socket->canReadLine() )
// return;
response = socket->readLine();
switch(status) {
//logging in
case Init: {
#ifdef APOP_TEST
start = response.find('<',0);
end = response.find('>', start);
if( start >= 0 && end > start )
{
timeStamp = response.mid( start , end - start + 1);
md5Source = timeStamp + popPassword;
md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]);
for(int j =0;j < MD5_DIGEST_LENGTH ;j++)
{
printf("%x", md5Digest[j]);
}
printf("\n");
// qDebug(md5Digest);
*stream << "APOP " << popUserName << " " << md5Digest << "\r\n";
// qDebug("%s", stream);
status = Stat;
}
else
#endif
{
timeStamp = "";
*stream << "USER " << popUserName << "\r\n";
status = Pass;
}
break;
}
case Pass: {
*stream << "PASS " << popPassword << "\r\n";
status = Stat;
break;
}
//ask for number of messages
case Stat: {
if (response[0] == '+') {
*stream << "STAT" << "\r\n";
status = Mcnt;
} else errorHandlingWithMsg(ErrLoginFailed, response);
break;
}
//get count of messages, eg "+OK 4 900.." -> int 4
case Mcnt: {
if (response[0] == '+') {
temp = response.replace(0, 4, "");
int x = temp.find(" ", 0);
temp.truncate((uint) x);
newMessages = temp.toInt();
messageCount = 1;
status = List;
if (synchronize) {
//messages deleted from server, reload all
if (newMessages < lastSync)
lastSync = 0;
messageCount = 1;
}
- if (selected) {
+ if (selected && mailList ) {
int *ptr = mailList->first();
if (ptr != 0) {
newMessages++; //to ensure no early jumpout
messageCount = *ptr;
} else newMessages = 0;
}
} else errorHandlingWithMsg(ErrUnknownResponse, response);
}
//Read message number x, count upwards to messageCount
case List: {
if (messageCount <= newMessages) {
*stream << "LIST " << messageCount << "\r\n";
status = Size;
temp2.setNum(newMessages - lastSync);
temp.setNum(messageCount - lastSync);
if (!selected) {
emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
} else {
//completing a previously closed transfer
/* if ( (messageCount - lastSync) <= 0) {
temp.setNum(messageCount);
emit updateStatus(tr("Previous message ") + temp);
} else {*/
emit updateStatus(tr("Completing message ") + temp);
//}
}
break;
} else {
emit updateStatus(tr("No new Messages"));
status = Quit;
}
}
//get size of message, eg "500 characters in message.." -> int 500
case Size: {
if (status != Quit) { //because of idiotic switch
if (response[0] == '+') {
temp = response.replace(0, 4, "");
int x = temp.find(" ", 0);
temp = temp.right(temp.length() - ((uint) x + 1) );
mailSize = temp.toInt();
emit currentMailSize(mailSize);
status = Retr;
} else {
//qWarning(response);
errorHandlingWithMsg(ErrUnknownResponse, response);
}
}
}
//Read message number x, count upwards to messageCount
case Retr: {
if (status != Quit) {
if ((selected)||(mailSize <= headerLimit))
{
*stream << "RETR " << messageCount << "\r\n";
} else { //only header
*stream << "TOP " << messageCount << " 0\r\n";
}
messageCount++;
status = Ignore;
break;
} }
case Ignore: {
if (status != Quit) { //because of idiotic switch
if (response[0] == '+') {
message = "";
status = Read;
if (!socket->canReadLine()) //sync. problems
break;
response = socket->readLine();
} else errorHandlingWithMsg(ErrUnknownResponse, response);
}
}
//add all incoming lines to body. When size is reached, send
//message, and go back to read new message
case Read: {
if (status != Quit) { //because of idiotic switch
message += response;
while ( socket->canReadLine() ) {
response = socket->readLine();
message += response;
}
emit downloadedSize(message.length());
int x = message.find("\r\n.\r\n",-5);
if (x == -1) {
break;
} else { //message reach entire size
if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active
{
emit newMessage(message, messageCount-1, mailSize, TRUE);
} else { //incomplete mail downloaded
emit newMessage(message, messageCount-1, mailSize, FALSE);
}
if ((messageCount > newMessages)||(selected)) //last message ?
{
status = Quit;
if (selected) { //grab next from queue
newMessages--;
status = Quit;
}
}
else
{
*stream << "LIST " << messageCount << "\r\n";
status = Size;
temp2.setNum(newMessages - lastSync);
temp.setNum(messageCount - lastSync);
emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
break;
}
}
}
if (status != Quit)
break;
}
case Quit: {
*stream << "Quit\r\n";
status = Done;
int newM = newMessages - lastSync;
if (newM > 0) {
temp.setNum(newM);
emit updateStatus(temp + tr(" new messages"));
} else {
emit updateStatus(tr("No new messages"));
}
socket->close();
receiving = FALSE;
emit mailTransfered(newM);
break;
}
}
}
diff --git a/noncore/unsupported/mailit/resource.cpp b/noncore/unsupported/mailit/resource.cpp
deleted file mode 100644
index dc19880..0000000
--- a/noncore/unsupported/mailit/resource.cpp
+++ b/dev/null
@@ -1,136 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
-#include "qpeapplication.h"
-#include "resource.h"
-#include <qdir.h>
-#include <qfile.h>
-#include <qregexp.h>
-#include <qpixmapcache.h>
-#include <qpainter.h>
-
-#include "inlinepics_p.h"
-
-/*!
- \class Resource resource.h
- \brief The Resource class provides access to named resources.
-
- The resources may be provided from files or other sources.
-*/
-
-/*!
- \fn Resource::Resource()
- \internal
-*/
-
-/*!
- Returns the QPixmap named \a pix. You should avoid including
- any filename type extension (eg. .png, .xpm).
-*/
-QPixmap Resource::loadPixmap( const QString &pix )
-{
- QPixmap pm;
- QString key="QPE_"+pix;
- if ( !QPixmapCache::find(key,pm) ) {
- pm.convertFromImage(loadImage(pix));
- QPixmapCache::insert(key,pm);
- }
- return pm;
-}
-
-/*!
- Returns the QBitmap named \a pix. You should avoid including
- any filename type extension (eg. .png, .xpm).
-*/
-QBitmap Resource::loadBitmap( const QString &pix )
-{
- QBitmap bm;
- bm = loadPixmap(pix);
- return bm;
-}
-
-/*!
- Returns the filename of a pixmap named \a pix. You should avoid including
- any filename type extension (eg. .png, .xpm).
-
- Normally you will use loadPixmap() rather than this function.
-*/
-QString Resource::findPixmap( const QString &pix )
-{
- QString picsPath = QPEApplication::qpeDir() + "pics/";
-
- if ( QFile( picsPath + pix + ".png").exists() )
- return picsPath + pix + ".png";
- else if ( QFile( picsPath + pix + ".xpm").exists() )
- return picsPath + pix + ".xpm";
- else if ( QFile( picsPath + pix ).exists() )
- return picsPath + pix;
-
- //qDebug("Cannot find pixmap: %s", pix.latin1());
- return QString();
-}
-
-/*!
- Returns a sound file for a sound named \a name.
- You should avoid including any filename type extension (eg. .wav, .au, .mp3).
-*/
-QString Resource::findSound( const QString &name )
-{
- QString picsPath = QPEApplication::qpeDir() + "sounds/";
-
- QString result;
- if ( QFile( (result = picsPath + name + ".wav") ).exists() )
- return result;
-
- return QString();
-}
-
-/*!
- Returns a list of all sound names.
-*/
-QStringList Resource::allSounds()
-{
- QDir resourcedir( QPEApplication::qpeDir() + "sounds/", "*.wav" );
- QStringList entries = resourcedir.entryList();
- QStringList result;
- for (QStringList::Iterator i=entries.begin(); i != entries.end(); ++i)
- result.append((*i).replace(QRegExp("\\.wav"),""));
- return result;
-}
-
-/*!
- Returns the QImage named \a name. You should avoid including
- any filename type extension (eg. .png, .xpm).
-*/
-QImage Resource::loadImage( const QString &name)
-{
- QImage img = qembed_findImage(name.latin1());
- if ( img.isNull() )
- return QImage(findPixmap(name));
- return img;
-}
-
-/*!
- \fn QIconSet Resource::loadIconSet( const QString &name )
-
- Returns a QIconSet for the pixmap named \a name. A disabled icon is
- generated that conforms to the Qtopia look & feel. You should avoid
- including any filename type extension (eg. .png, .xpm).
-*/
diff --git a/noncore/unsupported/mailit/resource.h b/noncore/unsupported/mailit/resource.h
deleted file mode 100644
index 982c58a..0000000
--- a/noncore/unsupported/mailit/resource.h
+++ b/dev/null
@@ -1,80 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-#ifndef PIXMAPLOADER_H
-#define PIXMAPLOADER_H
-
-#include <qimage.h>
-#include <qbitmap.h>
-#include <qiconset.h>
-#include <qstringlist.h>
-
-class Resource
-{
-public:
- Resource() {}
-
- static QImage loadImage( const QString &name);
-
- static QPixmap loadPixmap( const QString &name );
- static QBitmap loadBitmap( const QString &name );
- static QString findPixmap( const QString &name );
-
- static QIconSet loadIconSet( const QString &name );
-
- static QString findSound( const QString &name );
- static QStringList allSounds();
-};
-
-// Inline for compatibility with SHARP ROMs
-inline QIconSet Resource::loadIconSet( const QString &pix )
-{
- QImage img = loadImage( pix );
- QPixmap pm;
- pm.convertFromImage( img );
- QIconSet is( pm );
- QIconSet::Size size = pm.width() <= 22 ? QIconSet::Small : QIconSet::Large;
-
- QPixmap dpm = loadPixmap( pix + "_disabled" );
-
-#ifndef QT_NO_DEPTH_32 // have alpha-blended pixmaps
- if ( dpm.isNull() ) {
- QImage dimg( img.width(), img.height(), 32 );
- for ( int y = 0; y < img.height(); y++ ) {
- for ( int x = 0; x < img.width(); x++ ) {
- QRgb p = img.pixel( x, y );
- uint a = (p & 0xff000000) / 3;
- p = (p & 0x00ffffff) | (a & 0xff000000);
- dimg.setPixel( x, y, p );
- }
- }
-
- dimg.setAlphaBuffer( TRUE );
- dpm.convertFromImage( dimg );
- }
-#endif
-
- if ( !dpm.isNull() )
- is.setPixmap( dpm, size, QIconSet::Disabled );
-
- return is;
-}
-
-
-#endif
diff --git a/noncore/unsupported/mailit/smtpclient.cpp b/noncore/unsupported/mailit/smtpclient.cpp
index 5b5ef52..51ca50b 100644
--- a/noncore/unsupported/mailit/smtpclient.cpp
+++ b/noncore/unsupported/mailit/smtpclient.cpp
@@ -1,170 +1,170 @@
/**********************************************************************
** Copyright (C) 2001 Trolltech AS. All rights reserved.
**
** This file is part of Qt Palmtop Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "smtpclient.h"
#include "emailhandler.h"
SmtpClient::SmtpClient()
{
socket = new QSocket(this, "smtpClient");
stream = new QTextStream(socket);
mailList.setAutoDelete(TRUE);
connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
sending = FALSE;
}
SmtpClient::~SmtpClient()
{
delete socket;
delete stream;
}
void SmtpClient::newConnection(const QString &target, int port)
{
if (sending) {
qWarning("socket in use, connection refused");
return;
}
status = Init;
sending = TRUE;
socket->connectToHost(target, port);
emit updateStatus(tr("DNS lookup"));
}
void SmtpClient::addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body)
{
RawEmail *mail = new RawEmail;
mail->from = from;
mail->subject = subject;
mail->to = to;
mail->body = body;
mailList.append(mail);
}
void SmtpClient::connectionEstablished()
{
emit updateStatus(tr("Connection established"));
}
void SmtpClient::errorHandling(int status)
{
errorHandlingWithMsg( status, QString::null );
}
void SmtpClient::errorHandlingWithMsg(int status, const QString & EMsg )
{
emit errorOccurred(status, EMsg );
socket->close();
mailList.clear();
sending = FALSE;
}
void SmtpClient::incomingData()
{
QString response;
if (!socket->canReadLine())
return;
response = socket->readLine();
switch(status) {
case Init: {
if (response[0] == '2') {
status = From;
mailPtr = mailList.first();
*stream << "HELO there\r\n";
} else errorHandlingWithMsg(ErrUnknownResponse,response);
break;
}
case From: {
if (response[0] == '2') {
qDebug(mailPtr->from);
- *stream << "MAIL FROM: <" << mailPtr->from << ">\r\n";
+ *stream << "MAIL FROM: " << mailPtr->from << "\r\n";
status = Recv;
} else errorHandlingWithMsg(ErrUnknownResponse, response );
break;
}
case Recv: {
if (response[0] == '2') {
it = mailPtr->to.begin();
if (it == NULL) {
errorHandlingWithMsg(ErrUnknownResponse,response);
}
- *stream << "RCPT TO: <" << *it << ">\r\n";
+ *stream << "RCPT TO: " << *it << "\r\n";
status = MRcv;
} else errorHandlingWithMsg(ErrUnknownResponse,response);
break;
}
case MRcv: {
if (response[0] == '2') {
it++;
if ( it != mailPtr->to.end() ) {
- *stream << "RCPT TO: <" << *it << ">\r\n";
+ *stream << "RCPT TO: " << *it << "\r\n";
break;
} else {
status = Data;
}
} else errorHandlingWithMsg(ErrUnknownResponse,response);
}
case Data: {
if (response[0] == '2') {
*stream << "DATA\r\n";
status = Body;
emit updateStatus(tr("Sending: ") + mailPtr->subject);
} else errorHandlingWithMsg(ErrUnknownResponse,response);
break;
}
case Body: {
if (response[0] == '3') {
*stream << mailPtr->body << "\r\n.\r\n";
mailPtr = mailList.next();
if (mailPtr != NULL) {
status = From;
} else {
status = Quit;
}
} else errorHandlingWithMsg(ErrUnknownResponse,response);
break;
}
case Quit: {
if (response[0] == '2') {
*stream << "QUIT\r\n";
status = Done;
QString temp;
temp.setNum(mailList.count());
emit updateStatus(tr("Sent ") + temp + tr(" messages"));
emit mailSent();
mailList.clear();
sending = FALSE;
socket->close();
} else errorHandlingWithMsg(ErrUnknownResponse,response);
break;
}
}
}
diff --git a/noncore/unsupported/mailit/viewatt.cpp b/noncore/unsupported/mailit/viewatt.cpp
index 293e137..3515ba5 100644
--- a/noncore/unsupported/mailit/viewatt.cpp
+++ b/noncore/unsupported/mailit/viewatt.cpp
@@ -1,121 +1,121 @@
/**********************************************************************
** Copyright (C) 2001 Trolltech AS. All rights reserved.
**
** This file is part of Qt Palmtop Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
-#include "resource.h"
+#include <qpe/resource.h>
#include "viewatt.h"
#include <qwhatsthis.h>
#include <qpe/applnk.h>
#include <qpe/mimetype.h>
ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f)
: QMainWindow(parent, name, f)
{
setCaption(tr("Exploring attatchments"));
setToolBarsMovable( FALSE );
bar = new QToolBar(this);
installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 );
connect(installButton, SIGNAL(activated()), this, SLOT(install()) );
installButton->setWhatsThis(tr("Click here to install the attachment to your Documents"));
listView = new QListView(this, "AttView");
listView->addColumn( tr("Attatchment") );
listView->addColumn( tr("Type") );
listView->addColumn( tr("Installed") );
setCentralWidget(listView);
QWhatsThis::add(listView,QWidget::tr("This is an overview about all attachments in the mail"));
}
void ViewAtt::update(Email *mailIn, bool inbox)
{
QListViewItem *item;
Enclosure *ePtr;
listView->clear();
if (inbox) {
bar->clear();
installButton->addTo( bar );
bar->show();
} else {
bar->hide();
}
mail = mailIn;
for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
QString isInstalled = tr("No");
if (ePtr->installed)
isInstalled = tr("Yes");
item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled);
const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute;
MimeType mt(mtypeDef);
item->setPixmap(0, mt.pixmap());
/*
if (ePtr->contentType == "TEXT") {
actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0);
actions->addTo(bar);
}
if (ePtr->contentType == "AUDIO") {
actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0);
actions->addTo(bar);
item->setPixmap(0, Resource::loadPixmap("play"));
}
if (ePtr->contentType == "IMAGE") {
actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0);
actions->addTo(bar);
item->setPixmap(0, Resource::loadPixmap("pixmap"));
}*/
}
}
void ViewAtt::install()
{
Enclosure *ePtr, *selPtr;
QListViewItem *item;
QString filename;
DocLnk d;
item = listView->selectedItem();
if (item != NULL) {
filename = item->text(0);
selPtr = NULL;
for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
if (ePtr->originalName == filename)
selPtr = ePtr;
}
if (selPtr == NULL) {
qWarning("Internal error, file is not installed to documents");
return;
}
d.setName(selPtr->originalName);
d.setFile(selPtr->path + selPtr->name);
d.setType(selPtr->contentType + "/" + selPtr->contentAttribute);
d.writeLink();
selPtr->installed = TRUE;
item->setText(2, tr("Yes"));
}
}