[prev in list] [next in list] [prev in thread] [next in thread]
List: kopete-devel
Subject: Re: [kopete-devel] [PATCH] Winpopup protocol
From: Pali =?utf-8?q?Roh=C3=A1r?= <pali.rohar () gmail ! com>
Date: 2009-09-04 14:30:26
Message-ID: 200909041630.26480.pali.rohar () gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
I fix using smbclient. I add param -I <ip_address> because some smbclient doesnt work \
without param -I. Sometime smbclient doesnt get workgroup for localhost. Winpopup \
protocol is then offline but no error show. I add default localhost workgroup \
WORKGROUP, so it fix. I think it is BUG 140142.
This patch also fix show myself name in chat window and Comment in user info dialog.
Can I commit it to svn?
I cannot upload this patch to reviewboard (same error).
--
Pali Rohár
pali.rohar@gmail.com
On Po 10. August 2009 14:35:04 you wrote:
> Hello,
> I ported from kopete-kde3 button "Install into Samba" for initialize this protocol \
> in samba. This button exist near host name in account widget, but it has none name \
> and do nothing. After click it use bash script winpopup-install.
> And also I fix sending messages and script winpopup-install.
> I remove suffix .sh from scripts winpopup-install and winpopup-send because it use \
> bash (not sh).
> I try upload this patch to reviewboard, but it show me error:
> The file '/trunk/KDE/kdenetwork/kopete/protocols/winpopup/winpopup-install' \
> (r1007087) could not be found in the repository
> I never seen this error before. Patch I generate with svn diff.
>
>
["winpopup.patch" (text/x-patch)]
Index: winpopup-send.sh
===================================================================
--- winpopup-send.sh (revision 1019807)
+++ winpopup-send.sh (working copy)
@@ -1,44 +0,0 @@
-#!/bin/bash
-PATH=/bin:/usr/bin/:/usr/local/bin
-
-# Check input
-[ -z "$1" -o -z "$2" ] && exit 1
-
-# Check if file is indeed a file and readable
-[ ! -f "$1" -o ! -r "$1" ] && exit 1
-
-KOPETE_RUNNING=x`ps -A|grep -e "kopete$"`
-
-if [ "$KOPETE_RUNNING" = "x" ]; then
-
- if [ -z "$3" ]; then
- THIS_SERVER=`uname -n`
- else
- THIS_SERVER="$3"
- fi
-
- if [ "$2" != "$THIS_SERVER" ]; then
- echo -e "Kopete is currently not running.\nYour message was not delivered!" \
\
- | smbclient -N -M $2
- fi
-
-else
-
- # Create a unique filename
- filename="/var/lib/winpopup/`date +%s_%N`"
-
- # the time...
- TIME=`date --iso-8601=seconds`
-
- # the message
- MESSAGE=`cat "$1"`
-
- # Put it into the file
- echo -e "$2\n$TIME\n$MESSAGE" > $filename
-
-
-fi
-
-# Remove the message from samba
-rm -f "$1"
-
Index: wpuserinfo.cpp
===================================================================
--- wpuserinfo.cpp (revision 1019807)
+++ wpuserinfo.cpp (working copy)
@@ -58,6 +58,7 @@
connect( this, SIGNAL( closeClicked() ), this, SLOT( slotCloseClicked() ) );
+ noComment = true;
startDetailsProcess(m_contact->contactId());
}
@@ -73,9 +74,12 @@
KConfigGroup group = KGlobal::config()->group("WinPopup");
QString theSMBClientPath = group.readEntry("SMBClientPath", "/usr/bin/smbclient");
+ if ( host == "LOCALHOST" ) //dont cycle
+ noComment = false;
+
detailsProcess = new QProcess(this);
QStringList args;
- args << "-N" << "-g" << "-L" << host << "-";
+ args << "-N" << "-g" << "-L" << host << "-I" << host;
connect(detailsProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, \
SLOT(slotDetailsProcessFinished(int, QProcess::ExitStatus)));
@@ -93,17 +97,19 @@
QString output = QString::fromUtf8(outputData.data());
QStringList outputList = output.split('\n');
foreach (QString line, outputList) {
- if (info.indexIn(line) != -1) {
+ if (info.indexIn(line) != -1 && noComment) {
Workgroup = info.cap(1);
OS = info.cap(2);
Software = info.cap(3);
}
if (host.indexIn(line) != -1) {
Comment = host.cap(1);
+ noComment = false;
}
}
}
+ disconnect(detailsProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, \
SLOT(slotDetailsProcessFinished(int, QProcess::ExitStatus))); delete detailsProcess;
detailsProcess = 0;
@@ -111,6 +117,9 @@
m_mainWidget->sWorkgroup->setText(Workgroup);
m_mainWidget->sOS->setText(OS);
m_mainWidget->sServer->setText(Software);
+
+ if ( noComment )
+ startDetailsProcess("LOCALHOST"); //smbclient get comment sometime from localhost
}
void WPUserInfo::slotCloseClicked()
Index: wpcontact.cpp
===================================================================
--- wpcontact.cpp (revision 1019807)
+++ wpcontact.cpp (working copy)
@@ -163,6 +163,7 @@
QRegExp subj("^Subject: ([^\n]*)\n(.*)$");
Kopete::Message msg(this, contactList);
msg.setDirection( Kopete::Message::Inbound );
+ msg.setTimestamp(Arrival);
if(subj.indexIn(Body) == -1) {
msg.setPlainBody( Body );
@@ -181,7 +182,7 @@
// Warning: this could crash
kDebug(14170) << message.to().first() << " is " << dynamic_cast<WPContact *>( \
message.to().first() )->contactId();
- QString Message = (!message.subject().isEmpty() ? "Subject: " + message.subject() + \
'\n' : QString("")) + message.plainBody(); + QString Message = \
QString((!message.subject().isEmpty() ? "Subject: " + message.subject() + '\n' : \
QString()) + message.plainBody()).trimmed(); WPAccount *acct = \
dynamic_cast<WPAccount *>(account()); WPContact *contact = dynamic_cast<WPContact \
*>( message.to().first() ); if (acct && contact) {
Index: wpaccount.cpp
===================================================================
--- wpaccount.cpp (revision 1019807)
+++ wpaccount.cpp (working copy)
@@ -47,7 +47,7 @@
// we need this before initActions
Kopete::MetaContact *myself = Kopete::ContactList::self()->myself();
- setMyself( new WPContact(this, accountID, myself->displayName(), myself) );
+ setMyself( new WPContact(this, accountID, QString(), myself) );
// if (excludeConnect()) connect(Kopete::OnlineStatus::Online); // ??
}
Index: winpopup-install
===================================================================
--- winpopup-install (revision 1007087)
+++ winpopup-install (working copy)
@@ -1,14 +1,37 @@
#!/bin/bash
+PATH=/bin:/usr/bin/:/usr/local/bin
-PATH=/bin:/usr/bin
+# Check if first parameter script winpopup-send with path
+if [ -f "$1" ]; then
+ #Get winpopup-send from param
+ WPSEND=$1
+else
+ #Try find winpopup-send in $PATH
+ WPSEND=`which winpopup-send`
+fi
+# Check if winpopup-send exist
+if [ "$WPSEND" == "" ] || [ ! -f "$WPSEND" ]; then
+ echo "Cant find script winpopup-send"
+ echo "Run: $0 <script winpopup-send with path>"
+ exit 1
+fi
+
# Grab the full path to the smb.conf file
i=`find /etc -name smb.conf`
-# Create new smb.conf file with updated message command line
+# Check if smb.conf exist
+if [ ! -f "$i" ]; then
+ echo "Samba configuration file smb.conf doesnt exist in /etc"
+ exit 1
+fi
+
+# Create new smb.conf file with updated message command line and security section
+# If security isnt share, smbclient doesnt get SERVER and WORKGROUP for browsing \
network echo "[global]" > ~/smb.conf.new
-echo " message command = $1 %s %m %t &" >> ~/smb.conf.new
-cat $i | grep -v "message command = " | grep -v "\[global\]" >> ~/smb.conf.new
+echo " message command = $WPSEND %s %m %t &" >> ~/smb.conf.new
+echo " security = share" ~/smb.conf.new
+cat $i | grep -v "message command = " | grep -v "\[global\]" | grep -v "security = " \
>> ~/smb.conf.new
# Backup the old file
mv -f $i "$i.old"
Property changes on: winpopup-install
___________________________________________________________________
Added: svn:mergeinfo
Index: wpuserinfo.h
===================================================================
--- wpuserinfo.h (revision 1019807)
+++ wpuserinfo.h (working copy)
@@ -51,6 +51,7 @@
QString Comment, Workgroup, OS, Software;
QProcess *detailsProcess;
+ bool noComment;
};
#endif
Index: wpeditaccount.cpp
===================================================================
--- wpeditaccount.cpp (revision 1019807)
+++ wpeditaccount.cpp (working copy)
@@ -86,6 +86,8 @@
mSmbcPath->setUrl(tmpSmbcPath);
}
+ connect ( doInstallSamba, SIGNAL(clicked()), this, SLOT(installSamba()) );
+
show();
}
Index: winpopup-install.sh
===================================================================
--- winpopup-install.sh (revision 1019807)
+++ winpopup-install.sh (working copy)
@@ -1,37 +0,0 @@
-#!/bin/bash
-
-PATH=/bin:/usr/bin
-
-# Grab the full path to the smb.conf file
-i=`find /etc -name smb.conf`
-
-# Create new smb.conf file with updated message command line
-echo "[global]" > ~/smb.conf.new
-echo " message command = $1 %s %m %t &" >> ~/smb.conf.new
-cat $i | grep -v "message command = " | grep -v "\[global\]" >> ~/smb.conf.new
-
-# Backup the old file
-mv -f $i "$i.old"
-
-# Move new file into place and reset permissions
-mv -f ~/smb.conf.new $i
-chown root:root $i
-chmod 644 $i
-
-# Create a winpopup directory somewhere "safe"
-#rm -rf /var/lib/winpopup --- a bit strong?
-if [ ! -d /var/lib/winpopup ]; then
- mkdir -p /var/lib/winpopup
-fi
-
-chmod 0777 /var/lib/winpopup
-
-# This is to help if somebody grades up from the old behavior
-if [ -n "`ls -A /var/lib/winpopup/`" ]; then
- chmod 666 /var/lib/winpopup/*
-fi
-
-rm -f /var/lib/winpopup/message
-
-# Force Samba to reread configuration
-killall -HUP smbd
Index: libwinpopup/libwinpopup.cpp
===================================================================
--- libwinpopup/libwinpopup.cpp (revision 1019807)
+++ libwinpopup/libwinpopup.cpp (working copy)
@@ -30,6 +30,7 @@
#include <KLocale>
#include <KDirLister>
#include <KToolInvocation>
+#include <kdefakes.h> // gethostname
// Kopete Includes
#include "kopeteuiglobal.h"
@@ -161,7 +162,7 @@
// for Samba 3
readGroupsProcess = new QProcess;
QStringList args;
- args << "-N" << "-g" << "-L" << Host;
+ args << "-N" << "-g" << "-L" << Host << "-I" << Host;
connect(readGroupsProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, \
SLOT(slotReadProcessExited(int, QProcess::ExitStatus)));
@@ -179,7 +180,7 @@
if (!outputData.isEmpty()) {
QString outputString = QString::fromUtf8(outputData.data());
QStringList outputList = outputString.split('\n');
- QRegExp group("Workgroup\\|(.[^\\|]+)\\|(.+)"), \
host("Server\\|(.[^\\|]+)\\|(.+)"), + QRegExp \
group("Workgroup\\|(.[^\\|]+)\\|(.+)"), \
host("Server\\|(.[^\\|]+)\\|(.*)"),
info("Domain=\\[([^\\]]+)\\] OS=\\[([^\\]]+)\\] Server=\\[([^\\]]+)\\]"),
error("Connection.*failed");
foreach (QString line, outputList) {
@@ -222,6 +223,29 @@
} else {
passedInitialHost = true;
+ if ( currentGroups.isEmpty() && currentHost.toUpper() == "LOCALHOST" ) {
+ kDebug(14170) << "Cant get workgroup for localhost";
+ //Samba on localhost in up but doesnt receive workgroups or security in smb.conf \
in not share + //Sometimes samba recive workgroups in 2min.
+ //TODO: Fix it better
+
+ //try get host name
+ QString theHostName;
+ char *tmp = new char[255];
+
+ if (tmp != 0) {
+ gethostname(tmp, 255);
+ theHostName = tmp;
+ if (theHostName.contains('.') != 0) \
theHostName.remove(theHostName.indexOf('.'), theHostName.length()); + theHostName \
= theHostName.toUpper(); + }
+
+ if ( theHostName.isEmpty() )
+ theHostName = "LOCALHOST";
+
+ //add localhost to currentGroups with unknow workgroup
+ currentGroups["WORKGROUP"] = theHostName;
+ }
if (!currentGroups.isEmpty()) {
foreach (QString groupMaster, currentGroups) {
todo += groupMaster;
@@ -232,6 +256,8 @@
i18n("Connection to localhost failed.\n"
"Is your samba server running?"),
QString::fromLatin1("Winpopup"));
+ else
+ kDebug(14170) << "Unknow error";
}
}
}
@@ -322,10 +348,13 @@
{
QProcess *sender = new QProcess(this);
QStringList args;
- args << "-M" << Destination << "-N";
+ args << "-M" << Destination << "-N" << "-I" << Destination;
sender->start(smbClientBin, args);
- sender->write(Body.trimmed().toLocal8Bit());
+ sender->waitForStarted();
+ //TODO: check if we can write message
+ sender->write(Body.toLocal8Bit());
sender->closeWriteChannel();
+ connect(sender, SIGNAL(finished(int, QProcess::ExitStatus)), sender, \
SLOT(deleteLater())); }
void WinPopupLib::settingsChanged(const QString &smbClient, int groupFreq)
Index: winpopup-send
===================================================================
--- winpopup-send (revision 1007087)
+++ winpopup-send (working copy)
@@ -19,7 +19,7 @@
if [ "$2" != "$THIS_SERVER" ]; then
echo -e "Kopete is currently not running.\nYour message was not delivered!" \
\
- | smbclient -N -M $2
+ | smbclient -N -M $2 -I $2
fi
else
Property changes on: winpopup-send
___________________________________________________________________
Added: svn:mergeinfo
Index: ui/wpeditaccountbase.ui
===================================================================
--- ui/wpeditaccountbase.ui (revision 1019807)
+++ ui/wpeditaccountbase.ui (working copy)
@@ -94,6 +94,9 @@
<property name="whatsThis" >
<string>Install support into Samba to enable this service.</string>
</property>
+ <property name="text" >
+ <string>I&nstall Into Samba</string>
+ </property>
</widget>
</item>
</layout>
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (revision 1019807)
+++ CMakeLists.txt (working copy)
@@ -45,7 +45,7 @@
########### install files ###############
install( FILES kopete_wp.desktop DESTINATION ${SERVICES_INSTALL_DIR})
-install(PROGRAMS winpopup-send.sh winpopup-install.sh DESTINATION \
${BIN_INSTALL_DIR}) +install(PROGRAMS winpopup-send winpopup-install DESTINATION \
${BIN_INSTALL_DIR})
["signature.asc" (application/pgp-signature)]
_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic