class JabberDeleteConfirmBox(wx.Dialog): def __init__(self, acct, msg, *a, **k): self.acct = acct wx.Dialog.__init__(self, *a, **k) self.init_components(msg) self.bind_events() self.layout_components() # TODO: we need self.del_check.Enable(self.acct.connection is not None) self.Layout() self.Sizer.Fit(self) def init_components(self, msg): self.help_bmp = wx.StaticBitmap(self) self.help_bmp.SetBitmap( wx.ArtProvider.GetBitmap(wx.ART_HELP, wx.ART_OTHER, (32, 32))) self.msg_label = wx.StaticText(self, label=msg) self.del_check = wx.CheckBox(self, label="Also delete from Jabber server") self.pw_text = wx.TextCtrl(self, style=wx.TE_PASSWORD, validator=LengthLimit(1024)) self.pw_label = wx.StaticText(self, label="Password: "******"Incorrect Password"), _("Incorrect Password")) return self.show_buttons(False) self.acct.delete_from_server( self.password, on_success=success, on_fail=lambda: (self.show_buttons(), wx.MessageBox(message=_( "Failed to delete account from the server."), caption=_("Delete Account - Failed"), style=wx.OK))) else: success() def show_buttons(self, val=True): self.yes_btn.Enabled = val self.no_btn.Enabled = val self.yes_btn.Show(val) self.no_btn.Show(val) self.del_label.Show(not val) self.Layout() def no_clicked(self, e): self.EndModal(wx.NO) def on_check(self, e): self.pw_text.Enabled = self.delete delete = wx_prop('del_check') password = wx_prop('pw_text')
def __init__(self,parent): SimplePanel.__init__(self, parent, wx.FULL_REPAINT_ON_RESIZE) self.BackgroundColour = wx.WHITE self.Sizer = wx.BoxSizer(HORIZONTAL) sz = wx.BoxSizer(HORIZONTAL) self.Sizer.Add(sz,1,EXPAND|ALL,3) leftcol = wx.BoxSizer(VERTICAL) acctcombo = self.acctcombo = UberCombo(self, value='',skinkey='AppDefaults.PrefCombo') acctcont = PrefPanel(self,acctcombo,_('Account')) leftcol.Add(acctcont,0,EXPAND|ALL,3) buddylist = self.buddylist = ListOBuddies(self) self.buddies_panel = buddycont = PrefPanel(self, buddylist, _('Buddy')) leftcol.Add(buddycont, 1, EXPAND | TOPLESS, 3) style = wx.NO_BORDER | CAL_SUNDAY_FIRST | CAL_SEQUENTIAL_MONTH_SELECTION | CAL_SHOW_HOLIDAYS cal = self.cal = CalendarCtrl(self, -1, wx.DateTime.Now(), wx.DefaultPosition, wx.DefaultSize, style) cal.SetForegroundColour(wx.Color(160, 160, 160)) cal.SetHolidayColours(wx.BLACK, wx.WHITE) cal.SetHeaderColours(Color(160, 160, 160), Color(239, 239, 239)) calcont = PrefPanel(self,cal,_('Date')) leftcol.Add(calcont, 0, EXPAND | TOPLESS, 3) sz.Add(leftcol, 0, EXPAND) viewpanel = wx.Panel(self) viewer = self.viewer = PastBrowserWebkitWindow(viewpanel) # viewer.SetMouseWheelZooms(True) finder = self.finder = FindBar(viewpanel,viewer) menu = UMenu(viewer) menu.AddItem(_('Copy'), id = wx.ID_COPY, callback = lambda *a: viewer.Copy()) viewer.BindWheel(self) viewer.BindScrollWin(self) viewer.Bind(wx.EVT_CONTEXT_MENU, lambda e: (menu.GetItemById(wx.ID_COPY).Enable(viewer.CanCopy()), menu.PopupMenu(event = e))) viewer.Bind(wx.EVT_KEY_DOWN,self.OnKeyDown) finder.TextControl.Bind(wx.EVT_KEY_DOWN,self.OnKeyDown) nav = BoxSizer(wx.HORIZONTAL) prev = self.prev = UberButton(viewpanel, label = '<-', skin = BUTTON_SKIN) next = self.next = UberButton(viewpanel, label = '->', skin = BUTTON_SKIN) datelabel = wx.StaticText(viewpanel, -1, style = wx.ALIGN_CENTER| wx.ST_NO_AUTORESIZE) datelabel.SetMinSize((140, -1)) prev.Bind(wx.EVT_BUTTON, lambda e: self.Flip(-1)) next.Bind(wx.EVT_BUTTON, lambda e: self.Flip( 1)) nav.AddStretchSpacer(1) nav.AddMany([(prev, 0, wx.EXPAND | wx.ALIGN_CENTER), (datelabel, 0, wx.EXPAND | wx.ALIGN_CENTER), (next, 0, wx.EXPAND | wx.ALIGN_CENTER)]) nav.AddStretchSpacer(1) viewpanel.Sizer = wx.BoxSizer(wx.VERTICAL) viewpanel.Sizer.AddMany([ (nav, 0, EXPAND), (viewer, 1, EXPAND), (finder, 0, EXPAND) ]) sz.Add(PrefPanel(self, viewpanel, _('Conversation Log')), 1, EXPAND | ALL, 3) Bind = self.Bind Bind(wx.EVT_PAINT, self.OnPaint) def OnAcct(*a): ''' Handle selection of a new account from the Account drop down ''' if self.GroupChatsSelected(): from collections import defaultdict self.groupchats = defaultdict(list) for g in GetGroupChats(): d = g['time'] key = DateTimeFromDMY(d.day, d.month-1, d.year) self.groupchats[key].append(g) #dates = sorted((g['date'], g) for g in self.dates = sorted(self.groupchats.keys()) UpdateCal() self.buddies_panel.SetTitle(_('Chats')) else: buddylist.SetList(GetBuddies(acctcombo.Value.id), BuddyRenderer()) OnBuddy() self.buddies_panel.SetTitle(_('Buddy')) def OnBuddy(*a): ''' Handels selection of a buddy from the buddy pannel ''' if not self.GroupChatsSelected(): self.dates = GetDates(buddylist.SelectedBuddy.dir) UpdateCal() else: ViewLogForFile(buddylist.SelectedItem['file'], do_aliases=False) def UpdateCal(): ''' Switches the date to the last date conversed with the selected budy ''' self.next.Enable(True) self.prev.Enable(True) if self.dates: self.cal.Date = self.dates[-1] self.cal.Enable(True) OnCalChange() def OnCalChange(*a): ''' Update the Calendar UI to a new date ''' caldate = cal.Date currentyear = caldate.GetYear() currentmonth = caldate.GetMonth() relevantdates = frozenset(date.GetDay() for date in self.dates if date.GetYear() == currentyear and date.GetMonth() == currentmonth and date.GetDay()) SetHoliday, SetAttr = cal.SetHoliday, cal.SetAttr for i in xrange(1, 32): if i in relevantdates: SetHoliday(i) else: SetAttr(i, CalendarDateAttr(Color(160,160,160))) OnDayChange() self.OnCalChange = OnCalChange def ViewLogForDay(date): ''' Load the log file for the specified date for the currently selected buddy ''' logpath = logpath_for_date(buddylist.SelectedBuddy, date) ViewLogForFile(logpath) def ViewLogForFile(logpath, do_aliases=True): ''' Update the log viewer with the file specified ''' with viewer.Frozen(): viewer.SetPageSource(logpath.text('utf-8', 'replace'), logpath.url()) viewer.RunScript('window.scroll(0, 0);') if do_aliases: substitue_aliases() import hooks hooks.notify('digsby.statistics.logviewer.log_viewed') def substitue_aliases(): ''' Swap out buddy names with their allies ''' import gui with open(gui.skin.resourcedir() / 'html' / 'jquery-1.3.2.js', 'rb') as f: viewer.RunScript(f.read()) buddy = buddylist.SelectedBuddy aliases = IAliasProvider(profile()) import simplejson as json names = set(json.loads(viewer.RunScript("var foo = []; $('.buddy').each(function(){foo.push($(this).html())}); JSON.stringify(foo);"))) for name in names: alias = aliases.get_alias(name, buddy.service, buddy.protocol) or name viewer.RunScript(SUBHTML % (json.dumps(name), json.dumps(alias))) def OnDayChange(*a): ''' Show the log for the day selected in the clander ''' date = cal.Date self.date = date datelabel.SetLabel(date.FormatDate()) if cal.GetAttr(date.GetDay()).IsHoliday(): if self.GroupChatsSelected(): chats = sorted(self.groupchats[date], key=lambda g: g['time'], reverse=True) buddylist.SetList(chats, GroupChatRenderer()) if chats: ViewLogForFile(chats[0]['file'], do_aliases=False) else: ViewLogForDay(date) else: year = str(date.GetYear()) month = date.GetMonth() month = wx.DateTime.GetMonthName(int(month)) day = str(date.GetDay()) specific_day_string = _('{month}, {day}, {year}').format(month=month, day=day, year=year) if self.GroupChatsSelected(): msg = _("There are no chat logs for {specific_day_string}.").format(specific_day_string=specific_day_string) else: msg = _("There are no chat logs for {specific_day_string} with {name}.").format(specific_day_string=specific_day_string, name=buddylist.SelectedBuddy.name) viewer.SetPageSource(msg, 'file:///C:/') viewer.SetFocus() wx.CallAfter(cal.Refresh) self.OnDayChange = OnDayChange acctcombo.SetCallbacks(value = OnAcct) buddylist.Bind(wx.EVT_LISTBOX, OnBuddy) cBind = cal.Bind cBind(EVT_CALENDAR_YEAR, OnCalChange) cBind(EVT_CALENDAR_MONTH, OnCalChange) cBind(EVT_CALENDAR_SEL_CHANGED, OnDayChange) acctcombo.SetItems(MakeAccountItems(), 0)
class PasswordChangeDialog(wx.Dialog): def __init__(self, parent, acct, *a, **k): self.acct = acct wx.Dialog.__init__(self, parent, title=_('Change Password'), *a, **k) self.init_components() self.bind_events() self.layout_components() self.Layout() self.Sizer.Fit(self) def init_components(self): self.old_pw_label = wx.StaticText(self, label=_("Old Password: "******"New Password: "******"Confirm New Password: "******"Incorrect Old Password"), _("Incorrect Old Password")) elif self.new1_password != self.new2_password: wx.MessageBox(_("Passwords do not match"), _("Paswords do not match")) else: def success(st=None): print 'success!', st print 'setting password in', self.acct from common import profile self.acct.password = profile.crypt_pw(self.new1_password) for acct in profile.account_manager.accounts: if acct.name == self.acct.username and acct.protocol == self.acct.protocol: acct.update_info( password=profile.crypt_pw(self.new1_password)) break self.EndModal(wx.ID_OK) def error(self, e=None): print 'error', e self.EndModal(wx.ID_OK) self.acct.change_password(self.new1_password, success=success, error=error) def Prompt(self, callback): #self.callback = callback self.ShowModal()