Beispiel #1
0
 def setup(self):
     st = self.settings
     st.beginGroup("url")
     for service in map(unicode, st.allKeys()):
         self.urls[service] = unicode(st.value(service).toString())
     st.endGroup()
     st.beginGroup("service")
     for service in map(unicode, st.allKeys()):
         self.services[service] = unicode(st.value(service).toString())
     st.endGroup()
     st.beginGroup("account")
     for key in map(unicode, st.allKeys()):
         service = unicode(st.value(key).toString())
         self.accounts[key] = drug(
             service = service,
             name = key.partition("/")[2],
             type = self.services[service],
             url = self.urls[service])
     st.endGroup()
     for key, account in self.accounts.items():
         self._accounts.append(key)
         self.add_account_to_list(account)
         self.accounts[key] = account = Account(account)
         add_service(account.service,
             {'api':account.api, 'search':account.search})
Beispiel #2
0
 def addAccount(self):
     pref = self.app.preferences.ui
     if pref.addaccountButton.text() == "wait":
         return # already adding an account
     if pref.accountidEdit.text() == "":
         return # is empty
     index = pref.accountserviceComboBox.currentIndex()
     if index == 0 and pref.accounturlEdit.text() == "":
         return # is empty too
     account = drug(service = services[index].name,
                    name = unicode(pref.accountidEdit.text()),
                    type = services[index].type,
                    url = services[index].url)
     if account.url is None:
         url = unicode(pref.accounturlEdit.text())
         if url.endswith("/"):
             url = url[:-1]
         if not "://" in url:
             url = u"http://" + url
         account.url = url
     if account.service is None:
         s = account.url.partition("//")[2].partition("/")[0].split(".")
         account.service = s[-2] + s[-1]
     # save new account
     pref.addaccountButton.setText("wait")
     st = self.settings
     key = u"account/{0}/{1}".format(account.service, account.name)
     if st.contains(key):
         return # allready existing -> skip
     st.setValue(key, account.service)
     key = u"service/" + account.service
     if not st.contains(key):
         st.setValue(key, account.type)
         st.setValue(u"url/" + account.service, account.url)
         self.urls[account.service] = account.url
     pref.accountsTabWidget.setCurrentIndex(0)
     self.add_account_to_list(account)
     key = u"{0}/{1}".format(account.service, account.name)
     self._accounts.append(key)
     self.accounts[key] = account = Account(account)
     # create timer events for new account
     self.app.updates.add_timer("friends", account.service, account.name, "")
     self.app.updates.add_timer(
         "user", account.service, account.name, account.name)
     if account.groups is not None:
         self.app.updates.add_timer("groups",account.service,account.name,"")
     # install service
     if account.service not in self.services:
         self.services[account.service] = account.type
         add_service(account.service,
             {'api':account.api, 'search':account.search})
     pref.addaccountButton.setText("add")