Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim-plugins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeniy Popov <evgeniypopov@gmail.com>2013-05-17 21:03:44 +0400
committerEvgeniy Popov <evgeniypopov@gmail.com>2013-05-17 21:03:44 +0400
commit6956c904545b44d8a49b3e5c11a18075d057ef91 (patch)
tree8481fde99dbcb650a29cc98f9516ec572ecca0ef
parent8fc656a145556d14da3c341776112e74b95c2eb1 (diff)
BirthdayReminderPlugin. new version
-rw-r--r--birthday_reminder/birthday_reminder_large.pngbin0 -> 6998 bytes
-rw-r--r--birthday_reminder/manifest.ini6
-rw-r--r--birthday_reminder/plugin.py55
3 files changed, 47 insertions, 14 deletions
diff --git a/birthday_reminder/birthday_reminder_large.png b/birthday_reminder/birthday_reminder_large.png
new file mode 100644
index 0000000..d150022
--- /dev/null
+++ b/birthday_reminder/birthday_reminder_large.png
Binary files differ
diff --git a/birthday_reminder/manifest.ini b/birthday_reminder/manifest.ini
index fa523ea..22fd658 100644
--- a/birthday_reminder/manifest.ini
+++ b/birthday_reminder/manifest.ini
@@ -1,7 +1,7 @@
[info]
name: Birthday reminder
short_name: birthday_reminder
-version: 0.0.2
-description: Birthday reminder plugin
+version: 0.0.3
+description: Birthday reminder plugin. Reminder before 5,3,1 and birthday days.
authors: Evgeniy Popov <evgeniypopov@gmail.com>
-homepage: https://bitbucket.org/axce1/bday
+homepage: http://trac-plugins.gajim.org/wiki/BirthdayReminderPlugin
diff --git a/birthday_reminder/plugin.py b/birthday_reminder/plugin.py
index 6476685..dc3c1c3 100644
--- a/birthday_reminder/plugin.py
+++ b/birthday_reminder/plugin.py
@@ -9,6 +9,8 @@ from plugins.helpers import log_calls
from notify import popup
from common import configpaths
+from common import gajim
+from common import ged
class BirthDayPlugin(GajimPlugin):
@@ -18,12 +20,31 @@ class BirthDayPlugin(GajimPlugin):
self.config_dialog = None
self.description = ('Birthday reminder plugin')
+ self.events_handlers = {
+ 'roster-received': (ged.GUI2, self.roster_received)}
configpath = configpaths.ConfigPaths()
cache_path = configpath.cache_root
self.vcard_path = os.path.join(cache_path, 'vcards') + os.sep
self.timeout_id = 0
-
- def check_birthdays(self):
+ self.showed_accounts = []
+
+ def check_birthdays(self, account=None):
+ def show_popup(account, jid):
+ contact_instances = gajim.contacts.get_contacts(account, jid)
+ contact = gajim.contacts.get_highest_prio_contact_from_contacts(
+ contact_instances)
+ if contact:
+ nick = gobject.markup_escape_text(contact.get_shown_name())
+ try:
+ image = os.path.dirname(__file__) + os.sep + \
+ 'birthday_reminder_large.png'
+ except:
+ image = None
+
+ popup('Send message', contact.jid, account, msg_type='', \
+ path_to_image=image, title=title, text=text + ' ' + nick)
+
+ accounts = gajim.contacts.get_accounts()
vcards = []
date_dict = {}
for jid in glob.glob(self.vcard_path + '*@*'):
@@ -39,8 +60,8 @@ class BirthDayPlugin(GajimPlugin):
name = xml.getElementsByTagName('BDAY')
for node in name:
try:
- data = node.childNodes[0].nodeValue
- date_dict[xmldoc[len(self.vcard_path):]] = data
+ data = node.childNodes[0].nodeValue
+ date_dict[xmldoc[len(self.vcard_path):][:-1]] = data
except:
pass
@@ -64,20 +85,25 @@ class BirthDayPlugin(GajimPlugin):
if time_to_bday.days > 5:
continue
if time_to_bday.days == 5:
- text = "5 days before BDay %s" % key
+ text = "5 days before BDay"
elif time_to_bday.days == 3:
- text = "3 days before BDay %s" % key
+ text = "3 days before BDay"
elif time_to_bday.days == 1:
- text = "Tommorrow BDay %s" % key
+ text = "Tomorrow BDay"
elif time_to_bday.days == 0:
- text = "Today BDay %s" % key
- if text:
- popup('', key, key, title=title, text=text)
+ text = "Today BDay"
+ if not text:
+ continue
+ if account:
+ show_popup(account,key)
+ else:
+ for acct in accounts:
+ show_popup(account, key)
return True
@log_calls('BirthDayPlugin')
def activate(self):
- self.check_birthdays()
+ #self.check_birthdays()
self.timeout_id = gobject.timeout_add_seconds(24*3600,
self.check_birthdays)
@@ -86,3 +112,10 @@ class BirthDayPlugin(GajimPlugin):
if self.timeout_id > 0:
gobject.source_remove(self.timeout_id)
+
+ @log_calls('BirthDayPlugin')
+ def roster_received(self, obj):
+ if obj.conn.name not in self.showed_accounts:
+ self.check_birthdays(obj.conn.name)
+ self.showed_accounts.append(obj.conn.name)
+