[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/network/kepas/src
From: Tom Patzig <tpatzig () suse ! de>
Date: 2008-01-24 0:02:37
Message-ID: 1201132957.228525.10874.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 765435 by tpatzig:
-changed to KFileDialog
-display hostname instead of ip
-bugfixes
M +1 -1 CMakeLists.txt
M +1 -1 lib/CMakeLists.txt
M +18 -13 lib/buddylist.cpp
M +3 -0 lib/buddylist.h
M +31 -31 lib/receiver.cpp
M +3 -7 lib/receiver.h
M +1 -0 lib/receiverinfo.h
M +17 -13 lib/servicelocator.cpp
M +1 -1 plasma/CMakeLists.txt
M +3 -2 plasma/plasma-kifer.cpp
M +10 -2 trayicon.cpp
--- trunk/playground/network/kepas/src/CMakeLists.txt #765434:765435
@@ -25,7 +25,7 @@
kde4_add_executable(kepastray ${kifertray_SRCS})
target_link_libraries(kepastray
- ${KDE4_KDEUI_LIBS} ${KDE4_KDNSSD_LIBS} kepas)
+ ${KDE4_KIO_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDE4_KDNSSD_LIBS} \
kepas)
install(TARGETS kepastray
DESTINATION ${KDE4_BIN_INSTALL_DIR})
--- trunk/playground/network/kepas/src/lib/CMakeLists.txt #765434:765435
@@ -36,7 +36,7 @@
kde4_add_library(kepas SHARED ${libkifer_SRCS})
target_link_libraries(kepas
- ${KDE4_KDEUI_LIBS} ${KDE4_KDNSSD_LIBS})
+ ${KDE4_KIO_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDE4_KDNSSD_LIBS})
install(TARGETS kepas
DESTINATION ${LIB_INSTALL_DIR})
--- trunk/playground/network/kepas/src/lib/buddylist.cpp #765434:765435
@@ -65,10 +65,12 @@
BuddyList::~BuddyList()
{
- qDebug() << "deleting buddylist";
+ kdDebug() << "deleting buddylist";
- if (buddyListWidget)
+ if (buddyListWidget) {
+ kdDebug() << "buddyListWidget deleted";
delete buddyListWidget;
+ }
// if (kopeteListWidget)
// delete kopeteListWidget;
@@ -132,7 +134,7 @@
}
buddyListWidget->setEnabled(true);
- qDebug() << "initSendFileBuddyList";
+ kdDebug() << "initSendFileBuddyList";
m_fileName = file;
connect(buddyListWidget, \
SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(slotSendFileDirect(QListWidgetItem*)));
@@ -178,14 +180,14 @@
void BuddyList::delService(QString sn)
{
- qDebug() << "Deleting Buddy!";
+ kdDebug() << "Deleting Buddy!";
if (!buddyVector->isEmpty())
for (int i = 0; i < buddyVector->count(); i++) {
tmpBuddyContent = buddyVector->at(i);
- // qDebug() << "Name:" << tmpBuddyContent->name << " host: " << \
tmpBuddyContent->hostname; + // kdDebug() << "Name:" << tmpBuddyContent->name << " \
host: " << tmpBuddyContent->hostname;
if (tmpBuddyContent->SN == sn) {
- qDebug() << "take item at pos: " << i;
+ kdDebug() << "take item at pos: " << i;
buddyListWidget->takeItem(i);
buddyVector->remove(i);
}
@@ -207,7 +209,7 @@
void BuddyList::slotItemSelectionChanged()
{
- qDebug() << "changed";
+ kdDebug() << "changed";
@@ -267,12 +269,15 @@
int currentIndex = buddyListWidget->row(current);
BuddyContent* cBC = buddyVector->at(currentIndex);
- qDebug() << "current Buddy Content: user " << cBC->name;
- qDebug() << "current Buddy Content: SN " << cBC->SN;
+ kdDebug() << "current Buddy Content: user " << cBC->name;
+ kdDebug() << "current Buddy Content: SN " << cBC->SN;
- QString fileName = QFileDialog::getOpenFileName(this, tr("Select File"),"./","*");
+ QString fileName = KFileDialog::getOpenFileName(KUrl("./"),"*",this, tr("Select \
File")); sendHandler = new Sender(m_parent,cBC->hostname,cBC->port,m_userName);
sendHandler->initFileSender(fileName,1);
+ connect(sendHandler,SIGNAL(transferFinished()), this, SLOT(slotSendFinished()));
+ connect(sendHandler,SIGNAL(transferDenied()), this, SLOT(slotSendFinished()));
+
// connect(sendHandler, SIGNAL(requestFinished(int)), this, \
SLOT(slotRequestSend(int))); // connect(sendHandler, \
SIGNAL(requestFailed(QString)), this, SLOT(slotRequestFailed(QString))); \
sendHandler->sendFileRequest(); @@ -398,7 +403,7 @@
QDBusInterface* interface = new QDBusInterface(service,path,service2,dbusconn);
QDBusReply<QStringList> reply = interface->call(method);
-// qDebug() << "klipper reply: " << reply.value();
+// kdDebug() << "klipper reply: " << reply.value();
QStringList clipList = reply.value();
for (int i=0; i < clipList.size(); i++){
@@ -438,7 +443,7 @@
}
sendHandler->deleteLater();
- qDebug() << "sendHandler deleted";
+ kdDebug() << "sendHandler deleted";
close();
@@ -489,7 +494,7 @@
}
}
- qDebug() << "Kopete Online Account found = " << ID;
+ kdDebug() << "Kopete Online Account found = " << ID;
}
--- trunk/playground/network/kepas/src/lib/buddylist.h #765434:765435
@@ -31,6 +31,9 @@
#include <QtDBus>
#include <kconfig.h>
#include <KIcon>
+#include <KFileDialog>
+#include <kfiledialog.h>
+#include <kurl.h>
#include <klocalizedstring.h>
#include <QList>
--- trunk/playground/network/kepas/src/lib/receiver.cpp #765434:765435
@@ -84,8 +84,8 @@
if (header.method() == "GET" && header.value("Request") == "Send") {
- if (createNewPeer(header,m_sock->peerAddress().toString()))
- notifyUser(header,m_sock);
+ ReceiverInfo* peerInfo = createNewPeer(header,m_sock->peerAddress().toString());
+ notifyUser(peerInfo,m_sock);
} else if (header.method() == "POST" && header.value("Request") == "Payload" ) {
qDebug() << "Bytes: " << m_sock->bytesAvailable();
@@ -101,28 +101,31 @@
}
-bool Receiver::createNewPeer(QHttpRequestHeader& header, QString ip)
+ReceiverInfo* Receiver::createNewPeer(QHttpRequestHeader& header, QString ip)
{
info = new ReceiverInfo(header.value("Name"),"",ip,header.value("Size").toInt(),this);
- info->hostName = ip;
- QHostInfo::lookupHost(ip,this, SLOT(hostLookedUp(QHostInfo)));
+ info->hostName = header.value("Host").split(":").at(0);
+ info->userName = header.value("UserName");
+
+ qDebug() << "New Sender: " << header.value("UserName") + "@" + \
header.value("Host"); + qDebug() << "Filer: " << header.value("Name") + " " + \
header.value("Size");
+// QHostInfo::lookupHost(ip,this, SLOT(hostLookedUp(QHostInfo)));
+
recVec->push_back(info);
- if (info != NULL)
- return true;
- else
- return false;
+ return info;
}
-void Receiver::notifyUser(QHttpRequestHeader& header, QTcpSocket* sock)
+void Receiver::notifyUser(ReceiverInfo* peerInfo, QTcpSocket* sock)
{
-
+/*
userName = header.value("UserName");
fileName = header.value("Name");
fileSize = header.value("Size");
- float size = fileSize.toFloat();
+*/
+ float size = peerInfo->fileSize;
QString m_size;
if (size > (1024*1024*1024))
m_size = QString::number(size/(1024*1024*1024)) + " GB";
@@ -135,21 +138,13 @@
m_sock = sock;
- hostName = info->hostName;
- QString msg = userName + " from " + hostName + " want's to send you a file\n"
- + "Name : " + fileName + "\n"
- + "Size : " + m_size;
+ QString msg = QString("%1 from %2(%3) wants to send you a file\nName : %4\nSize: \
%5") + .arg(peerInfo->userName) \
+ .arg(peerInfo->hostName) \
+ .arg(peerInfo->ip) \
+ .arg(peerInfo->fileName) \
+ .arg(m_size);
-/*
- if (KMessageBox::questionYesNo(this,msg,"Incomming File Transfer...") == 3)
- {
- sendOKToPayLoad(sock);
- } else
- sendDeny(sock);
-*/
-
-//for the new KDE4 notify daemon
-
KNotification *notification= new KNotification ( "incommingFileTransfer", 0L , \
KNotification::Persistent ); notification->setText( msg );
notification->setPixmap( QPixmap("folder-remote") );
@@ -179,18 +174,21 @@
void Receiver::notifyClipAccess(QHttpRequestHeader& header, QTcpSocket* sock)
{
-
+/*
QString msg = userName + " from " + hostName + " want's to see your clipboard";
if (KMessageBox::questionYesNo(this,msg,"Clipboard Access...") == 3)
{
sendClipBoard(sock,header.value("SessionID"));
}
+*/
}
void Receiver::notifyClipReceived(QHttpRequestHeader& header, QTcpSocket* sock)
{
- userName = header.value("UserName");
- QString hostAddress = sock->peerAddress().toString();
+ QString userName = header.value("UserName");
+ QString hostName = header.value("Host").split(":").at(0);
+
+// QString hostAddress = sock->peerAddress().toString();
QByteArray clipData = sock->readAll();
QString clip = clipData.data();
@@ -198,8 +196,10 @@
if (clip.size() >= 30)
clip.truncate(30);
- QString msg = "Received Clipboard entry, from " + userName + "@" + hostAddress + \
"\n" + clip +
- "\nSet active?";
+ QString msg = QString("Received Clipboard entry, from %1@%2\n%3\nSet active?")
+ .arg(userName) \
+ .arg(hostName) \
+ .arg(clip);
/*
if (KMessageBox::questionYesNo(this,msg,"Clipboard from " + userName) == 3)
{
--- trunk/playground/network/kepas/src/lib/receiver.h #765434:765435
@@ -33,6 +33,7 @@
#include <KMessageBox>
#include <knotification.h>
#include <klocale.h>
+//#include <klocalizedstring.h>
#include "receiverinfo.h"
@@ -55,11 +56,6 @@
QTcpSocket* m_sock;
QHttp* http;
-
- QString userName;
- QString fileName;
- QString fileSize;
- QString hostName;
QString uuid;
QString fullclip;
@@ -81,9 +77,9 @@
// QWidget* m_parent;
- bool createNewPeer(QHttpRequestHeader& header, QString ip);
+ ReceiverInfo* createNewPeer(QHttpRequestHeader& header, QString ip);
- void notifyUser(QHttpRequestHeader& header, QTcpSocket*);
+ void notifyUser(ReceiverInfo*, QTcpSocket*);
void notifyClipAccess(QHttpRequestHeader& header, QTcpSocket* sock);
void notifyClipReceived(QHttpRequestHeader& header, QTcpSocket* sock);
--- trunk/playground/network/kepas/src/lib/receiverinfo.h #765434:765435
@@ -39,6 +39,7 @@
QString ip;
int fileSize;
QString sessionID;
+ QString userName;
};
--- trunk/playground/network/kepas/src/lib/servicelocator.cpp #765434:765435
@@ -23,7 +23,7 @@
*/
#include <servicelocator.h>
-#include <qdebug.h>
+#include <KDebug>
ServiceLocator::ServiceLocator(QObject* parent)
{
@@ -36,7 +36,7 @@
QHostInfo hostinfo;
hostname = hostinfo.localHostName();
- qDebug() << "hostname" << hostname;
+ kdDebug() << "hostname" << hostname;
// checkBrowse();
startService();
@@ -47,12 +47,16 @@
ServiceLocator::~ServiceLocator()
{
- qDebug() << "deleting avahiService";
+ kdDebug() << "deleting avahiService";
if (receiver)
delete receiver;
if (service)
delete service;
+ if (browser)
+ delete browser;
+ if (server)
+ delete server;
}
void ServiceLocator::startService()
@@ -63,9 +67,9 @@
connect(server,SIGNAL(newConnection()),this, SLOT(slotNewConnection()));
char* user = getenv("USER");
- qDebug() << "user " << getenv("USER");
+ kdDebug() << "user " << getenv("USER");
receiver->setTargetPath(getenv("HOME"));
- qDebug() << "homedir " << getenv("HOME");
+ kdDebug() << "homedir " << getenv("HOME");
username = user;
// username+="_kifer";
@@ -92,7 +96,7 @@
service = new DNSSD::PublicService("kepas on " + username + "@" + \
hostname,"_giver._tcp",server->serverPort(),"local."); \
service->setTextData(serviceID); bool isOK = service->publish();
- isOK ? qDebug() << "Service published on port " << server->serverPort() : qDebug() \
<< "Service not published"; + isOK ? kdDebug() << "Service published on port " << \
server->serverPort() : kdDebug() << "Service not published";
}
@@ -130,7 +134,7 @@
void ServiceLocator::checkBrowseFinished()
{
- qDebug() << "browse finished";
+ kdDebug() << "browse finished";
if (checkRunStatus)
emit serviceRuns();
else {
@@ -145,7 +149,7 @@
void ServiceLocator::addService(DNSSD::RemoteService::Ptr srv)
{
srv->resolve();
- qDebug() << "Service found " << srv->serviceName();
+ kdDebug() << "Service found " << srv->serviceName();
QMap<QString, QByteArray> map = srv->textData();
/*
if (map["id"].count() == 0) {
@@ -167,7 +171,7 @@
/*
if (map["Machine Name"] == hostname) {
checkRunStatus = true;
- qDebug() << "Service already running!";
+ kdDebug() << "Service already running!";
} else
*/
@@ -177,7 +181,7 @@
void ServiceLocator::delService(DNSSD::RemoteService::Ptr srv)
{
- qDebug() << "Service removed " << srv->serviceName();
+ kdDebug() << "Service removed " << srv->serviceName();
emit delBuddy(srv->serviceName());
}
@@ -185,13 +189,13 @@
void ServiceLocator::slotNewConnection()
{
- qDebug() << "new TCP connection" ;
+ kdDebug() << "new TCP connection" ;
socket = server->nextPendingConnection();
- qDebug() << socket->peerPort();
- qDebug() << socket->peerAddress();
+ kdDebug() << socket->peerPort();
+ kdDebug() << socket->peerAddress();
receiver->defReqType(socket);
--- trunk/playground/network/kepas/src/plasma/CMakeLists.txt #765434:765435
@@ -12,7 +12,7 @@
kde4_add_plugin(plasma_applet_kepas ${kifer-plasma_SRCS})
target_link_libraries(plasma_applet_kepas
- ${PLASMA_LIBS} ${KDE4_KDEUI_LIBS} kepas)
+ ${KDE4_KIO_LIBRARY} ${PLASMA_LIBS} ${KDE4_KDEUI_LIBS} kepas)
install(TARGETS plasma_applet_kepas
DESTINATION ${PLUGIN_INSTALL_DIR})
--- trunk/playground/network/kepas/src/plasma/plasma-kifer.cpp #765434:765435
@@ -232,7 +232,8 @@
void PlasmaKifer::slotFileSelect(bool set)
{
- QString fileName = QFileDialog::getOpenFileName(&m_menu, tr("Select \
File"),"./","*"); +
+ QString fileName = KFileDialog::getOpenFileName(KUrl("./"),"*",&m_menu, tr("Select \
File")); if (fileName.isEmpty())
return;
else {
@@ -277,7 +278,7 @@
void PlasmaKifer::slotSelectDir()
{
- QString dirname = QFileDialog::getExistingDirectory(m_dialog, tr("Select Target \
Directory"),"./"); + QString dirname = \
KFileDialog::getExistingDirectory(KUrl("./"),&m_menu, tr("Select Target Directory")); \
if (!dirname.isEmpty()) ui.saveToLineEdit->setText(dirname);
--- trunk/playground/network/kepas/src/trayicon.cpp #765434:765435
@@ -78,7 +78,13 @@
TrayIcon::~TrayIcon()
{
qDebug() << "bye bye";
+ if (m_dialog)
+ delete m_dialog;
+
delete mainmenu;
+ delete buddylist;
+ delete avahiClient;
+ delete tray;
delete dbus;
}
@@ -167,7 +173,8 @@
void TrayIcon::slotFileSelect(bool)
{
qDebug() << "slotFileSelect";
- QString fileName = QFileDialog::getOpenFileName(mainmenu, tr("Select \
File"),"./","*"); +
+ QString fileName = KFileDialog::getOpenFileName(KUrl("./"),"*",mainmenu, tr("Select \
File")); avahiClient->browse();
connect(avahiClient, SIGNAL(addBuddy(QMap<QString, \
QByteArray>)),buddylist,SLOT(addService(QMap<QString,QByteArray>))); \
connect(avahiClient, SIGNAL(delBuddy(QString)),buddylist,SLOT(delService(QString))); \
@@ -205,7 +212,8 @@
void TrayIcon::slotSelectDir()
{
- QString dirname = QFileDialog::getExistingDirectory(m_dialog, tr("Select Target \
Directory"),"./"); +
+ QString dirname = KFileDialog::getExistingDirectory(KUrl("./"),mainmenu, tr("Select \
Target Directory")); if (!dirname.isEmpty())
ui.saveToLineEdit->setText(dirname);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic