コード例 #1
0
    def _add_top_buttons(self, parent):
        # This adds the Account enable switch and the back button
        box = Gtk.Box()
        box.set_hexpand(True)
        box.set_halign(Gtk.Align.FILL)
        switch = Gtk.Switch()
        switch.set_active(
            app.config.get_per('accounts', self.account, 'active'))
        switch.set_vexpand(False)
        switch.set_valign(Gtk.Align.CENTER)
        switch.set_halign(Gtk.Align.END)
        if self.account == app.ZEROCONF_ACC_NAME and not app.is_installed(
                'ZEROCONF'):
            switch.set_sensitive(False)
            switch.set_active(False)

        switch.connect('notify::active', self._on_enable_switch, self.account)
        box.pack_start(switch, False, False, 0)
        if self.account != app.ZEROCONF_ACC_NAME:
            button = Gtk.Button(label=_('Remove'))
            button.connect('clicked', parent.on_remove_account, self.account)
            button.get_style_context().add_class('destructive-action')
            button.set_halign(Gtk.Align.END)
            switch.set_vexpand(False)
            box.pack_end(button, False, False, 0)
        self.pack_start(box, True, True, 0)
コード例 #2
0
ファイル: presence.py プロジェクト: slokhorst/gajim
    def get_presence(self,
                     to=None,
                     typ=None,
                     priority=None,
                     show=None,
                     status=None,
                     nick=None,
                     caps=True,
                     idle_time=False):
        if show not in ('chat', 'away', 'xa', 'dnd'):
            # Gajim sometimes passes invalid show values here
            # until this is fixed this is a workaround
            show = None
        presence = nbxmpp.Presence(to, typ, priority, show, status)
        if nick is not None:
            nick_tag = presence.setTag('nick', namespace=Namespace.NICK)
            nick_tag.setData(nick)

        if (idle_time and app.is_installed('IDLE')
                and app.settings.get('autoaway')):
            idle_sec = idle.Monitor.get_idle_sec()
            time_ = time.strftime('%Y-%m-%dT%H:%M:%SZ',
                                  time.gmtime(time.time() - idle_sec))

            idle_node = presence.setTag('idle', namespace=Namespace.IDLE)
            idle_node.setAttr('since', time_)

        caps = self._con.get_module('Caps').caps
        if caps is not None and typ != 'unavailable':
            presence.setTag('c',
                            namespace=Namespace.CAPS,
                            attrs=caps._asdict())

        return presence
コード例 #3
0
ファイル: muc.py プロジェクト: shubham2110/gajim1
    def _send_presence(self, muc_data, auto):
        show = app.SHOW_LIST[self._con.connected]
        if show in ('invisible', 'offline'):
            # FIXME: Check if this
            return

        status = self._con.status

        xmpp_show = helpers.get_xmpp_show(show)

        idle_time = None
        if auto and app.is_installed('IDLE') and app.config.get('autoaway'):
            idle_sec = idle.Monitor.get_idle_sec()
            idle_time = time.strftime('%Y-%m-%dT%H:%M:%SZ',
                                      time.gmtime(time.time() - idle_sec))

        self._log.info(
            'Send presence: %s, show: %s, status: %s, idle_time: %s',
            muc_data.occupant_jid, xmpp_show, status, idle_time)

        self._con.get_module('Presence').send_presence(muc_data.occupant_jid,
                                                       show=xmpp_show,
                                                       status=status,
                                                       caps=True,
                                                       idle_time=idle_time)
コード例 #4
0
ファイル: helpers.py プロジェクト: slokhorst/gajim
def play_sound_file(path_to_soundfile):
    path_to_soundfile = check_soundfile_path(path_to_soundfile)
    if path_to_soundfile is None:
        return

    path_to_soundfile = str(path_to_soundfile)
    if sys.platform == 'win32':
        import winsound
        try:
            winsound.PlaySound(path_to_soundfile,
                               winsound.SND_FILENAME|winsound.SND_ASYNC)
        except Exception:
            log.exception('Sound Playback Error')

    elif sys.platform == 'darwin':
        try:
            from AppKit import NSSound
        except ImportError:
            log.exception('Sound Playback Error')
            return

        sound = NSSound.alloc()
        sound.initWithContentsOfFile_byReference_(path_to_soundfile, True)
        sound.play()

    elif app.is_installed('GSOUND'):
        try:
            app.gsound_ctx.play_simple({'media.filename' : path_to_soundfile})
        except GLib.Error as error:
            log.error('Could not play sound: %s', error.message)
コード例 #5
0
ファイル: preferences.py プロジェクト: 72Zn/gajim
    def __init__(self, *args):

        deps_installed = app.is_installed('AV')

        audio_input_devices = {}
        audio_output_devices = {}
        if deps_installed:
            audio_input_devices = AudioInputManager().get_devices()
            audio_output_devices = AudioOutputManager().get_devices()

        audio_input_items = self._create_av_combo_items(audio_input_devices)
        audio_output_items = self._create_av_combo_items(audio_output_devices)

        settings = [
            Setting(SettingKind.POPOVER,
                    _('Audio Input Device'),
                    SettingType.CONFIG,
                    'audio_input_device',
                    desc=_('Select your audio input (e.g. microphone)'),
                    props={'entries': audio_input_items}),

            Setting(SettingKind.POPOVER,
                    _('Audio Output Device'),
                    SettingType.CONFIG,
                    'audio_output_device',
                    desc=_('Select an audio output (e.g. speakers, '
                           'headphones)'),
                    props={'entries': audio_output_items}),
        ]

        PreferenceBox.__init__(self, settings)

        self.set_sensitive(deps_installed)
コード例 #6
0
ファイル: location.py プロジェクト: slokhorst/gajim
def enable():
    if not app.is_installed('GEOCLUE'):
        log.warning('GeoClue not installed')
        return

    listener = LocationListener.get()
    listener.start()
コード例 #7
0
ファイル: preferences.py プロジェクト: slokhorst/gajim
    def __init__(self, *args):

        deps_installed = app.is_installed('AV')

        video_input_devices = {}
        if deps_installed:
            video_input_devices = VideoInputManager().get_devices()

        video_input_items = self._create_av_combo_items(video_input_devices)

        video_framerates = {
            '': _('Default'),
            '15/1': '15 fps',
            '10/1': '10 fps',
            '5/1': '5 fps',
            '5/2': '2.5 fps',
        }

        video_sizes = {
            '': _('Default'),
            '800x600': '800x600',
            '640x480': '640x480',
            '320x240': '320x240',
        }

        settings = [
            Setting(SettingKind.POPOVER,
                    _('Video Input Device'),
                    SettingType.CONFIG,
                    'video_input_device',
                    props={'entries': video_input_items},
                    desc=_('Select your video input device (e.g. webcam, '
                           'screen capture)'),
                    callback=self._on_video_input_changed),
            Setting(SettingKind.POPOVER,
                    _('Video Framerate'),
                    SettingType.CONFIG,
                    'video_framerate',
                    props={'entries': video_framerates}),
            Setting(SettingKind.POPOVER,
                    _('Video Resolution'),
                    SettingType.CONFIG,
                    'video_size',
                    props={'entries': video_sizes}),
            Setting(SettingKind.SWITCH,
                    _('Show My Video Stream'),
                    SettingType.CONFIG,
                    'video_see_self',
                    desc=_('Show your own video stream in calls')),
            Setting(SettingKind.SWITCH,
                    _('Live Preview'),
                    SettingType.VALUE,
                    desc=_('Show a live preview to test your video source'),
                    callback=self._toggle_live_preview),
        ]

        PreferenceBox.__init__(self, settings)

        self.set_sensitive(deps_installed)
コード例 #8
0
 def set_activatable(self):
     if self.account == app.ZEROCONF_ACC_NAME:
         zeroconf = app.is_installed('ZEROCONF')
         self.get_parent().set_activatable(zeroconf)
         self.get_parent().set_sensitive(zeroconf)
         if not zeroconf:
             self.get_parent().set_tooltip_text(
                 _('Please check if Avahi or Bonjour is installed.'))
コード例 #9
0
ファイル: last_activity.py プロジェクト: slokhorst/gajim
    def set_enabled(self, enabled):
        if enabled and app.is_installed('IDLE'):
            if not app.settings.get_account_setting(self._account,
                                                    'send_idle_time'):
                return

            self._nbxmpp('LastActivity').set_idle_func(
                idle.Monitor.get_idle_sec)
        else:
            self._nbxmpp('LastActivity').disable()
コード例 #10
0
ファイル: preferences.py プロジェクト: 72Zn/gajim
    def __init__(self):
        Gtk.ApplicationWindow.__init__(self)
        self.set_application(app.app)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_show_menubar(False)
        self.set_name('PreferencesWindow')
        self.set_default_size(900, 650)
        self.set_resizable(True)
        self.set_title(_('Preferences'))

        self._ui = get_builder('preferences.ui')

        self._video_preview = None
        self._prefs = {}

        side_bar_switcher = SideBarSwitcher()
        side_bar_switcher.set_stack(self._ui.stack)
        self._ui.grid.attach(side_bar_switcher, 0, 0, 1, 1)

        self.add(self._ui.grid)

        self._check_emoji_theme()

        prefs = [
            ('window_behaviour', WindowBehaviour),
            ('contact_list', ContactList),
            ('chats', Chats),
            ('group_chats', GroupChats),
            ('visual_notifications', VisualNotifications),
            ('sounds', Sounds),
            ('status_message', StatusMessage),
            ('automatic_status', AutomaticStatus),
            ('themes', Themes),
            ('emoji', Emoji),
            ('status_icon', StatusIcon),
            ('server', Server),
            ('audio', Audio),
            ('video', Video),
            ('miscellaneous', Miscellaneous),
            ('advanced', Advanced),
        ]

        self._add_prefs(prefs)
        self._add_video_preview()

        self._ui.audio_video_info_bar.set_revealed(not app.is_installed('AV'))

        self.connect('key-press-event', self._on_key_press)
        self._ui.connect_signals(self)

        self.show_all()
        if sys.platform not in ('win32', 'darwin'):
            self._ui.emoji.hide()
コード例 #11
0
ファイル: preferences.py プロジェクト: slokhorst/gajim
    def __init__(self, *args):

        settings = [
            Setting(SettingKind.USE_STUN_SERVER,
                    _('Use Stun Server'),
                    SettingType.DIALOG,
                    desc=_('Helps to establish calls through firewalls'),
                    props={'dialog': StunServerDialog}),
        ]

        PreferenceBox.__init__(self, settings)

        self.set_sensitive(app.is_installed('AV'))
コード例 #12
0
 def _apply_speller(self):
     if app.settings.get('use_speller') and app.is_installed('GSPELL'):
         lang = app.settings.get('speller_language')
         gspell_lang = Gspell.language_lookup(lang)
         if gspell_lang is None:
             gspell_lang = Gspell.language_get_default()
         spell_buffer = Gspell.TextBuffer.get_from_gtk_text_buffer(
             self._message_buffer)
         spell_buffer.set_spell_checker(Gspell.Checker.new(gspell_lang))
         spell_view = Gspell.TextView.get_from_gtk_text_view(
             self._ui.message_textview)
         spell_view.set_inline_spell_checking(True)
         spell_view.set_enable_language_menu(True)
コード例 #13
0
ファイル: accounts.py プロジェクト: slokhorst/gajim
    def __init__(self, account):
        Gtk.ListBoxRow.__init__(self)
        self.set_selectable(False)

        box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12)

        self._account = account

        self._label = Gtk.Label(label=app.get_account_label(account))
        self._label.set_halign(Gtk.Align.START)
        self._label.set_hexpand(True)
        self._label.set_ellipsize(Pango.EllipsizeMode.END)
        self._label.set_xalign(0)
        self._label.set_width_chars(18)

        next_icon = Gtk.Image.new_from_icon_name('go-next-symbolic',
                                                 Gtk.IconSize.MENU)
        next_icon.get_style_context().add_class('insensitive-fg-color')

        account_enabled = app.settings.get_account_setting(
            self._account, 'active')
        self._switch = Gtk.Switch()
        self._switch.set_active(account_enabled)
        self._switch.set_vexpand(False)

        self._switch_state_label = Gtk.Label()
        self._switch_state_label.set_xalign(1)
        self._switch_state_label.set_valign(Gtk.Align.CENTER)
        self._set_label(account_enabled)

        if (self._account == app.ZEROCONF_ACC_NAME
                and not app.is_installed('ZEROCONF')):
            self._switch.set_active(False)
            self.set_activatable(False)
            self.set_sensitive(False)
            if sys.platform in ('win32', 'darwin'):
                tooltip = _('Please check if Bonjour is installed.')
            else:
                tooltip = _('Please check if Avahi is installed.')
            self.set_tooltip_text(tooltip)

        self._switch.connect('state-set', self._on_enable_switch,
                             self._account)

        box.add(self._switch)
        box.add(self._switch_state_label)
        box.add(Gtk.Separator())
        box.add(self._label)
        box.add(next_icon)
        self.add(box)
コード例 #14
0
ファイル: preferences.py プロジェクト: slokhorst/gajim
    def __init__(self, *args):

        speller_desc = None
        if not app.is_installed('GSPELL'):
            speller_desc = _('Needs gspell to be installed')

        settings = [
            Setting(SettingKind.SWITCH,
                    _('Spell Checking'),
                    SettingType.CONFIG,
                    'use_speller',
                    desc=speller_desc,
                    enabled_func=self._speller_available,
                    callback=self._on_use_speller),
            Setting(SettingKind.SWITCH,
                    _('Message Receipts (✔)'),
                    SettingType.CONFIG,
                    'positive_184_ack',
                    desc=_('Add a checkmark to received messages')),
            Setting(SettingKind.SWITCH,
                    _('XHTML Formatting'),
                    SettingType.CONFIG,
                    'show_xhtml',
                    desc=_('Render XHTML styles (colors, etc.) of incoming '
                           'messages')),
            Setting(SettingKind.SWITCH, _('Show Send Message Button'),
                    SettingType.CONFIG, 'show_send_message_button'),
            Setting(SettingKind.SWITCH, _('Show Status Message'),
                    SettingType.CONFIG, 'print_status_in_chats'),
            Setting(SettingKind.SWITCH,
                    _('Show Chat State In Tabs'),
                    SettingType.CONFIG,
                    'show_chatstate_in_tabs',
                    desc=_('Show the contact’s chat state (e.g. typing) in '
                           'the chat’s tab')),
            Setting(SettingKind.SWITCH,
                    _('Show Chat State In Banner'),
                    SettingType.CONFIG,
                    'show_chatstate_in_banner',
                    desc=_('Show the contact’s chat state (e.g. typing) in '
                           'the chats tab’s banner')),
            Setting(SettingKind.SWITCH,
                    _('Display Chat State In Contact List'),
                    SettingType.CONFIG,
                    'show_chatstate_in_roster',
                    desc=_('Show the contact’s chat state (e.g. typing) in '
                           'the contact list')),
        ]

        PreferenceBox.__init__(self, settings)
コード例 #15
0
    def _answer_request(self, con, stanza):
        log.info('Request from %s', stanza.getFrom())
        if not app.account_is_connected(self._account):
            return

        allow_send = app.config.get_per('accounts', self._account,
                                        'send_idle_time')
        if app.is_installed('IDLE') and allow_send:
            iq = stanza.buildReply('result')
            query = iq.setQuery()
            query.attrs['seconds'] = idle.Monitor.get_idle_sec()
        else:
            iq = stanza.buildReply('error')
            err = nbxmpp.ErrorNode(nbxmpp.ERR_SERVICE_UNAVAILABLE)
            iq.addChild(node=err)

        self._con.connection.send(iq)

        raise nbxmpp.NodeProcessed
コード例 #16
0
    def _answer_request(self, _con, stanza, properties):
        self._log.info('Request from %s', properties.jid)

        allow_send = app.config.get_per('accounts', self._account,
                                        'send_idle_time')
        if app.is_installed('IDLE') and allow_send:
            iq = stanza.buildReply('result')
            query = iq.setQuery()
            seconds = idle.Monitor.get_idle_sec()
            query.attrs['seconds'] = seconds
            self._log.info('Respond with seconds: %s', seconds)
        else:
            iq = stanza.buildReply('error')
            err = nbxmpp.ErrorNode(nbxmpp.ERR_SERVICE_UNAVAILABLE)
            iq.addChild(node=err)

        self._con.connection.send(iq)

        raise nbxmpp.NodeProcessed
コード例 #17
0
ファイル: connection.py プロジェクト: slokhorst/gajim
    def change_status(self, show, msg, auto=False):
        if not msg:
            msg = ''

        self._status = show
        self._status_message = msg

        if self._state.is_disconnected:
            if show == 'offline':
                return

            self.server_resource = helpers.get_resource(self.name)
            self.connect_and_init(show, msg)
            return

        if self._state.is_connecting or self._state.is_reconnect_scheduled:
            if show == 'offline':
                self.disconnect(reconnect=False)
            elif self._state.is_reconnect_scheduled:
                self.reconnect()
            return

        # We are connected
        if show == 'offline':
            presence = self.get_module('Presence').get_presence(
                typ='unavailable',
                status=msg,
                caps=False)

            self.connection.send(presence, now=True)
            self.disconnect(reconnect=False)
            return

        idle_time = None
        if auto:
            if app.is_installed('IDLE') and app.settings.get('autoaway'):
                idle_sec = idle.Monitor.get_idle_sec()
                idle_time = time.strftime(
                    '%Y-%m-%dT%H:%M:%SZ',
                    time.gmtime(time.time() - idle_sec))

        self._update_status(show, msg, idle_time=idle_time)
コード例 #18
0
ファイル: helpers.py プロジェクト: slokhorst/gajim
def get_optional_features(account):
    features = []

    if app.settings.get_account_setting(account, 'request_user_data'):
        features.append(Namespace.MOOD + '+notify')
        features.append(Namespace.ACTIVITY + '+notify')
        features.append(Namespace.TUNE + '+notify')
        features.append(Namespace.LOCATION + '+notify')

    features.append(Namespace.NICK + '+notify')

    if app.connections[account].get_module('Bookmarks').nativ_bookmarks_used:
        features.append(Namespace.BOOKMARKS_1 + '+notify')
    elif app.connections[account].get_module('Bookmarks').pep_bookmarks_used:
        features.append(Namespace.BOOKMARKS + '+notify')
    if app.is_installed('AV'):
        features.append(Namespace.JINGLE_RTP)
        features.append(Namespace.JINGLE_RTP_AUDIO)
        features.append(Namespace.JINGLE_RTP_VIDEO)
        features.append(Namespace.JINGLE_ICE_UDP)

    # Give plugins the possibility to add their features
    app.plugin_manager.extension_point('update_caps', account, features)
    return features
コード例 #19
0
ファイル: features.py プロジェクト: slokhorst/gajim
    def _get_features(self):
        Feature = namedtuple('Feature', [
            'name', 'available', 'tooltip', 'dependency_u', 'dependency_w',
            'enabled'
        ])

        notification_sounds_available = (app.is_installed('GSOUND') or
                                         sys.platform in ('win32', 'darwin'))
        notification_sounds_enabled = app.settings.get('sounds_on')
        spell_check_enabled = app.settings.get('use_speller')

        auto_status = [
            app.settings.get('autoaway'),
            app.settings.get('autoxa')
        ]
        auto_status_enabled = bool(any(auto_status))

        return [
            Feature(
                _('Audio / Video'), app.is_installed('AV'),
                _('Enables Gajim to provide Audio and Video chats'),
                _('Requires: gir1.2-farstream-0.2, gir1.2-gstreamer-1.0, '
                  'gstreamer1.0-libav, gstreamer1.0-plugins-ugly'),
                _('Feature not available under Windows'), None),
            Feature(
                _('Automatic Status'), self._idle_available(),
                _('Enables Gajim to measure your computer\'s idle time in '
                  'order to set your Status automatically'),
                _('Requires: libxss'), _('No additional requirements'),
                auto_status_enabled),
            Feature(
                _('Bonjour / Zeroconf (Serverless Chat)'),
                app.is_installed('ZEROCONF'),
                _('Enables Gajim to automatically detected clients in a '
                  'local network for serverless chats'),
                _('Requires: gir1.2-avahi-0.6'),
                _('Requires: pybonjour and bonjour SDK running (%(url)s)') %
                {'url': 'https://developer.apple.com/opensource/)'}, None),
            Feature(
                _('Location detection'), app.is_installed('GEOCLUE'),
                _('Enables Gajim to be location-aware, if the user decides '
                  'to publish the device’s location'), _('Requires: geoclue'),
                _('Feature is not available under Windows'), None),
            Feature(
                _('Notification Sounds'), notification_sounds_available,
                _('Enables Gajim to play sounds for various notifications'),
                _('Requires: gsound'), _('No additional requirements'),
                notification_sounds_enabled),
            Feature(
                _('Secure Password Storage'), self._some_keyring_available(),
                _('Enables Gajim to store Passwords securely instead of '
                  'storing them in plaintext'),
                _('Requires: gnome-keyring or kwallet'),
                _('Windows Credential Vault is used for secure password '
                  'storage'), app.settings.get('use_keyring')),
            Feature(
                _('Spell Checker'), app.is_installed('GSPELL'),
                _('Enables Gajim to spell check your messages while '
                  'composing'), _('Requires: Gspell'), _('Requires: Gspell'),
                spell_check_enabled),
            Feature(
                _('UPnP-IGD Port Forwarding'), app.is_installed('UPNP'),
                _('Enables Gajim to request your router to forward ports '
                  'for file transfers'), _('Requires: gir1.2-gupnpigd-1.0'),
                _('Feature not available under Windows'), None)
        ]
コード例 #20
0
ファイル: message_textview.py プロジェクト: bj-h/gajim
 def toggle_speller(self, activate):
     if app.is_installed('GSPELL') and app.config.get('use_speller'):
         spell_view = Gspell.TextView.get_from_gtk_text_view(self)
         spell_view.set_inline_spell_checking(activate)
コード例 #21
0
ファイル: message_textview.py プロジェクト: bj-h/gajim
#
# You should have received a copy of the GNU General Public License
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.

from gi.repository import Gtk
from gi.repository import GLib
from gi.repository import GObject
from gi.repository import Pango

from gajim.common import app
from gajim.common.i18n import _
from gajim.common.const import StyleAttr

from gajim.gtk.util import scroll_to_end

if app.is_installed('GSPELL'):
    from gi.repository import Gspell  # pylint: disable=ungrouped-imports


class MessageTextView(Gtk.TextView):
    """
    Class for the message textview (where user writes new messages) for
    chat/groupchat windows
    """
    __gsignals__ = {
        'text-changed':
        (GObject.SignalFlags.RUN_LAST, None, (Gtk.TextBuffer, ))
    }

    UNDO_LIMIT = 20
    PLACEHOLDER = _('Write a message…')
コード例 #22
0
ファイル: single_message.py プロジェクト: bj-h/gajim
    def __init__(self,
                 account,
                 to='',
                 action='',
                 from_whom='',
                 subject='',
                 message='',
                 resource='',
                 session=None,
                 form_node=None):
        Gtk.ApplicationWindow.__init__(self)
        self.set_application(app.app)
        self.set_title(_('Send Single Message'))
        self.set_name('SendSingleMessageWindow')
        self.account = account
        self.action = action

        self.subject = subject
        self.message = message
        self.to = to
        self.from_whom = from_whom
        self.resource = resource
        self.session = session

        self._ui = get_builder('single_message_window.ui')
        self.message_tv_buffer = self._ui.message_textview.get_buffer()
        self.conversation_textview = ConversationTextview(
            account, used_in_history_window=True)
        self.conversation_textview.tv.show()
        self.conversation_textview.tv.set_left_margin(6)
        self.conversation_textview.tv.set_right_margin(6)
        self.conversation_textview.tv.set_top_margin(6)
        self.conversation_textview.tv.set_bottom_margin(6)
        self.conversation_tv_buffer = self.conversation_textview.tv.get_buffer(
        )
        self._ui.conversation_scrolledwindow.add(self.conversation_textview.tv)

        self.form_widget = None
        parent_box = self._ui.conversation_scrolledwindow.get_parent()
        if form_node:
            self.form_widget = DataFormWidget(form_node)
            self.form_widget.show_all()
            self._ui.conversation_scrolledwindow.hide()
            self._ui.message_label_received.hide()
            parent_box.add(self.form_widget)
            parent_box.child_set_property(self.form_widget, 'top-attach', 2)
            parent_box.child_set_property(self.form_widget, 'left-attach', 0)
            parent_box.child_set_property(self.form_widget, 'width', 2)
            self.action = 'form'

        self.message_tv_buffer.connect('changed', self.update_char_counter)
        if isinstance(to, list):
            jid = ', '.join([i[0].get_full_jid() for i in to])
            self._ui.to_entry.set_text(jid)
        else:
            self._ui.to_entry.set_text(to)

        if app.config.get('use_speller') and app.is_installed(
                'GSPELL') and action == 'send':
            lang = app.config.get('speller_language')
            gspell_lang = Gspell.language_lookup(lang)
            if gspell_lang is None:
                AspellDictError(lang)
            else:
                spell_buffer = Gspell.TextBuffer.get_from_gtk_text_buffer(
                    self._ui.message_textview.get_buffer())
                spell_buffer.set_spell_checker(Gspell.Checker.new(gspell_lang))
                spell_view = Gspell.TextView.get_from_gtk_text_view(
                    self._ui.message_textview)
                spell_view.set_inline_spell_checking(True)
                spell_view.set_enable_language_menu(True)

        self.prepare_widgets_for(self.action)

        # set_text(None) raises TypeError exception
        if self.subject is None:
            self.subject = _('(No subject)')
        self._ui.subject_entry.set_text(self.subject)
        self._ui.subject_from_entry_label.set_text(self.subject)

        if to == '':
            liststore = get_completion_liststore(self._ui.to_entry)
            self.completion_dict = helpers.get_contact_dict_for_account(
                account)
            keys = sorted(self.completion_dict.keys())
            for jid in keys:
                contact = self.completion_dict[jid]
                status_icon = get_icon_name(contact.show)
                liststore.append((status_icon, jid))
        else:
            self.completion_dict = {}

        self._ui.to_entry.connect('changed', self.on_to_entry_changed)
        self._ui.connect_signals(self)

        # get window position and size from config
        resize_window(self._ui.single_message_window,
                      app.config.get('single-msg-width'),
                      app.config.get('single-msg-height'))
        move_window(self._ui.single_message_window,
                    app.config.get('single-msg-x-position'),
                    app.config.get('single-msg-y-position'))

        self._ui.single_message_window.show_all()
コード例 #23
0
ファイル: features.py プロジェクト: throwawaymicrosoft/gajim
 def gupnp_igd_available(self):
     return app.is_installed('UPNP')
コード例 #24
0
ファイル: features.py プロジェクト: throwawaymicrosoft/gajim
 def farstream_available(self):
     return app.is_installed('FARSTREAM')
コード例 #25
0
ファイル: features.py プロジェクト: throwawaymicrosoft/gajim
 def speller_available(self):
     return app.is_installed('GSPELL')
コード例 #26
0
ファイル: features.py プロジェクト: throwawaymicrosoft/gajim
 def gpg_available(self):
     return app.is_installed('GPG')
コード例 #27
0
ファイル: features.py プロジェクト: throwawaymicrosoft/gajim
 def zeroconf_available(self):
     return app.is_installed('ZEROCONF')
コード例 #28
0
    def _add_upnp_igd_as_streamhost_to_query(self, query, file_props, iq):
        if not app.is_installed('UPNP'):
            self._con.connection.send(iq)
            return

        my_ip = self._con.peerhost[0]

        # check if we are connected with an IPv4 address
        try:
            socket.inet_aton(my_ip)
        except socket.error:
            self._con.connection.send(iq)
            return

        def ip_is_local(ip):
            if '.' not in ip:
                # it's an IPv6
                return True
            ip_s = ip.split('.')
            ip_l = int(ip_s[0])<<24 | int(ip_s[1])<<16 | int(ip_s[2])<<8 | \
                 int(ip_s[3])
            # 10/8
            if ip_l & (255 << 24) == 10 << 24:
                return True
            # 172.16/12
            if ip_l & (255 << 24 | 240 << 16) == (172 << 24 | 16 << 16):
                return True
            # 192.168
            if ip_l & (255 << 24 | 255 << 16) == (192 << 24 | 168 << 16):
                return True
            return False

        if not ip_is_local(my_ip):
            self.connection.send(iq)
            return

        self.no_gupnp_reply_id = 0

        def cleanup_gupnp():
            if self.no_gupnp_reply_id:
                GLib.source_remove(self.no_gupnp_reply_id)
                self.no_gupnp_reply_id = 0
            app.gupnp_igd.disconnect(self.ok_id)
            app.gupnp_igd.disconnect(self.fail_id)

        def success(_gupnp, _proto, ext_ip, _re, ext_port, local_ip,
                    local_port, _desc):
            log.debug('Got GUPnP-IGD answer: external: %s:%s, internal: %s:%s',
                      ext_ip, ext_port, local_ip, local_port)
            if local_port != app.config.get('file_transfers_port'):
                sender = file_props.sender
                receiver = file_props.receiver
                sha_str = helpers.get_auth_sha(file_props.sid, sender,
                                               receiver)
                listener = app.socks5queue.start_listener(
                    local_port, sha_str, self._result_socks5_sid,
                    file_props.sid)
                if listener:
                    self._add_streamhosts_to_query(query, sender, ext_port,
                                                   [ext_ip])
            else:
                self._add_streamhosts_to_query(query, file_props.sender,
                                               ext_port, [ext_ip])
            self._con.connection.send(iq)
            cleanup_gupnp()

        def fail(_gupnp, error, _proto, _ext_ip, _local_ip, _local_port,
                 _desc):
            log.debug('Got GUPnP-IGD error: %s', error)
            self._con.connection.send(iq)
            cleanup_gupnp()

        def no_upnp_reply():
            log.debug('Got not GUPnP-IGD answer')
            # stop trying to use it
            app.disable_dependency('UPNP')
            self.no_gupnp_reply_id = 0
            self._con.connection.send(iq)
            cleanup_gupnp()
            return False

        self.ok_id = app.gupnp_igd.connect('mapped-external-port', success)
        self.fail_id = app.gupnp_igd.connect('error-mapping-port', fail)

        port = app.config.get('file_transfers_port')
        self.no_gupnp_reply_id = GLib.timeout_add_seconds(10, no_upnp_reply)
        app.gupnp_igd.add_port('TCP', 0, my_ip, port, 3600,
                               'Gajim file transfer')
コード例 #29
0
ファイル: jingle.py プロジェクト: throwawaymicrosoft/gajim
# * UI:
#   - make state and codec informations available to the user
#   - video integration
#   * config:
#     - codecs

import logging

import nbxmpp
from gajim.common import helpers
from gajim.common import app

from gajim.common.jingle_session import JingleSession, JingleStates
from gajim.common.jingle_ft import JingleFileTransfer
from gajim.common.jingle_transport import JingleTransportSocks5, JingleTransportIBB
if app.is_installed('FARSTREAM'):
    from gajim.common.jingle_rtp import JingleAudio, JingleVideo

logger = logging.getLogger('gajim.c.jingle')


class ConnectionJingle(object):
    """
    This object depends on that it is a part of Connection class.
    """
    def __init__(self):
        # dictionary: sessionid => JingleSession object
        self._sessions = {}

        # dictionary: (jid, iq stanza id) => JingleSession object,
        # one time callbacks
コード例 #30
0
ファイル: location.py プロジェクト: slokhorst/gajim
# 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/>.

import logging
from datetime import datetime

from gi.repository import GLib
from nbxmpp.structs import LocationData

from gajim.common import app

if app.is_installed('GEOCLUE'):
    from gi.repository import Geoclue  # pylint: disable=ungrouped-imports,no-name-in-module

log = logging.getLogger('gajim.c.dbus.location')


class LocationListener:
    _instance = None

    @classmethod
    def get(cls):
        if cls._instance is None:
            cls._instance = cls()
        return cls._instance

    def __init__(self):