[Branch ~piorun/piorun/devel] Rev 66: storing account settings in database instead of config file

0 views
Skip to first unread message

nor...@launchpad.net

unread,
Jan 1, 2008, 4:03:14 PM1/1/08
to piorun...@googlegroups.com
------------------------------------------------------------
revno: 66
committer: doza <doza@orkan>
branch nick: devel
timestamp: Tue 2008-01-01 22:02:45 +0100
message:
storing account settings in database instead of config file
removed:
src/dialogs/AccountDialog.boo
renamed:
src/actions/AccountActions.boo => src/Account.boo
modified:
Piorun.mdp
res/ui.xml
src/Configuration.boo
src/Database.boo
src/Piorun.boo
src/Session.boo
src/actions/SessionActions.boo
src/Account.boo

=== removed file 'src/dialogs/AccountDialog.boo'
--- a/src/dialogs/AccountDialog.boo 2007-11-25 22:25:46 +0000
+++ b/src/dialogs/AccountDialog.boo 1970-01-01 00:00:00 +0000
@@ -1,173 +0,0 @@
-# Copyright (c) 2005-2006 Dominik Zablotny <do...@sztorm.net>
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy of this
-# software and associated documentation files (the "Software"), to deal in the Software
-# without restriction, including without limitation the rights to use, copy, modify, merge,
-# publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
-# to whom the Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in all copies
-# or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
-# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
-# FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
-# OR OTHER DEALINGS IN THE SOFTWARE.
-
-namespace Piorun
-
-import Piorun.Xmpp
-import System
-import Gtk
-import Glade
-import System.Diagnostics
-
-class AccountDialog:
-
- [Widget] accountDialog as Gtk.Dialog
- [Widget] passwordEntry as Gtk.Entry
- [Widget] SavePasswordCheckButton as Gtk.CheckButton
- [Widget] resourceEntry as Gtk.Entry
- [Widget] prioritySpinButton as Gtk.SpinButton
- [Widget] serverEntry as Gtk.Entry
- [Widget] portSpinButton as Gtk.SpinButton
- [Widget] useTlsCheckButton as Gtk.CheckButton
- [Widget] oldTlsCheckButton as Gtk.CheckButton
- [Widget] defPriorityCheckButton as Gtk.CheckButton
- [Widget] defPortCheckButton as Gtk.CheckButton
- [Widget] advExpander as Expander
- [Widget] jidCombo as Gtk.Combo
-
- [Widget] newPasswordEntry as Gtk.Entry
- [Widget] repeatPasswordEntry as Gtk.Entry
- [Widget] newPasswordLabel as Gtk.Label
- [Widget] repeatPasswordLabel as Gtk.Label
-
- [property(NewPassword)] newPassword as string
-
- SavePassword as bool:
- get:
- return SavePasswordCheckButton.Active
-
- _newPasswordVisible = false
- NewPasswordVisible:
- get:
- return _newPasswordVisible
- set:
- newPasswordEntry.Visible = value
- newPasswordLabel.Visible = value
- _newPasswordVisible = value
-
- _repeatPasswordVisible = false
- RepeatPasswordVisible:
- get:
- return _repeatPasswordVisible
- set:
- repeatPasswordEntry.Visible = value
- repeatPasswordLabel.Visible = value
- _newPasswordVisible = value
-
- def constructor(parent as Window):
- gxml = Glade.XML.FromAssembly("piorun.glade","accountDialog", null)
- gxml.Autoconnect(self)
- advExpander.Expanded = false # must be before showing
- accountDialog.TransientFor = parent
- accountDialog.Visible = false
-
- def Run() as ResponseType:
- return cast(ResponseType, accountDialog.Run())
-
- def SetData():
- ac as Account
- if App.Conf.Accounts.Count < 1:
- ac = Account()
- ac.UserName = System.Environment.UserName
- ac.HostName = "jabber.org"
- ac.Resource = "Piorun"
- ac.Priority = 0
- ac.Port = 5222
- ac.UseTls = true
- ac.OldTls = false
- FillAccount(ac)
- else:
- jids = array(string, App.Conf.Accounts.Count)
- for i as int in range(0, App.Conf.Accounts.Count):
- ac = App.Conf.Accounts[i] as Account
- jids[i] = ac.UserName +"@"+ ac.HostName
- jidCombo.PopdownStrings = jids
- jidCombo.DisableActivate ()
- FillAccount(App.Conf.Accounts[0] as Account)
-
- def FillAccount(a as Account):
- if a.Password != null:
- passwordEntry.Text = a.Password
- SavePasswordCheckButton.Active = true
- else:
- passwordEntry.Text = a.Password
- SavePasswordCheckButton.Active = false
- portSpinButton.Value = a.Port
- prioritySpinButton.Value = a.Priority
- serverEntry.Text = a.Server
- resourceEntry.Text = a.Resource
- useTlsCheckButton.Active = a.UseTls
- oldTlsCheckButton.Active = a.OldTls
- defPriorityCheckButton.Active = (prioritySpinButton.Value == 0)
- if oldTlsCheckButton.Active:
- defPortCheckButton.Active = (portSpinButton.Value == 5223)
- else:
- defPortCheckButton.Active = (portSpinButton.Value == 5222)
-
- def GetData(a as Account):
- a.UserName = Jid.User(jidCombo.Entry.Text)
- a.HostName = Jid.Host(jidCombo.Entry.Text)
- a.Password = passwordEntry.Text
- a.Resource = resourceEntry.Text
- a.Priority = cast(int, prioritySpinButton.Value)
- a.Server = serverEntry.Text
- a.Port = cast(int, portSpinButton.Value)
- a.UseTls = useTlsCheckButton.Active
- a.OldTls = oldTlsCheckButton.Active
-
- def OnResponse(o, args as ResponseArgs):
- if RepeatPasswordVisible:
- if NewPasswordVisible:
- first = newPasswordEntry.Text
- else:
- first = passwordEntry.Text
- if first != repeatPasswordEntry.Text:
- MessageDialog(accountDialog, Gtk.DialogFlags.DestroyWithParent, \
- Gtk.MessageType.Error, Gtk.ButtonsType.Close, \
- "Repeated password do not match")
- return
- accountDialog.Hide()
-
- def OldTlsToggled(o, args as EventArgs):
- useTlsCheckButton.Sensitive = not oldTlsCheckButton.Active
-
- def SelectionChanged(o, args as EventArgs):
- for ac as Account in App.Conf.Accounts:
- if jidCombo.Entry.Text.CompareTo(ac.UserName +"@"+ ac.HostName)==0:
- FillAccount(ac)
- return
-
- def OnOldTlsToggled(o, args as EventArgs):
- if defPortCheckButton.Active:
- if oldTlsCheckButton.Active:
- portSpinButton.Value = 5223
- else:
- portSpinButton.Value = 5222
-
- def OnDefaultPortToggled(o, args as EventArgs):
- if defPortCheckButton.Active:
- if oldTlsCheckButton.Active:
- portSpinButton.Value = 5223
- else:
- portSpinButton.Value = 5222
- portSpinButton.Sensitive = not defPortCheckButton.Active
-
- def OnDefaultPriorityToggled(o, args as EventArgs):
- if defPriorityCheckButton.Active:
- prioritySpinButton.Value = 0
- prioritySpinButton.Sensitive = not defPriorityCheckButton.Active

=== renamed file 'src/actions/AccountActions.boo' => 'src/Account.boo'
--- a/src/actions/AccountActions.boo 2007-11-25 22:25:46 +0000
+++ b/src/Account.boo 2008-01-01 21:02:45 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2006 Dominik Zablotny <do...@sztorm.net>
+# Copyright (c) 2006-2008 Dominik Zablotny <do...@sztorm.net>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
# software and associated documentation files (the "Software"), to deal in the Software
@@ -19,11 +19,26 @@
namespace Piorun

import Gtk
+import Glade
import Piorun.Xmpp
import System
import System.Diagnostics
import System.IO

+class Account:
+ public HostName = ""
+ public UserName = ""
+ public Password = ""
+
+ public Resource = ""
+ public Server = "" # "real" DNS host name
+ public Port as int = 5222
+ public Priority as int = 0
+ public UseTls = true
+ public OldTls = false
+ public AllowUnsafe = true
+ public LastUsed = DateTime.Now
+
class AccountActions(ActionGroup):

session as Session
@@ -95,3 +110,149 @@
def OnAccountRegister(o, args as EventArgs):
pass

+
+class AccountDialog:
+
+ [Widget] accountDialog as Gtk.Dialog
+ [Widget] passwordEntry as Gtk.Entry
+ [Widget] SavePasswordCheckButton as Gtk.CheckButton
+ [Widget] resourceEntry as Gtk.Entry
+ [Widget] prioritySpinButton as Gtk.SpinButton
+ [Widget] serverEntry as Gtk.Entry
+ [Widget] portSpinButton as Gtk.SpinButton
+ [Widget] useTlsCheckButton as Gtk.CheckButton
+ [Widget] oldTlsCheckButton as Gtk.CheckButton
+ [Widget] defPriorityCheckButton as Gtk.CheckButton
+ [Widget] defPortCheckButton as Gtk.CheckButton
+ [Widget] advExpander as Expander
+ [Widget] jidCombo as Gtk.Combo
+
+ [Widget] newPasswordEntry as Gtk.Entry
+ [Widget] repeatPasswordEntry as Gtk.Entry
+ [Widget] newPasswordLabel as Gtk.Label
+ [Widget] repeatPasswordLabel as Gtk.Label
+
+ [property(NewPassword)] newPassword as string
+
+ SavePassword as bool:
+ get:
+ return SavePasswordCheckButton.Active
+
+ _newPasswordVisible = false
+ NewPasswordVisible:
+ get:
+ return _newPasswordVisible
+ set:
+ newPasswordEntry.Visible = value
+ newPasswordLabel.Visible = value
+ _newPasswordVisible = value
+
+ _repeatPasswordVisible = false
+ RepeatPasswordVisible:
+ get:
+ return _repeatPasswordVisible
+ set:
+ repeatPasswordEntry.Visible = value
+ repeatPasswordLabel.Visible = value
+ _newPasswordVisible = value
+
+ def constructor(parent as Window):
+ gxml = Glade.XML.FromAssembly("piorun.glade","accountDialog", null)
+ gxml.Autoconnect(self)
+ advExpander.Expanded = false # must be before showing
+ accountDialog.TransientFor = parent
+ accountDialog.Visible = false
+ SetData()
+
+ def Run() as ResponseType:
+ return cast(ResponseType, accountDialog.Run())
+
+ def SetData():
+ ac as Account
+ if App.Accounts.Length < 1:
+ ac = Account()
+ ac.UserName = System.Environment.UserName
+ ac.HostName = "jabber.org"
+ ac.Resource = "Piorun"
+ ac.Priority = 0
+ ac.Port = 5222
+ ac.UseTls = true
+ ac.OldTls = false
+ FillAccount(ac)
+ else:
+ jids = a.UserName +"@"+ a.HostName for a in App.Accounts
+ jidCombo.PopdownStrings = array(string, jids)
+ jidCombo.DisableActivate()
+ FillAccount(App.Accounts[0] as Account)
+
+ def FillAccount(a as Account):
+ if a.Password != null:
+ passwordEntry.Text = a.Password
+ SavePasswordCheckButton.Active = true
+ else:
+ passwordEntry.Text = a.Password
+ SavePasswordCheckButton.Active = false
+ portSpinButton.Value = a.Port
+ prioritySpinButton.Value = a.Priority
+ serverEntry.Text = a.Server
+ resourceEntry.Text = a.Resource
+ useTlsCheckButton.Active = a.UseTls
+ oldTlsCheckButton.Active = a.OldTls
+ defPriorityCheckButton.Active = (prioritySpinButton.Value == 0)
+ if oldTlsCheckButton.Active:
+ defPortCheckButton.Active = (portSpinButton.Value == 5223)
+ else:
+ defPortCheckButton.Active = (portSpinButton.Value == 5222)
+
+ def GetData(a as Account):
+ a.UserName = Jid.User(jidCombo.Entry.Text)
+ a.HostName = Jid.Host(jidCombo.Entry.Text)
+ a.Password = passwordEntry.Text
+ a.Resource = resourceEntry.Text
+ a.Priority = cast(int, prioritySpinButton.Value)
+ a.Server = serverEntry.Text
+ a.Port = cast(int, portSpinButton.Value)
+ a.UseTls = useTlsCheckButton.Active
+ a.OldTls = oldTlsCheckButton.Active
+
+ def OnResponse(o, args as ResponseArgs):
+ if RepeatPasswordVisible:
+ if NewPasswordVisible:
+ first = newPasswordEntry.Text
+ else:
+ first = passwordEntry.Text
+ if first != repeatPasswordEntry.Text:
+ MessageDialog(accountDialog, Gtk.DialogFlags.DestroyWithParent, \
+ Gtk.MessageType.Error, Gtk.ButtonsType.Close, \
+ "Repeated password do not match")
+ return
+ accountDialog.Hide()
+
+ def OldTlsToggled(o, args as EventArgs):
+ useTlsCheckButton.Sensitive = not oldTlsCheckButton.Active
+
+ def SelectionChanged(o, args as EventArgs):
+ for ac as Account in App.Accounts:
+ if jidCombo.Entry.Text.CompareTo(ac.UserName +"@"+ ac.HostName)==0:
+ FillAccount(ac)
+ return
+
+ def OnOldTlsToggled(o, args as EventArgs):
+ if defPortCheckButton.Active:
+ if oldTlsCheckButton.Active:
+ portSpinButton.Value = 5223
+ else:
+ portSpinButton.Value = 5222
+
+ def OnDefaultPortToggled(o, args as EventArgs):
+ if defPortCheckButton.Active:
+ if oldTlsCheckButton.Active:
+ portSpinButton.Value = 5223
+ else:
+ portSpinButton.Value = 5222
+ portSpinButton.Sensitive = not defPortCheckButton.Active
+
+ def OnDefaultPriorityToggled(o, args as EventArgs):
+ if defPriorityCheckButton.Active:
+ prioritySpinButton.Value = 0
+ prioritySpinButton.Sensitive = not defPriorityCheckButton.Active

=== modified file 'Piorun.mdp'
--- a/Piorun.mdp 2007-11-25 22:25:46 +0000
+++ b/Piorun.mdp 2008-01-01 21:02:45 +0000
@@ -18,7 +18,6 @@
<File name="src/Piorun.boo" subtype="Code" buildaction="Compile" />
<File name="src/widgets" subtype="Directory" buildaction="Compile" />
<File name="src/Contact.boo" subtype="Code" buildaction="Compile" />
- <File name="src/dialogs/AccountDialog.boo" subtype="Code" buildaction="Compile" />
<File name="src/dialogs/StatusDialog.boo" subtype="Code" buildaction="Compile" />
<File name="src/dialogs/PreferencesDialog.boo" subtype="Code" buildaction="Compile" />
<File name="src/dialogs/SubscrDialog.boo" subtype="Code" buildaction="Compile" />
@@ -62,7 +61,6 @@
<File name="src/SystemContact.boo" subtype="Code" buildaction="Compile" />
<File name="res/ui.xml" subtype="Code" buildaction="EmbedAsResource" />
<File name="src/actions" subtype="Directory" buildaction="Compile" />
- <File name="src/actions/AccountActions.boo" subtype="Code" buildaction="Compile" />
<File name="src/actions/HelpActions.boo" subtype="Code" buildaction="Compile" />
<File name="src/actions/EditActions.boo" subtype="Code" buildaction="Compile" />
<File name="src/actions/ContactActions.boo" subtype="Code" buildaction="Compile" />
@@ -91,6 +89,7 @@
<File name="doc/piorun.uml" subtype="Code" buildaction="Nothing" />
<File name="src/Database.boo" subtype="Code" buildaction="Compile" />
<File name="src/Main.boo" subtype="Code" buildaction="Compile" />
+ <File name="src/Account.boo" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System.Xml, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

=== modified file 'res/ui.xml'
--- a/res/ui.xml 2008-01-01 02:09:47 +0000
+++ b/res/ui.xml 2008-01-01 21:02:45 +0000
@@ -78,8 +78,8 @@
</menu>
<menu action="AccountMenu">
<menuitem action="AccountRegister" />
+ <separator />
<menuitem action="AccountUnregister" />
- <separator />
<menuitem action="AccountChangePassword" />
<menuitem action="AccountEditVCard" />
<menu action="PrivacyMenu">

=== modified file 'src/Configuration.boo'
--- a/src/Configuration.boo 2007-11-25 22:25:46 +0000
+++ b/src/Configuration.boo 2008-01-01 21:02:45 +0000
@@ -34,19 +34,6 @@
[Option("Configuration directory", ShortForm: "c")]
public ConfigDir as string

-
-class Account:
- [XmlAttribute] public HostName = ""
- [XmlAttribute] public UserName = ""
- [XmlAttribute] public Password = ""
-
- [XmlAttribute] public Resource = ""
- [XmlAttribute] public Server = "" # "real" DNS host name
- [XmlAttribute] public Port as int = 5222
- [XmlAttribute] public Priority as int = 0
- [XmlAttribute] public UseTls = true
- [XmlAttribute] public OldTls = false
-
class Room:
[XmlAttribute] public HostName = ""
[XmlAttribute] public UserName = ""
@@ -200,8 +187,8 @@
[XmlArray, XmlArrayItem(typeof(Room))]
public RoomHistory= ArrayList() # of Room

- [XmlArray, XmlArrayItem(typeof(Account) )]
- public Accounts = ArrayList() # of Account
+# [XmlArray, XmlArrayItem(typeof(Account) )]
+# public Accounts = ArrayList() # of Account

def constructor():
pass

=== modified file 'src/Database.boo'
--- a/src/Database.boo 2008-01-01 02:09:47 +0000
+++ b/src/Database.boo 2008-01-01 21:02:45 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2005-2007 Dominik Zablotny <do...@sztorm.net>
+# Copyright (c) 2005-2008 Dominik Zablotny <do...@sztorm.net>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
# software and associated documentation files (the "Software"), to deal in the Software
@@ -38,15 +38,16 @@
Version = 1

newFile as bool
- connection as IDbConnection
+ connection as SqliteConnection

- upgraders = (UpgradeTo1,)
+ upgraders = (UpgradeTo1,)


- def constructor():
- pass
-
- def Init(filename as string):
+ def constructor(filename as string):
+ # temporary code - backups db
+ if File.Exists(filename):
+ File.Copy(filename, filename+'.'+DateTime.Now.ToString('yyyy-MM-dd HH-mm'))
+
# connect
newFile = not File.Exists(filename)
connection = SqliteConnection("URI=file:" + filename)
@@ -91,12 +92,74 @@
drop table if exists certificate;
create table certificate(
id_certificate integer primary key,
- hash text,
+ hash text unique,
raw blob);
+
+ drop table if exists account;
+ create table account(
+ id_account integer primary key,
+ host_name text not null,
+ user_name text not null,
+ password text,
+ resource text,
+ server text,
+ port integer,
+ priority integer,
+ last_used datetime,
+ allow_unsafe integer,
+ old_tls integer,
+ unique(host_name, user_name)
+ );
"""
debug q
ExecuteQuery(q)
-
+
+ def GetAccounts(limit as int) as (Account):
+ q = ' SELECT host_name, user_name, password, resource, server, '+\
+ ' port, priority, last_used, allow_unsafe, old_tls '+\
+ ' FROM account ORDER BY last_used LIMIT ? '
+ accounts = (List of Account)()
+ plimit = SqliteParameter(Value: limit)
+ using cmd = connection.CreateCommand():
+ cmd.CommandText = q
+ cmd.Parameters.Add(plimit)
+ using reader = cmd.ExecuteReader() as SqliteDataReader:
+ while reader.Read():
+ a = Account()
+ a.HostName = reader.GetString(0)
+ a.UserName = reader.GetString(1)
+ a.Password = reader.GetString(2)
+ a.Resource = reader.GetString(3)
+ a.Server = reader.GetString(4)
+ a.Port = reader.GetInt32(5)
+ a.Priority = reader.GetInt32(6)
+ a.LastUsed = DateTime.FromFileTime(reader.GetInt64(7))
+ a.AllowUnsafe = reader.GetInt32(8) > 0
+ a.OldTls = reader.GetInt32(9) > 0
+ accounts.Add(a)
+ return accounts.ToArray()
+
+ def SaveAccount(a as Account):
+ """ add or update """
+ q = 'INSERT OR REPLACE INTO '+\
+ ' account(host_name, user_name, password, resource, '+\
+ ' server, port, priority, last_used, allow_unsafe, old_tls)'+\
+ 'VALUES (?,?,?,?,?,?,?,?,?,?)'
+ using cmd = connection.CreateCommand():
+ cmd.CommandText = q
+ p=( SqliteParameter(Value: a.HostName),
+ SqliteParameter(Value: a.UserName),
+ SqliteParameter(Value: a.Password),
+ SqliteParameter(Value: a.Resource),
+ SqliteParameter(Value: a.Server),
+ SqliteParameter(Value: a.Port),
+ SqliteParameter(Value: a.Priority),
+ SqliteParameter(Value: a.LastUsed.ToFileTime()),
+ SqliteParameter(Value: Convert.ToInt32(a.AllowUnsafe)),
+ SqliteParameter(Value: Convert.ToInt32(a.OldTls)))
+ cmd.Parameters.AddRange(p)
+ cmd.ExecuteNonQuery()
+
def Esc(s as string) as string:
return s.Replace("'", "''")

@@ -152,12 +215,9 @@
if not HasCertificate(hash):
using cmd = connection.CreateCommand():
cmd.CommandText = 'INSERT INTO certificate(hash, raw) VALUES(?, ?)'
- phash = cmd.CreateParameter()
- praw = cmd.CreateParameter()
- cmd.Parameters.Add(phash)
- cmd.Parameters.Add(praw)
- phash.Value = hash
- praw.Value = raw
+ p = ( SqliteParameter(Value:hash),
+ SqliteParameter(Value:raw) )
+ cmd.Parameters.AddRange(p)
cmd.ExecuteNonQuery()

def DelCertificate(hash as string):
@@ -193,24 +253,25 @@
certificates = (List of (byte))()
using cmd = connection.CreateCommand():
cmd.CommandText = 'SELECT raw FROM certificate'
- using reader = cmd.ExecuteReader() as SqliteDataReader:
+ using reader = cmd.ExecuteReader():
while reader.Read():
certificates.Add(reader.GetValue(0) as (byte))
return certificates.ToArray()

def ExecuteQuery(q as string) as int:
""" Execute a Query without any return results """
- using cmd = connection.CreateCommand() as SqliteCommand:
+ using cmd = connection.CreateCommand():
cmd.CommandText = q
cmd.ExecuteNonQuery()
return cmd.LastInsertRowID()

def Read(q as string) as IDataReader:
- using cmd = connection.CreateCommand() as SqliteCommand:
+ using cmd = connection.CreateCommand():
cmd.CommandText = q
return cmd.ExecuteReader()

- private def GetVersion() as int:
+ private \
+ def GetVersion() as int:
""" For empty database returns 0 """
q = "select db_version from info"
using cmd = connection.CreateCommand():

=== modified file 'src/Piorun.boo'
--- a/src/Piorun.boo 2008-01-01 02:09:47 +0000
+++ b/src/Piorun.boo 2008-01-01 21:02:45 +0000
@@ -51,6 +51,11 @@
History:
get: return history

+ accounts as (Account)
+ Accounts:
+ get:
+ return accounts
+
[getter(Sep)] sep = Path.DirectorySeparatorChar
[getter(CmdLine)] cmdLine as CommandLine
[getter(Conf)] conf as Piorun.Configuration
@@ -106,6 +111,8 @@
Gtk.Application.Quit()
# Environment.Exit(0)

+ def ReloadAccounts():
+ accounts = self.Database.GetAccounts(Conf.AccountHistoryMax.Value)


def Init(argv as (string)):
@@ -133,9 +140,9 @@
Tags.TimestampsVisible = Conf.ShowTimestamps.Value
Conf.ShowTimestamps.Changed += { Tags.TimestampsVisible = Conf.ShowTimestamps.Value }

- database = Database()
- database.Init(ConfigDirName + Sep + "data.sqlite")
+ database = Database(ConfigDirName + Sep + "data.sqlite")
history = History()
+ ReloadAccounts()

# display main window
AddSession(null)

=== modified file 'src/Session.boo'
--- a/src/Session.boo 2007-12-30 22:30:41 +0000
+++ b/src/Session.boo 2008-01-01 21:02:45 +0000
@@ -43,8 +43,6 @@
get:
return client

-
-
# null account means that window is "blank", uninitialized
# and any new connection will be opened right in this window
[property(Account)] account as Account

=== modified file 'src/actions/SessionActions.boo'
--- a/src/actions/SessionActions.boo 2007-11-25 22:25:46 +0000
+++ b/src/actions/SessionActions.boo 2008-01-01 21:02:45 +0000
@@ -167,34 +167,24 @@

def SaveAccount(a as Account):
""" Saves account settings in the list """
- i = 0
- a2 as Account
- while i < App.Conf.Accounts.Count:
- a2 = App.Conf.Accounts[i] as Account
- if a.UserName == a2.UserName and a.HostName == a2.HostName:
- App.Conf.Accounts.Remove(a2)
- else:
- i++
- max = App.Conf.AccountHistoryMax.Value
- App.Conf.Accounts.Insert(0, a)
- if App.Conf.Accounts.Count > max:
- App.Conf.Accounts.RemoveRange(max, App.Conf.Accounts.Count-max)
+ a.LastUsed = DateTime.Now
+ App.Database.SaveAccount(a)
+ App.ReloadAccounts()

def OnNewActivated(o, args as EventArgs):
a = Account()
- accountDialog = AccountDialog(session)
- accountDialog.SetData()
- if accountDialog.Run() != ResponseType.Ok:
- return
- accountDialog.GetData(a)
- App.FlushMainLoop()
- if session.Account:
- App.AddSession(a)
- else:
- session.Account = a
- LogIn(a)
- if not accountDialog.SavePassword: a.Password = null
- SaveAccount(a)
+ using accountDialog = AccountDialog(session):
+ if accountDialog.Run() != ResponseType.Ok:
+ return
+ accountDialog.GetData(a)
+ App.FlushMainLoop()
+ if session.Account:
+ App.AddSession(a)
+ else:
+ session.Account = a
+ LogIn(a)
+ if not accountDialog.SavePassword: a.Password = null
+ SaveAccount(a)

def OnConnectedToggled(o, args as EventArgs):
if connectedIgnore:

--

https://code.launchpad.net/~piorun/piorun/devel

You are receiving this branch notification because you are subscribed to it.

Reply all
Reply to author
Forward
0 new messages