This commit is contained in:
parent
a44d1e61b7
commit
a8f1be436e
2 changed files with 126 additions and 110 deletions
|
@ -18,6 +18,9 @@ class Account:
|
||||||
self._transport2proto={}
|
self._transport2proto={}
|
||||||
self._cnx=None
|
self._cnx=None
|
||||||
|
|
||||||
|
def getDesc(self):
|
||||||
|
return (self._hlogin + "@" + self._host)
|
||||||
|
|
||||||
def setHost(self,hostName):
|
def setHost(self,hostName):
|
||||||
self._host=hostName
|
self._host=hostName
|
||||||
|
|
||||||
|
|
27
start.py
27
start.py
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# vim: set sw=4 ts=4 si et:
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
@ -25,7 +26,8 @@ class Answer:
|
||||||
while not self._answer:
|
while not self._answer:
|
||||||
sys.stderr.write(question)
|
sys.stderr.write(question)
|
||||||
tmp_ans = raw_input()
|
tmp_ans = raw_input()
|
||||||
if tmp_ans in (answerlist): self._answer=tmp_ans
|
if tmp_ans in (answerlist):
|
||||||
|
self._answer = tmp_ans
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
return self._answer;
|
return self._answer;
|
||||||
|
@ -43,15 +45,20 @@ class JabSync:
|
||||||
|
|
||||||
def parseCmdLine(self):
|
def parseCmdLine(self):
|
||||||
parser = OptionParser()
|
parser = OptionParser()
|
||||||
parser.add_option("-c","--config",\
|
parser.add_option(\
|
||||||
action="store", type="string", dest="filename",\
|
"-c","--config",\
|
||||||
help="Use file a configuration file",metavar="config")
|
action="store", \
|
||||||
|
type="string", \
|
||||||
|
dest="filename",\
|
||||||
|
help="Use file a configuration file",\
|
||||||
|
metavar="config")
|
||||||
(options,args)=parser.parse_args()
|
(options,args)=parser.parse_args()
|
||||||
if options.filename:
|
if options.filename:
|
||||||
self._configFile=options.filename
|
self._configFile=options.filename
|
||||||
else:
|
else:
|
||||||
self._configFile=os.path.join(os.path.expanduser("~"),".jabsync")
|
self._configFile=os.path.join(os.path.expanduser("~"),".jabsync")
|
||||||
print "Configuration file: " + self._configFile
|
print "Configuration file: " + self._configFile
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
self._config = Config()
|
self._config = Config()
|
||||||
self._config.loadFromFile(self._configFile)
|
self._config.loadFromFile(self._configFile)
|
||||||
|
@ -101,22 +108,28 @@ class JabSync:
|
||||||
" [y]ahoo"+\
|
" [y]ahoo"+\
|
||||||
" [-] Forget JIDs using this host",\
|
" [-] Forget JIDs using this host",\
|
||||||
what_tp_ans.keys())
|
what_tp_ans.keys())
|
||||||
trans_proto=what_tp_ans[what_transport]
|
trans_proto = what_tp_ans[what_transport.get()]
|
||||||
|
print "Selected : " + trans_proto
|
||||||
if trans_proto == "forget":
|
if trans_proto == "forget":
|
||||||
# TODO: ajouter regles d'exclusion
|
# TODO: ajouter regles d'exclusion
|
||||||
zero = 0
|
zero = 0
|
||||||
else:
|
else:
|
||||||
# TODO: ajouter transport a la config XML
|
# TODO: ajouter transport a la config XML
|
||||||
|
self._commonTransports[hostName] = trans_proto
|
||||||
zero = 0
|
zero = 0
|
||||||
return self.giveTransport(hostName)
|
return self.giveTransport(hostName)
|
||||||
|
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
|
print "jabsync::get\n"
|
||||||
#get Roster
|
#get Roster
|
||||||
for account in self._accountList:
|
for account in self._accountList:
|
||||||
roster = account.getRoster()
|
roster = account.getRoster()
|
||||||
# fusionner les roster
|
# fusionner les roster
|
||||||
jid_list = roster.getJIDs()
|
jid_list = roster.getJIDs()
|
||||||
for jid in jid_list:
|
for jid in jid_list:
|
||||||
|
print "Getting... "
|
||||||
|
print jid
|
||||||
transport = jid.getDomain()
|
transport = jid.getDomain()
|
||||||
trans_proto = self.giveTransport(transport)
|
trans_proto = self.giveTransport(transport)
|
||||||
if not self._commonJIDs.has_key(trans_proto):
|
if not self._commonJIDs.has_key(trans_proto):
|
||||||
|
@ -125,8 +138,8 @@ class JabSync:
|
||||||
jid_groups = roster.getGroups(jid)
|
jid_groups = roster.getGroups(jid)
|
||||||
if not jid_name: jid_name = jid.getNode()
|
if not jid_name: jid_name = jid.getNode()
|
||||||
if not self._commonJIDs[trans_proto].has_key(jid.getNode()):
|
if not self._commonJIDs[trans_proto].has_key(jid.getNode()):
|
||||||
self._commonJIDs[trans_proto][jid.getNode()]=(jid_name,jid_groups)
|
self._commonJIDs[trans_proto][jid.getNode()] = \
|
||||||
# print " <- "+jid.getNode()+" @ "+trans_proto+" = "+jid_name
|
(jid_name,jid_groups)
|
||||||
print "\x1B[G <- "+jid.getNode()+" @ "+trans_proto+" = "+jid_name
|
print "\x1B[G <- "+jid.getNode()+" @ "+trans_proto+" = "+jid_name
|
||||||
|
|
||||||
#upload rosters
|
#upload rosters
|
||||||
|
|
Loading…
Reference in a new issue