From 91d79ee851be9fd141b25d0c6abaa512eef85124 Mon Sep 17 00:00:00 2001 From: Philipp Schmidt Date: Tue, 19 Jul 2011 03:18:25 +0200 Subject: [PATCH 01/10] Buddylist showing also the own online status of any account --- plugin/vimchat.vim | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugin/vimchat.vim b/plugin/vimchat.vim index 290192c..64f4aef 100644 --- a/plugin/vimchat.vim +++ b/plugin/vimchat.vim @@ -1096,7 +1096,14 @@ You can type \on to reconnect. ****************************** """ % (curJid)) continue - accountText = u"{{{ [+] %s\n"%(curJid) + accountPresenceInfo = account.jabberGetPresence() + if accountPresenceInfo[0] != None: + status = str(accountPresenceInfo[1]) + if status == "None": + status = '' + accountText = u"{{{ [+] %s\n\t%s: %s\n"%(curJid,str(accountPresenceInfo[0]),status) + else: + accountText = u"{{{ [+] %s\n"%(curJid) rF.write(accountText) roster = account._roster @@ -1125,7 +1132,7 @@ You can type \on to reconnect. if show != u'off': buddyText =\ - u"{{{ (%s) %s\n\t%s \n\tGroups: %s\n\t%s:\n%s\n}}}\n" %\ + u"{{{ (%s) %s\n\t%s \n\tGroups: %s\n\t%s: %s\n}}}\n" %\ (show, name, item, groups, show, status) rF.write(buddyText) From cad516d4e45eecc940548999d859a4c57ec38117 Mon Sep 17 00:00:00 2001 From: Philipp Schmidt Date: Tue, 19 Jul 2011 03:29:24 +0200 Subject: [PATCH 02/10] This commit resolves a gvim SEGV on my machine. This is a fix that needs to be tested on other machines and we need to understand the main cause why those imports are not allowed in gvim --- plugin/vimchat.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/vimchat.vim b/plugin/vimchat.vim index 64f4aef..54af1da 100644 --- a/plugin/vimchat.vim +++ b/plugin/vimchat.vim @@ -50,7 +50,7 @@ except: pynotify_enabled = False try: - if 'DBUS_SESSION_BUS_ADDRESS' in os.environ: + if 'DBUS_SESSION_BUS_ADDRESS' in os.environ and int(vim.eval("has('gui_running')"))==0: import pynotify pynotify_enabled = True else: @@ -69,7 +69,7 @@ except: pyotr_logging = False gtk_enabled = False -if 'DISPLAY' in os.environ: +if 'DISPLAY' in os.environ and int(vim.eval("has('gui_running')"))==0: try: from gtk import StatusIcon import gtk From 1cfb17431d049b8e72a8f6e91269faedc66f7a7e Mon Sep 17 00:00:00 2001 From: Philipp Schmidt Date: Sun, 24 Jul 2011 15:53:44 +0200 Subject: [PATCH 03/10] Restore the show status of the last use of VimChat. This will be written in the config file (eventually comments are deleted) --- README.md | 1 + plugin/vimchat.vim | 39 ++++++++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 770e1b7..3ac29e8 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ __Optional ~/.vimrc Variables:__ * let g:vimchat\_buddylistmaxwidth = max width of buddy list window, default '' * let g:vimchat\_timestampformat = format of the message timestamp, default "[%H:%M]" * let g:vimchat\_showPresenceNotification = notification if buddy changed status, comma-separated list of states, default "" +* let g:vimchat\_restoreSessionStatus = (0 or 1), default is 0 # Contributors diff --git a/plugin/vimchat.vim b/plugin/vimchat.vim index 54af1da..372a1ff 100644 --- a/plugin/vimchat.vim +++ b/plugin/vimchat.vim @@ -29,6 +29,7 @@ " g:vimchat_buddylistmaxwidth = max width of buddy list window default '' " g:vimchat_timestampformat = format of the message timestamp default "[%H:%M]" " g:vimchat_showPresenceNotification = notify if buddy changed status default "" +" g:vimchat_restoreSessionStatus = (0 or 1) default is 0 python <") while(size > 0): account = accounts.keys()[0] self._signOff(account) @@ -914,6 +932,15 @@ class VimChatScope: accounts = self.accounts if account in accounts: try: + # Save the status of this account to the config file + if self.sessionStatusRestore==1: + [show,status] = accounts[account].jabberGetPresence() + priority = accounts[account]._presence.getPriority() + if not show: show='' + if not status: status='' + if not priority: priority='' + self.setLastStatus(account,str(show),str(status),str(priority)) + # disconnect and stop accounts[account].disconnect() accounts[account].stop() del accounts[account] @@ -1819,7 +1846,9 @@ fu! VimChatCheckVars() if !exists('g:vimchat_showPresenceNotification') let g:vimchat_showPresenceNotification="" endif - + if !exists('g:vimchat_restoreSessionStatus') + let g:vimchat_restoreSessionStatus=0 + endif return 1 endfu "}}} From 4dff13e8bb940031a0ce3c9d2250895ab2a0186e Mon Sep 17 00:00:00 2001 From: Philipp Schmidt Date: Sun, 24 Jul 2011 17:41:19 +0200 Subject: [PATCH 04/10] Restore the show status of the last use of VimChat. This will be written in the config file (eventually comments are deleted) --- plugin/vimchat.vim | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/plugin/vimchat.vim b/plugin/vimchat.vim index 372a1ff..5a529ec 100644 --- a/plugin/vimchat.vim +++ b/plugin/vimchat.vim @@ -826,6 +826,37 @@ class VimChatScope: return dict.__getitem__(self, key) #}}} #}}} + #RESET STATUS FUNCTIONS + #{{{ getLastStatus + def getLastStatus(self,account=None): + if not os.path.exists(self.configFilePath): + return # Config file does not exist + status="" + config = RawConfigParser(); + config.read(self.configFilePath) + if config.has_section('last_status'): + for acc in config.options('last_status'): + if account == None or account == acc: + status = config.get('last_status', acc) + break + return status + #}}} + #{{{ setLastStatus + def setLastStatus(self,account,show="",status="",priority=""): + if not os.path.exists(self.configFilePath): + return # Config file does not exist + if account == None: + return + status=show+","+status+","+priority + config.read(self.configFilePath) + config.read(self.configFilePath) + if not config.has_section('last_status'): + config.add_section('last_status') + config.set('last_status', account, str(status)) + # Does not preserve comments + with open(self.configFilePath,'wb') as configfile: + config.write(configfile) + #}}} #CONNECTION FUNCTIONS #{{{ signOn def signOn(self): @@ -953,7 +984,7 @@ class VimChatScope: else: print 'Error: [%s] is an invalid account.' % (account) if self.growl_enabled: - self.growl_notifier.notify ("account status", "VimChat", "Error signing off %s VimChat" %(account), self.growl_icon) + self.growl_notifier.notify ("account status", "VimChat", "Error signing off %s VimChat" %(account), self.growl_icon) #}}} #{{{ showStatus def showStatus(self): From fc3e7c5db7a881a1ae0346e3c7ba1a6b35068445 Mon Sep 17 00:00:00 2001 From: Philipp Schmidt Date: Sun, 24 Jul 2011 20:40:52 +0200 Subject: [PATCH 05/10] Restore the show status of the last use of VimChat. This will be written in the config file (eventually comments are deleted) --- plugin/vimchat.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/vimchat.vim b/plugin/vimchat.vim index 5a529ec..476a985 100644 --- a/plugin/vimchat.vim +++ b/plugin/vimchat.vim @@ -848,6 +848,7 @@ class VimChatScope: if account == None: return status=show+","+status+","+priority + config = RawConfigParser(); config.read(self.configFilePath) config.read(self.configFilePath) if not config.has_section('last_status'): From 1fbdd699acf17cffc4f9f9bd386f79f8f7d6adc2 Mon Sep 17 00:00:00 2001 From: Philipp Schmidt Date: Thu, 4 Aug 2011 00:31:20 +0200 Subject: [PATCH 06/10] Update to master --- plugin/vimchat.vim | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/plugin/vimchat.vim b/plugin/vimchat.vim index 28a9403..077ae96 100644 --- a/plugin/vimchat.vim +++ b/plugin/vimchat.vim @@ -51,7 +51,7 @@ except: pynotify_enabled = False try: - if 'DBUS_SESSION_BUS_ADDRESS' in os.environ and int(vim.eval("has('gui_running')"))==0: + if 'DBUS_SESSION_BUS_ADDRESS' in os.environ: import pynotify pynotify_enabled = True else: @@ -70,7 +70,7 @@ except: pyotr_logging = False gtk_enabled = False -if 'DISPLAY' in os.environ and int(vim.eval("has('gui_running')"))==0: +if 'DISPLAY' in os.environ: try: from gtk import StatusIcon import gtk @@ -1091,14 +1091,7 @@ You can type \on to reconnect. ****************************** """ % (curJid)) continue - accountPresenceInfo = account.jabberGetPresence() - if accountPresenceInfo[0] != None: - status = str(accountPresenceInfo[1]) - if status == "None": - status = '' - accountText = u"{{{ [+] %s\n\t%s: %s\n"%(curJid,str(accountPresenceInfo[0]),status) - else: - accountText = u"{{{ [+] %s\n"%(curJid) + accountText = u"{{{ [+] %s\n"%(curJid) rF.write(accountText) roster = account._roster @@ -1127,7 +1120,7 @@ You can type \on to reconnect. if show != u'off': buddyText =\ - u"{{{ (%s) %s\n\t%s \n\tGroups: %s\n\t%s: %s\n}}}\n" %\ + u"{{{ (%s) %s\n\t%s \n\tGroups: %s\n\t%s:\n%s\n}}}\n" %\ (show, name, item, groups, show, status) rF.write(buddyText) From 3c3c2e4831ae93e9d0372a70a2bffa517002f28b Mon Sep 17 00:00:00 2001 From: Philipp Schmidt Date: Thu, 4 Aug 2011 02:59:26 +0200 Subject: [PATCH 07/10] Restore the show status of the last use of VimChat. This will be written in the config file (eventually comments are deleted) --- README.md | 1 + plugin/vimchat.vim | 63 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0560de4..90267fa 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ __Optional ~/.vimrc Variables:__ * let g:vimchat\_buddylistmaxwidth = max width of buddy list window, default '' * let g:vimchat\_timestampformat = format of the message timestamp, default "[%H:%M]" * let g:vimchat\_showPresenceNotification = notification if buddy changed status, comma-separated list of states, default "" +* let g:vimchat\_restoreSessionStatus = (0 or 1), default is 0 # Hacking diff --git a/plugin/vimchat.vim b/plugin/vimchat.vim index 4ab3c36..e41c8be 100644 --- a/plugin/vimchat.vim +++ b/plugin/vimchat.vim @@ -30,6 +30,7 @@ " g:vimchat_timestampformat = format of the msg timestamp default "[%H:%M]" " g:vimchat_showPresenceNotification = " notify if buddy changed status default "" +" g:vimchat_restoreSessionStatus = (0 or 1) default is 0 python <") while(size > 0): account = accounts.keys()[0] self._signOff(account) @@ -881,6 +927,16 @@ class VimChatScope: accounts = self.accounts if account in accounts: try: + # Save the status of this account to the config file + if self.sessionStatusRestore==1: + [show,status] = accounts[account].jabberGetPresence() + priority = accounts[account]._presence.getPriority() + if not show: show='' + if not status: status='' + if not priority: priority='' + self.setLastStatus(account, str(show), str(status), + str(priority)) + # disconnect and stop accounts[account].disconnect() accounts[account].stop() del accounts[account] @@ -1727,6 +1783,9 @@ fu! VimChatCheckVars() if !exists('g:vimchat_showPresenceNotification') let g:vimchat_showPresenceNotification="" endif + if !exists('g:vimchat_restoreSessionStatus') + let g:vimchat_restoreSessionStatus=0 + endif return 1 endfu From a1b6a22842f6e6c867246858b63dd193277086a0 Mon Sep 17 00:00:00 2001 From: Philipp Schmidt Date: Thu, 4 Aug 2011 03:11:25 +0200 Subject: [PATCH 08/10] Restore the show status of the last use of VimChat. This will be written in the config file (eventually comments are deleted) --- plugin/vimchat.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/vimchat.vim b/plugin/vimchat.vim index f01ed9a..5a7fe2b 100644 --- a/plugin/vimchat.vim +++ b/plugin/vimchat.vim @@ -878,7 +878,8 @@ class VimChatScope: self.accounts[accountJid].disconnect() except: pass - self.accounts[accountJid] = self.JabberConnection(self, jid, jabberClient, roster) + self.accounts[accountJid] = self.JabberConnection( + self, jid, jabberClient, roster) self.accounts[accountJid].start() # Restore the status of the previous session From d62b1cdf3fd1693b04bf56abf4b8d507f139c2cb Mon Sep 17 00:00:00 2001 From: Philipp Schmidt Date: Thu, 4 Aug 2011 03:14:26 +0200 Subject: [PATCH 09/10] Restore the show status of the last use of VimChat. This will be written in the config file (eventually comments are deleted) --- plugin/vimchat.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugin/vimchat.vim b/plugin/vimchat.vim index 5a7fe2b..142a151 100644 --- a/plugin/vimchat.vim +++ b/plugin/vimchat.vim @@ -163,7 +163,8 @@ class VimChatScope: self.timeformat = vim.eval('g:vimchat_timestampformat') # Set restore session variable - self.sessionStatusRestore = int(vim.eval('g:vimchat_restoreSessionStatus')) + self.sessionStatusRestore = int(vim.eval( + 'g:vimchat_restoreSessionStatus')) # Signon to accounts listed in .vimrc if vim.eval("exists('g:vimchat_accounts')") == '1': @@ -957,7 +958,8 @@ class VimChatScope: "Error signing off %s VimChat" %(account), self.growl_icon) - self.growl_notifier.notify ("account status", "VimChat", "Error signing off %s VimChat" %(account), self.growl_icon) + self.growl_notifier.notify ("account status", "VimChat", + "Error signing off %s VimChat" %(account), self.growl_icon) def showStatus(self): print self.accounts[self.accounts.keys()[0]].jabberGetPresence() From beba60516f6f2aa15bb6cac774d9e1b21e6070aa Mon Sep 17 00:00:00 2001 From: Philipp Schmidt Date: Thu, 4 Aug 2011 03:17:01 +0200 Subject: [PATCH 10/10] Restore the show status of the last use of VimChat. This will be written in the config file (eventually comments are deleted) --- plugin/vimchat.vim | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugin/vimchat.vim b/plugin/vimchat.vim index 142a151..57cecd4 100644 --- a/plugin/vimchat.vim +++ b/plugin/vimchat.vim @@ -955,10 +955,6 @@ class VimChatScope: print 'Error: [%s] is an invalid account.' % (account) if self.growl_enabled: self.growl_notifier.notify("account status", "VimChat", - "Error signing off %s VimChat" %(account), - self.growl_icon) - - self.growl_notifier.notify ("account status", "VimChat", "Error signing off %s VimChat" %(account), self.growl_icon) def showStatus(self):