Exemplo n.º 1
0
    def OnCreateProfile(self, evt=None):
        from gui.profiledialog import ProfileDialog

        # show a profile dialog
        dialog = ProfileDialog(self.window)
        self.profile_dialog = dialog
        dialog.CenterOnParent()

        res = dialog.ShowModal()

        if res != wx.ID_OK: return

        # create the identity
        username, password = dialog.GetUsername(), dialog.GetPassword()
        assert username and password

        if dialog.is_new_profile:
            hooks.first('digsby.identity.create', username, password)
        else:
            hooks.first('digsby.identity.get', username, password)

        self.window.set_profiles(identities(), username, password)
        self._last_choice = self.window.FindWindowById(LoginWindow.USERNAME).GetSelection()
        self.window.panel.Layout()
        self.window.Layout()

        return True
Exemplo n.º 2
0
def extract_advanced_subpanel_im(panel, info, SP, MSP, MSC):
    hooks.first("digsby.services.edit.advanced.extract_sub.im", impl="digsby_service_editor",
                panel = panel, info = info, SP = SP, MSP = MSP, MSC = MSC)

    info['encryption'] = panel.controls['encryption']['radio'].GetValue()
    info['ignore_ssl_warnings'] = panel.controls['ignore_ssl_warnings']['check'].Value
    info['allow_plaintext'] = panel.controls['allow_plaintext']['check'].Value

    return True
Exemplo n.º 3
0
    def OnChoice(self, evt):
        evt.Skip()

        last_choice = getattr(self, '_last_choice', 0)

        i = evt.Int
        length = len(evt.EventObject.Items)

        print 'LAST WUT', evt.EventObject.GetCurrentSelection()

        if i == length - 3:
            # the ----- line. do nothing
            self.window.FindWindowById(LoginWindow.USERNAME).SetSelection(last_choice)
        elif i == length - 2:
            # Add Profile
            evt.Skip(False)
            if not self.OnCreateProfile():
                self.window.FindWindowById(LoginWindow.USERNAME).SetSelection(last_choice)

        elif i == length - 1:
            username = self.window.FindWindowById(LoginWindow.USERNAME).GetItems()[last_choice]
            identity_obj = identity(username)
            if identity_obj is None:
                return

            identity_obj.password = self.window.GetPassword()

            if wx.OK == wx.MessageBox(
                _('Are you sure you want to delete profile "%s"?' % username),
                _('Remove Profile'), wx.OK | wx.CANCEL):

                import digsby.digsbylocal as digsbylocal
                try:
                    hooks.first('digsby.identity.delete', username,
                                raise_hook_exceptions=True)
                except digsbylocal.InvalidPassword:
                    wx.MessageBox(_('Please enter the correct password to delete "%s".' % username),
                                  _('Remove Profile'))
                    self.window.FindWindowById(LoginWindow.USERNAME).SetSelection(last_choice)
                else:
                    self.window.set_profiles(identities())
                    self._last_choice = 0
                    self.window.FindWindowById(LoginWindow.PASSWORD).SetValue('')
                    self.window.panel.Layout()
                    self.window.Layout()

            else:
                self.window.FindWindowById(LoginWindow.USERNAME).SetSelection(last_choice)

        else:
            self._last_choice = i
            print 'LAST CHOICE', i
            self.window.FindWindowById(LoginWindow.PASSWORD).SetValue('')
Exemplo n.º 4
0
    def on_mouseclick(self, e):
        e.Skip()
        sp = self.service_provider_from_evt(e)
        if sp is None:
            return

        diag = hooks.first('digsby.services.create', parent = self.Top, sp_info = sp, impl="digsby_service_editor")
        diag.CenterOnParent()
        return_code = diag.ShowModal()

        if return_code != wx.ID_SAVE:
            log.info("Account creation cancelled. Return code = %r", return_code)
            return

        info = diag.extract()
        sp = hooks.first('digsby.service_provider',
                         impl = diag.sp_info.provider_id,
                         **info)

        log.info("Created %r", sp)
        components = []
        types_ = sp.get_component_types()
        if 'im' in types_:
            sp.autologin = True
        for type_ in types_:
            comp = sp.get_component(type_)
            components.append((comp, type_[:2]))
            log.info("\thas component %r: %r", type_, comp)
        import services.service_provider as sp
        with sp.ServiceProviderContainer(profile()).rebuilding() as container:
            profile.account_manager.add_multi(components)
            for comp, type_ in components:
                try:
                    if hasattr(comp, 'enable'):
                        comp.enable()
                    else:
                        comp.enabled = True
                except Exception:
                    print_exc()
                try:
                    on_create = getattr(comp, 'onCreate', None) #CamelCase for GUI code
                    if on_create is not None:
                        on_create()
                except Exception:
                    print_exc()
                if type_ == 'em':
                    hooks.notify('digsby.email.new_account', parent = self.Top, protocol = comp.protocol, **info)
            container.rebuild()
Exemplo n.º 5
0
    def edit(self, acct, connect=False, parent = None):

        # used to take linkparent

        import hooks, services.service_provider as SP
        sp = SP.get_provider_for_account(acct)
        diag = hooks.first('digsby.services.edit', parent = parent, sp = sp, impl="digsby_service_editor")
        old_offline = acct.offline_reason
        acct.offline_reason = StateMixin.Reasons.NONE

        info = None
        try:
            res = diag.ShowModal()
            from wx import ID_SAVE
            if diag.ReturnCode == ID_SAVE:
                info = diag.RetrieveData()
        finally:
            diag.Destroy()

        if info is None:
            return

        sp.update_info(info)
        sp.update_components(info)

        if not connect:
            return

        for ctype in sp.get_component_types():
            comp = sp.get_component(ctype, create = False)
            if comp is None:
                continue

            if comp is acct:
                #enable it.
                if hasattr(comp, 'enable'):
                    if old_offline == StateMixin.Reasons.BAD_PASSWORD:
                        log.info('comp.Connect() %r', comp)
                        comp.Connect()
                    elif not comp.enabled:
                        log.info('comp.enable() %r', comp)
                        comp.enable()
                else:
                    #UpdateMixin
                    if not comp.enabled:
                        log.info('comp.enabled = True %r', comp)
                        comp.enabled = True
                    else:
                        log.info('comp.Connect() %r', comp)
                        comp.Connect()
            else:
                if comp.enabled and hasattr(comp, 'enable'):
                    log.info('comp.enable() %r', comp)
                    comp.enable()
                else:
                    #UpdateMixin
                    if comp.enabled:
                        log.info('comp.Connect() %r', comp)
                        comp.Connect()
Exemplo n.º 6
0
def construct_advanced_subpanel_im(panel, SP, MSP, MSC):
    MSC.info.pop('more_details', None)

    hooks.first("digsby.services.edit.advanced.construct_sub.im", impl="digsby_service_editor",
                panel = panel, SP = SP, MSP = MSP, MSC = MSC)


    encryption = dict(radio = controls.RadioPanel(panel,
                                                 [_('Use TLS if Possible'),
                                                  _('Require TLS'),
                                                  _('Force SSL'),
                                                  _('No Encryption')]))

    encryption['radio'].SetValue(getattr(SP, 'encryption', MSC.info.defaults.encryption))

    sz = panel.controls['advanced_sz']

    hsz = wx.BoxSizer(wx.HORIZONTAL)

    l_sz = wx.BoxSizer(wx.VERTICAL)
    default_ui.ezadd(l_sz, encryption['radio'], flag = wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL)
    hsz.Add(l_sz, flag = wx.EXPAND | wx.LEFT, border = 10)

    r_sz = wx.BoxSizer(wx.VERTICAL)

    ignore_ssl_warnings = dict(check = wx.CheckBox(panel, -1, _("Ignore SSL Warnings")))
    ignore_ssl_warnings['check'].Value = getattr(SP, 'ignore_ssl_warnings', MSC.info.defaults.ignore_ssl_warnings)
    default_ui.ezadd(r_sz, ignore_ssl_warnings['check'], flag = wx.EXPAND | wx.ALL)

    allow_plaintext = dict(check = wx.CheckBox(panel, -1, _("Allow Plaintext Login")))
    allow_plaintext['check'].Value = getattr(SP, 'allow_plaintext', MSC.info.defaults.allow_plaintext)
    default_ui.ezadd(r_sz, allow_plaintext['check'], flag = wx.EXPAND | wx.ALL)

    hsz.Add(r_sz, flag = wx.EXPAND | wx.RIGHT, border = 0)

    default_ui.ezadd(sz, hsz, (sz.row, 0), (4, 4), flag = wx.EXPAND | wx.ALL)
    sz.row += 4

    panel.controls.update(
       encryption = encryption,
       ignore_ssl_warnings = ignore_ssl_warnings,
       allow_plaintext = allow_plaintext,
    )

    return True
Exemplo n.º 7
0
def validate(info, MSP, is_new):
    spc = SP.ServiceProviderContainer(common.profile())
    if is_new and spc.has_account(info):
        raise SP.AccountException(_("That account already exists."))

    try:
        sp = hooks.first('digsby.service_provider', impl = MSP.provider_id, raise_hook_exceptions = True, **info)
    except SP.AccountException, e:
        raise e
Exemplo n.º 8
0
    def import_profile_error(self, err_text=None):
        if err_text is not None:
            self.SetImportStatusText(err_text, True)

        if self.profile_importer is None:
            return

        log.info("Error getting profile")
        pi, self.profile_importer = self.profile_importer, None

        if hooks.first("digsby.identity.exists", pi.identity.name):
            hooks.first("digsby.identity.delete", pi.identity.name, pi.identity.password)

        # Form validation will re-enable OK button
        self.pp.validate_form()

        if not err_text:
            self.SetImportStatusText(_("An error occurred."), red=True)
Exemplo n.º 9
0
def get_service_provider_factory(provider_id):
    ProviderFactory = None
    for impl in (provider_id, None):
        pf = hooks.first("digsby.service_provider", impl = provider_id, provider_id = provider_id)
        if pf is not None:
            ProviderFactory  = pf
            break

    return ProviderFactory
Exemplo n.º 10
0
def validate_icq(info, MSP, is_new):
    valid = hooks.first(
        "digsby.services.validate", info, MSP, is_new, impl="digsby_service_editor", raise_hook_exceptions=True
    )

    password = info.get("_real_password_")
    if password is not None:
        if len(password) > 8:
            raise SP.AccountException(_("Password should be 8 characters or less."), fatal=False)
Exemplo n.º 11
0
    def construct_component(self, type):
        msp = get_meta_service_provider(self.provider_id)
        msc = get_meta_component_for_provider(self.provider_id, type)
        cf = self.get_component_factory(type)

        component = hooks.first("digsby.component.%s.construct" % type,
                                cf, self, msp, msc,
                                impls = (self.provider_id, 'default'))

        return component
Exemplo n.º 12
0
    def on_edit(self, rowdata):
        diag = hooks.first('digsby.services.edit', parent = self.Top, sp = rowdata, impl="digsby_service_editor")
        return_code = diag.ShowModal()
        if return_code != wx.ID_SAVE:
            return

        info = diag.RetrieveData()

        log.info("Modifying %r", rowdata)
        rowdata.update_info(info)
        rowdata.update_components(info)
Exemplo n.º 13
0
def _main():
    import wx
    import hooks
    import services.service_provider as SP
    sps = [p.provider_id for p in wx.GetApp().plugins if p.info.type == 'service_provider']
    msp = SP.get_meta_service_provider('pop')
    diag = hooks.first("digsby.services.create", msp)
    diag.Show()
    diag.Bind(wx.EVT_CLOSE, lambda e: (e.Skip(), app.ExitMainLoop()))
    app.SetTopWindow(diag)
    app.MainLoop()
Exemplo n.º 14
0
    def signin(self):
        # Set the label early if we're about to import the rest of Digsby,
        # because it may take awhile with a cold cache.
        my_id = identity(self._get_window_username())
        my_id.password = self.window.GetPassword()
        hooks.first('digsby.identity.activate', my_id, raise_hook_exceptions = True)

        if not 'digsbyprofile' in sys.modules:
            sys.util_allowed = True
            self.set_status(_('Loading...'))
            self.window.EnableControls(False, SIGN_IN, False)
            self.window.Update()
            from M2Crypto import m2 #yeah, we're actually Loading...
            m2.rand_bytes(16)       #just in case this chunk of dll isn't in memory, preload
        import digsbyprofile
        if (digsbyprofile.profile and digsbyprofile.profile.is_connected):
            self.window.EnableControls(True, SIGN_IN, True)
            self.disconnect_prof()
            self.cancelling = True
        else:
            self.login()
Exemplo n.º 15
0
    def OnDelete(self, data):

        # Display a confirmation dialog.
        msgbox = hooks.first("digsby.services.delete.build_dialog", impls = (data.provider_id, 'default'), parent = self.Top, SP = data)

        try:
            if msgbox.ShowModal() == wx.ID_YES:
                for type_ in data.get_component_types():
                    comp = data.get_component(type_, create = False)
                    if comp is None:
                        continue
                    profile.account_manager.remove(comp)
        finally:
            msgbox.Destroy()
Exemplo n.º 16
0
 def __init__(self, username, password):
     self.callback = None
     self.identity = hooks.first("digsby.identity.create", username, password)
     self.connection = DigsbyProtocol(
         username,
         password,
         profile=Null,
         user=None,
         server=("digsby.org", 5555),
         login_as="invisible",
         do_tls=False,
         sasl_md5=False,
         digsby_login=True,
     )
Exemplo n.º 17
0
    def _paint(self, e):
        dc = super(ServiceProviderRow, self)._paint(e)
        f = self.Font
        f.PointSize += 3
        dc.Font = f
        name = IServiceProviderInstanceGUIMetaData(self.data).account_name
        x,y = self._place_text.Position
        y += f.Descent

        for (color, string) in (hooks.first('digsby.services.colorize_name', impls = (self.data.provider_id, 'digsby_service_editor'), name = name) or ()):
            color_obj = getattr(self, '_active_%s_color' % color, None)
            dc.SetTextForeground(wx.Color(*color_obj))
            dc.DrawText(string, x, y)
            x += dc.GetTextExtent(string)[0]
Exemplo n.º 18
0
def validate(info, MSP, is_new):
    '''
    If user enters more than 16 characters for password, show a warning. Microsoft doesn't currently allow more than 16 chars for passwords,
    but legacy passwords may exist, so users must be allowed to enter them.

    For user safety, we also make sure they have not entered the same thing in their password and remote alias fields.
    '''
    valid = hooks.first('digsby.services.validate', info, MSP, is_new,
                        impl = "digsby_service_editor", raise_hook_exceptions = True)

    password = info.get('_real_password_')
    if password is not None:
        if len(password) > 16:
            raise SP.AccountException(_("Password should be 16 characters or less."), fatal = False)

    remote_alias = info.get('remote_alias')
    if remote_alias is not None:
        if password == remote_alias:
            raise SP.AccountException(_("You can't have your password as your display name."))

    return valid
Exemplo n.º 19
0
    def OnOK(self, event):
        if hooks.first("digsby.identity.exists", self.GetUsername()):
            wx.MessageBox(
                _('A profile named "%s" already exists. Please choose a different name or remove the existing profile.')
                % self.GetUsername(),
                _("Profile exists"),
            )
            return

        if not self.pp.passwords_match():
            wx.MessageBox(_("Please ensure your passwords match."), _("Passwords do not match"))
        else:
            if self.pp.is_new_profile:
                self.CloseWithOK()
            else:
                self.SetImportStatusText(_("Importing..."))
                self.ok_button.Enabled = False
                self.profile_importer = import_profile(
                    self.GetUsername(),
                    self.GetPassword(),
                    success=self.import_profile_success,
                    error=self.import_profile_error,
                    progress=self.update_status_text,
                )
Exemplo n.º 20
0
 def hook(self, hookname, *hookargs, **hookkwargs):
     return hooks.first(hookname, impls = (self.sp_info.provider_id, 'digsby_service_editor'), *hookargs, **hookkwargs)
Exemplo n.º 21
0
def last_identity():
    return hooks.first('digsby.identity.last')
Exemplo n.º 22
0
def identity(username):
    return (i for i in hooks.first('digsby.identity.all')
            if i.name == username).next()
Exemplo n.º 23
0
def identities():
    return [i for i in hooks.first('digsby.identity.all')]
Exemplo n.º 24
0
 def hook(self, hookname, *hookargs, **hookkwargs):
     return hooks.first(hookname,
                        impls=(self.sp_info.provider_id,
                               'digsby_service_editor'),
                        *hookargs,
                        **hookkwargs)
Exemplo n.º 25
0
def last_identity():
    return hooks.first('digsby.identity.last')
Exemplo n.º 26
0
def identities():
    return [i for i in hooks.first('digsby.identity.all')]
Exemplo n.º 27
0
def identity(username):
    return (i for i in hooks.first('digsby.identity.all')
            if i.name == username).next()