soc.2009.transport: 013cb823: Testing pyicqt2spectrum script
hanzz at soc.pidgin.im
hanzz at soc.pidgin.im
Sun Aug 2 11:10:36 EDT 2009
-----------------------------------------------------------------
Revision: 013cb823a9c5af21d70e4a99ed2cf52408adc708
Ancestor: d2b64773677e9e16b07c4899e59dfbb3afba4d29
Author: hanzz at soc.pidgin.im
Date: 2009-08-02T15:05:21
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/013cb823a9c5af21d70e4a99ed2cf52408adc708
Added files:
tools/pyicqt2spectrum.py
Added directories:
tools
Modified files:
filetransfermanager.cpp main.cpp
ChangeLog:
Testing pyicqt2spectrum script
-------------- next part --------------
============================================================
--- tools/pyicqt2spectrum.py 63819d671518b6c6022ea08158abec99cd4706d7
+++ tools/pyicqt2spectrum.py 63819d671518b6c6022ea08158abec99cd4706d7
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+import os, os.path, sys
+try:
+ from twisted.web import microdom as dom
+ from twisted.web.domhelpers import *
+ from twisted.internet import defer, utils
+ from twisted.enterprise import adbapi, util as dbutil
+ from twisted.words.protocols.jabber import jid
+ from twisted.enterprise import util
+except:
+ print "python-twisted is not installed"
+
+s = util.safe
+from twisted.internet import reactor
+
+def start():
+ if len(sys.argv) != 6 and len(sys.argv) != 7:
+ print sys.argv[0] + " pyicqt_directory database username password host [mysql_prefix]"
+ reactor.stop()
+ return
+ maindir = sys.argv[1]
+
+ prefix = ""
+ if len(sys.argv) == 7:
+ prefix = sys.argv[6]
+ dict = {}
+ db = adbapi.ConnectionPool('MySQLdb', db = sys.argv[2], user = sys.argv[3], passwd = sys.argv[4], host = sys.argv[5], cp_min=1, cp_max=1)
+ c = 0
+ for dr in os.listdir(maindir):
+ if os.path.isdir(maindir+dr):
+ for dr2 in os.listdir(maindir+dr):
+ for f in os.listdir(maindir+dr+'/'+dr2):
+ if os.path.isfile(maindir+dr+'/'+dr2+'/'+f):
+ fp = open(maindir+dr+'/'+dr2+'/'+f, 'r')
+ c += 1
+ print c
+ buff = fp.read()
+ fp.close()
+ try:
+ x = dom.parseXMLString(buff)
+ except:
+ continue
+ jid = f.replace('%','@')[:-4]
+ p = x.getElementsByTagName('password')
+ if len(p) != 1:
+ continue
+ password = gatherTextNodes(p[0])
+ u = x.getElementsByTagName('username')
+ uin = gatherTextNodes(u[0])
+ print jid
+ db.runQuery('insert ignore into ' + prefix + 'users (jid, uin, password) values ("%s", "%s", "%s")'%(s(jid), s(uin),s(password))).addCallback(done)
+ items = x.getElementsByTagName('item')
+ for j in items:
+ db.runQuery('insert ignore into ' + prefix + 'rosters (uin, jid) values ("%s", "%s")'%(s(j.getAttribute('jid')), s(jid))).addCallback(done)
+
+def done(res):
+ print '..done'
+
+reactor.callWhenRunning(start)
+reactor.run()
\ No newline at end of file
============================================================
--- filetransfermanager.cpp a3f3202d37b92ed1316c84d9f0a1eb9cf620bb57
+++ filetransfermanager.cpp 00108c3ba1f04299f8c8e062c34450aed8d77f54
@@ -30,7 +30,17 @@ void FileTransferManager::handleFTReques
std::cout << "Received file transfer request from " << from.full() << " " << to.full() << " " << sid << ".\n";
m_info[sid].filename = name;
m_info[sid].size = size;
- m_sip->acceptFT(from, sid, SIProfileFT::FTTypeS5B, to);
+ void serv_send_file(PurpleConnection *gc, const char *who, const char *file)
+
+ User *user = p->userManager()->getUserByJID(from.username());
+ if (user) {
+ if (user->account()){
+ if (user->isConnected()){
+ Log().Get(user->jid()) << "sending file";
+ serv_send_file(purple_account_get_connection(user->account()),to.username().c_str(), name.c_str());
+ }
+ }
+ }
}
============================================================
--- main.cpp bd468d3c1f1f34b2ca8d638f431dcd1a8f25c3c5
+++ main.cpp 1e7500d8b7ca002b844e75e708c23e8e1d536ef8
@@ -382,6 +382,20 @@ static void * notifyMessage(PurpleNotify
return NULL;
}
+static size_t ui_read_fnc(guchar *buffer, size_t size, PurpleXfer *xfer) {
+ return size;
+}
+
+static void XferCreated(PurpleXfer *xfer) {
+ purple_xfer_set_ui_read_fnc(xfer, ui_read_fnc);
+// xfer->ui_data = new
+}
+
+static void fileSendStart(PurpleXfer *xfer) {
+// GlooxMessageHandler::instance()->ft->acceptFT(from, sid, SIProfileFT::FTTypeS5B, to);
+}
+
+
static void buddyListAddBuddy(PurpleAccount *account, const char *username, const char *group, const char *alias){
std::cout << "BUDDY LIST ADD BUDDY REQUEST\n";
}
@@ -455,11 +469,11 @@ static PurpleXferUiOps xferUiOps =
static PurpleXferUiOps xferUiOps =
{
+ XferCreated,
NULL,
NULL,
NULL,
NULL,
- NULL,
NULL
};
@@ -1465,6 +1479,7 @@ bool GlooxMessageHandler::initPurple(){
purple_signal_connect(purple_conversations_get_handle(), "received-im-msg", &conversation_handle, PURPLE_CALLBACK(newMessageReceived), NULL);
purple_signal_connect(purple_conversations_get_handle(), "buddy-typing", &conversation_handle, PURPLE_CALLBACK(buddyTyping), NULL);
purple_signal_connect(purple_conversations_get_handle(), "buddy-typing-stopped", &conversation_handle, PURPLE_CALLBACK(buddyTypingStopped), NULL);
+ purple_signal_connect(purple_xfers_get_handle(), "file-send-start", &xfer_handle, PURPLE_CALLBACK(fileSendStart), NULL);
purple_signal_connect(purple_xfers_get_handle(), "file-recv-request", &xfer_handle, PURPLE_CALLBACK(newXfer), NULL);
purple_signal_connect(purple_xfers_get_handle(), "file-recv-complete", &xfer_handle, PURPLE_CALLBACK(XferComplete), NULL);
purple_signal_connect(purple_connections_get_handle(), "signed-on", &conn_handle,PURPLE_CALLBACK(signed_on), NULL);
More information about the Commits
mailing list