Skip to content
Snippets Groups Projects
Commit 765180d1 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Remove Plugin examples

These examples are outdated

The plugin repository should contain enough working examples
parent 0aaa9c41
No related branches found
No related tags found
No related merge requests found
from .plugin import EventsDumpPlugin
[info]
name: Events Dump
short_name: events_dump
version: 0.1
description: Dumps info about selected events to console.
authors = Mateusz Biliński <mateusz@bilinski.it>
homepage = http://blog.bilinski.it
# -*- coding: utf-8 -*-
##
## This file is part of Gajim.
##
## Gajim is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation; version 3 only.
##
## Gajim is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
##
'''
Events Dump plugin.
Dumps info about selected events to console.
:author: Mateusz Biliński <mateusz@bilinski.it>
:since: 10th August 2008
:copyright: Copyright (2008) Mateusz Biliński <mateusz@bilinski.it>
:license: GPL
'''
import types
from pprint import pformat
from gajim.plugins import GajimPlugin
from gajim.plugins.helpers import log_calls, log
from gajim.common import ged
class EventsDumpPlugin(GajimPlugin):
@log_calls('EventsDumpPlugin')
def init(self):
self.description = _('Dumps info about selected events to console.')
self.config_dialog = None
#self.gui_extension_points = {}
#self.config_default_values = {}
events_from_old_dbus_support = [
'Roster', 'AccountPresence', 'ContactPresence',
'ContactAbsence', 'ContactStatus', 'NewMessage',
'Subscribe', 'Subscribed', 'Unsubscribed',
'NewAccount', 'VcardInfo', 'LastStatusTime',
'OsInfo', 'GCPresence', 'GCMessage', 'RosterInfo',
'NewGmail']
events_from_src_gajim = [
'ROSTER', 'WARNING', 'ERROR',
'INFORMATION', 'ERROR_ANSWER', 'STATUS',
'NOTIFY', 'MSGERROR', 'MSGSENT', 'MSGNOTSENT',
'SUBSCRIBED', 'UNSUBSCRIBED', 'SUBSCRIBE',
'AGENT_ERROR_INFO', 'AGENT_ERROR_ITEMS',
'AGENT_REMOVED', 'REGISTER_AGENT_INFO',
'AGENT_INFO_ITEMS', 'AGENT_INFO_INFO',
'QUIT', 'NEW_ACC_CONNECTED',
'NEW_ACC_NOT_CONNECTED', 'ACC_OK', 'ACC_NOT_OK',
'MYVCARD', 'VCARD', 'LAST_STATUS_TIME', 'OS_INFO',
'GC_NOTIFY', 'GC_MSG', 'GC_SUBJECT', 'GC_CONFIG',
'GC_CONFIG_CHANGE', 'GC_INVITATION',
'GC_AFFILIATION', 'GC_PASSWORD_REQUIRED',
'BAD_PASSPHRASE', 'ROSTER_INFO', 'BOOKMARKS',
'CON_TYPE', 'CONNECTION_LOST', 'FILE_REQUEST',
'FILE_REQUEST_ERROR', 'FILE_SEND_ERROR',
'STANZA_ARRIVED', 'STANZA_SENT',
'HTTP_AUTH', 'VCARD_PUBLISHED',
'VCARD_NOT_PUBLISHED', 'ASK_NEW_NICK', 'SIGNED_IN',
'METACONTACTS', 'ATOM_ENTRY', 'FAILED_DECRYPT',
'PRIVACY_LISTS_RECEIVED', 'PRIVACY_LIST_RECEIVED',
'PRIVACY_LISTS_ACTIVE_DEFAULT',
'PRIVACY_LIST_REMOVED', 'ZC_NAME_CONFLICT',
'PING_SENT', 'PING_REPLY', 'PING_ERROR',
'SEARCH_FORM', 'SEARCH_RESULT',
'RESOURCE_CONFLICT', 'PEP_CONFIG',
'UNIQUE_ROOM_ID_UNSUPPORTED',
'UNIQUE_ROOM_ID_SUPPORTED', 'SESSION_NEG',
'GPG_PASSWORD_REQUIRED', 'SSL_ERROR',
'FINGERPRINT_ERROR', 'PLAIN_CONNECTION',
'PUBSUB_NODE_REMOVED', 'PUBSUB_NODE_NOT_REMOVED']
network_events_from_core = ['raw-message-received',
'raw-iq-received',
'raw-pres-received']
network_events_generated_in_nec = [
'customized-message-received',
'more-customized-message-received',
'modify-only-message-received',
'enriched-chat-message-received']
self.events_names = []
self.events_names += network_events_from_core
self.events_names += network_events_generated_in_nec
self.events_handlers = {}
self._set_handling_methods()
@log_calls('EventsDumpPlugin')
def activate(self):
pass
@log_calls('EventsDumpPlugin')
def deactivate(self):
pass
@log_calls('EventsDumpPlugin')
def _set_handling_methods(self):
for event_name in self.events_names:
setattr(self, event_name,
types.MethodType(
self._generate_handling_method(event_name),
self))
self.events_handlers[event_name] = (ged.POSTCORE,
getattr(self, event_name))
def _generate_handling_method(self, event_name):
def handler(self, *args):
print ("Event '%s' occured. Arguments: %s\n\n===\n" % (event_name, pformat(args)))
return handler
from .plugin import NewEventsExamplePlugin
[info]
name: New Events Example
short_name: new_events_example
version: 0.1
description: Shows how to generate new network events based on existing one using Network Events Controller.
authors = Mateusz Biliński <mateusz@bilinski.it>
homepage = http://blog.bilinski.it
# -*- coding: utf-8 -*-
##
## This file is part of Gajim.
##
## Gajim is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation; version 3 only.
##
## Gajim is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
##
'''
New Events Example plugin.
Demonstrates how to use Network Events Controller to generate new events
based on existing one.
:author: Mateusz Biliński <mateusz@bilinski.it>
:since: 15th August 2008
:copyright: Copyright (2008) Mateusz Biliński <mateusz@bilinski.it>
:license: GPL
'''
#import new # Depricated in python3 for types module
from pprint import pformat
from gajim.common import helpers
from gajim.common import app
from gajim.plugins import GajimPlugin
from gajim.plugins.helpers import log_calls, log
from gajim.common import ged
from gajim.common import nec
class NewEventsExamplePlugin(GajimPlugin):
@log_calls('NewEventsExamplePlugin')
def init(self):
self.description = _('Shows how to generate new network events based '
'on existing one using Network Events Controller.')
self.config_dialog = None
#self.gui_extension_points = {}
#self.config_default_values = {}
self.events_handlers = {'raw-message-received' :
(ged.POSTCORE, self.raw_message_received),
'customized-message-received' :
(ged.POSTCORE, self.customized_message_received),
'enriched-chat-message-received' :
(ged.POSTCORE, self.enriched_chat_message_received)}
self.events = [CustomizedMessageReceivedEvent,
MoreCustomizedMessageReceivedEvent,
ModifyOnlyMessageReceivedEvent,
EnrichedChatMessageReceivedEvent]
def enriched_chat_message_received(self, event_object):
pass
# print "Event '%s' occured. Event object: %s\n\n===\n" % \
# (event_object.name, event_object)
def raw_message_received(self, event_object):
pass
# print "Event '%s' occured. Event object: %s\n\n===\n" % \
# (event_object.name,event_object)
def customized_message_received(self, event_object):
pass
# print "Event '%s' occured. Event object: %s\n\n===\n" % \
# (event_object.name, event_object
@log_calls('NewEventsExamplePlugin')
def activate(self):
pass
@log_calls('NewEventsExamplePlugin')
def deactivate(self):
pass
class CustomizedMessageReceivedEvent(nec.NetworkIncomingEvent):
name = 'customized-message-received'
base_network_events = ['raw-message-received']
def generate(self):
return True
class MoreCustomizedMessageReceivedEvent(nec.NetworkIncomingEvent):
'''
Shows chain of custom created events.
This one is based on custom 'customized-messsage-received'.
'''
name = 'more-customized-message-received'
base_network_events = ['customized-message-received']
def generate(self):
return True
class ModifyOnlyMessageReceivedEvent(nec.NetworkIncomingEvent):
name = 'modify-only-message-received'
base_network_events = ['raw-message-received']
def generate(self):
msg_type = self.base_event.stanza.attrs.get('type', None)
if msg_type == u'chat':
msg_text = ''.join(self.base_event.stanza.kids[0].data)
self.base_event.stanza.kids[0].setData(
u'%s [MODIFIED BY CUSTOM NETWORK EVENT]' % (msg_text))
return False
class EnrichedChatMessageReceivedEvent(nec.NetworkIncomingEvent):
'''
Generates more friendly (in use by handlers) network event for
received chat message.
'''
name = 'enriched-chat-message-received'
base_network_events = ['raw-message-received']
def generate(self):
msg_type = self.base_event.stanza.attrs.get('type', None)
if msg_type == u'chat':
self.stanza = self.base_event.stanza
self.conn = self.base_event.conn
self.from_jid = helpers.get_full_jid_from_iq(self.stanza)
self.from_jid_without_resource = app.get_jid_without_resource(
self.from_jid)
self.account = self.conn.name
self.from_nickname = app.get_contact_name_from_jid( self.account,
self.from_jid_without_resource)
self.msg_text = ''.join(self.stanza.kids[0].data)
return True
return False
__all__ = ['RosterButtonsPlugin']
from .plugin import RosterButtonsPlugin
[info]
name: Roster Buttons
short_name: roster_buttons
version: 0.1
description: Adds quick action buttons to roster window.
authors = Mateusz Biliński <mateusz@bilinski.it>
homepage = http://blog.bilinski.it
# -*- coding: utf-8 -*-
## This file is part of Gajim.
##
## Gajim is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation; version 3 only.
##
## Gajim is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
##
'''
Roster buttons plug-in.
:author: Mateusz Biliński <mateusz@bilinski.it>
:since: 14th June 2008
:copyright: Copyright (2008) Mateusz Biliński <mateusz@bilinski.it>
:license: GPL
'''
import sys
import gtk
from gajim.common import app
from gajim.plugins import GajimPlugin
from gajim.plugins.helpers import log, log_calls
class RosterButtonsPlugin(GajimPlugin):
@log_calls('RosterButtonsPlugin')
def init(self):
self.description = _('Adds quick action buttons to roster window.')
self.GTK_BUILDER_FILE_PATH = self.local_file_path('roster_buttons.ui')
self.config_dialog = None
@log_calls('RosterButtonsPlugin')
def activate(self):
self.roster_vbox = app.interface.roster.xml.get_object('roster_vbox2')
self.show_offline_contacts_menuitem = app.interface.roster.xml.get_object('show_offline_contacts_menuitem')
self.xml = gtk.Builder()
self.xml.set_translation_domain('gajim_plugins')
self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH,
['roster_buttons_buttonbox'])
self.buttonbox = self.xml.get_object('roster_buttons_buttonbox')
self.roster_vbox.pack_start(self.buttonbox, expand=False)
self.roster_vbox.reorder_child(self.buttonbox, 0)
self.xml.connect_signals(self)
@log_calls('RosterButtonsPlugin')
def deactivate(self):
self.roster_vbox.remove(self.buttonbox)
self.buttonbox = None
self.xml = None
@log_calls('RosterButtonsPlugin')
def on_roster_button_1_clicked(self, button):
#gajim.interface.roster.on_show_offline_contacts_menuitem_activate(None)
self.show_offline_contacts_menuitem.set_active(not self.show_offline_contacts_menuitem.get_active())
@log_calls('RosterButtonsPlugin')
def on_roster_button_2_clicked(self, button):
pass
@log_calls('RosterButtonsPlugin')
def on_roster_button_3_clicked(self, button):
pass
@log_calls('RosterButtonsPlugin')
def on_roster_button_4_clicked(self, button):
pass
<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkWindow" id="window1">
<child>
<object class="GtkHButtonBox" id="roster_buttons_buttonbox">
<property name="visible">True</property>
<property name="homogeneous">True</property>
<property name="layout_style">spread</property>
<child>
<object class="GtkButton" id="roster_button_1">
<property name="label">1</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_roster_button_1_clicked"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="roster_button_2">
<property name="label">2</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_roster_button_2_clicked"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="roster_button_3">
<property name="label">3</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_roster_button_3_clicked"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="roster_button_4">
<property name="label">4</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_roster_button_4_clicked"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment