src_moonshot_SOURCES = \
src/moonshot-identity-manager-app.vala \
+ src/moonshot-identity-management-view.vala \
src/moonshot-local-flat-file-store.vala \
src/moonshot-idcard-store.vala \
src/moonshot-id.vala \
src/moonshot-identities-manager.vala \
src/moonshot-identity-request.vala \
src/moonshot-server.vala \
- src/moonshot-window.vala \
src/moonshot-password-dialog.vala \
src/moonshot-utils.vala
class CustomVBox : VBox
{
public IdCardWidget current_idcard { get; set; default = null; }
- private MainWindow main_window;
+ private IdentityManagerView main_window;
- public CustomVBox (MainWindow window, bool homogeneous, int spacing)
+ public CustomVBox (IdentityManagerView window, bool homogeneous, int spacing)
{
main_window = window;
set_homogeneous (homogeneous);
public interface IIdentityCardStore : Object {
- // Methods
- public abstract void add_card(IdCard card);
- public abstract void remove_card(IdCard card);
- public abstract SList<IdCard> get_card_list();
- public signal void CardListChanged();
+ // Methods
+ public abstract void add_card(IdCard card);
+ public abstract void remove_card(IdCard card);
+ public abstract void update_card(IdCard card);
+ public abstract SList<IdCard> get_card_list();
+ public signal void card_list_changed();
}
-class IdentitiesManager : Object {
+class IdentityManagerModel : Object {
public SList<IdCard> id_card_list;
+ public SList<IdCard> get_card_list() {
+ return id_card_list.copy();
+ }
+ public signal void card_list_changed();
+
private const string FILE_NAME = "identities.txt";
+ private IdentityManagerApp parent;
- public IdentitiesManager ()
+ public IdentityManagerModel(IdentityManagerApp parent_app)
{
+ print("IdentityManagerModel()\n");
+ parent = parent_app;
id_card_list = new SList<IdCard>();
var key_file = new KeyFile ();
-
var path = get_data_dir ();
var filename = Path.build_filename (path, FILE_NAME);
-
try
{
key_file.load_from_file (filename, KeyFileFlags.NONE);
using Gtk;
class IdentityManagerApp : Window {
- private MainWindow main_window;
-
+ public IdentityManagerModel model;
+ private IdentityManagerView view;
+ private MoonshotServer ipc_server;
+ private const int WINDOW_WIDTH = 400;
+ private const int WINDOW_HEIGHT = 500;
+
public IdentityManagerApp () {
- main_window = new MainWindow();
- main_window.show();
- }
+ model = new IdentityManagerModel(this);
+ view = new IdentityManagerView(this);
+ init_ipc_server ();
+ view.show();
+ }
-/* public int run(string[] args){
- GLib.Application.run(args);
- }*/
- public static int main(string[] args)
+
+#if IPC_MSRPC
+ private void init_ipc_server ()
+ {
+ // Errors will currently be sent via g_log - ie. to an
+ // obtrusive message box, on Windows
+ //
+ this.ipc_server = MoonshotServer.get_instance ();
+ MoonshotServer.start (this.view);
+ }
+#elif IPC_DBUS_GLIB
+ private void init_ipc_server ()
{
+ try {
+ var conn = DBus.Bus.get (DBus.BusType.SESSION);
+ dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus",
+ "/org/freedesktop/DBus",
+ "org.freedesktop.DBus");
+
+ // try to register service in session bus
+ uint reply = bus.request_name ("org.janet.Moonshot", (uint) 0);
+ assert (reply == DBus.RequestNameReply.PRIMARY_OWNER);
+
+ this.ipc_server = new MoonshotServer (this.view);
+ conn.register_object ("/org/janet/moonshot", ipc_server);
+ }
+ catch (DBus.Error e)
+ {
+ stderr.printf ("%s\n", e.message);
+ }
+ }
+#else
+ private void bus_acquired_cb (DBusConnection conn)
+ {
+ try {
+ conn.register_object ("/org/janet/moonshot", ipc_server);
+ }
+ catch (Error e)
+ {
+ stderr.printf ("%s\n", e.message);
+ }
+ }
+
+ private void init_ipc_server ()
+ {
+ this.ipc_server = new MoonshotServer (this.view);
+ GLib.Bus.own_name (GLib.BusType.SESSION,
+ "org.janet.Moonshot",
+ GLib.BusNameOwnerFlags.NONE,
+ bus_acquired_cb,
+ (conn, name) => {},
+ (conn, name) => {
+ error ("Couldn't own name %s on DBus.", name);
+ });
+ }
+#endif
+}
+
+
+public static int main(string[] args){
Gtk.init(ref args);
#if OS_WIN32
Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain (Config.GETTEXT_PACKAGE);
-
+
var app = new IdentityManagerApp();
-// app.show();
-
+ app.show();
+
Gtk.main();
return 0;
}
-}
public bool complete = false;
public bool select_default = false;
- private MainWindow main_window;
+ private IdentityManagerView main_window;
public string nai;
public string password;
public string service;
ReturnIdentityCallback callback = null;
- public IdentityRequest (MainWindow main_window,
+ public IdentityRequest (IdentityManagerView main_window,
string nai,
string password,
string service)
this.service = service;
}
- public IdentityRequest.default (MainWindow main_window)
+ public IdentityRequest.default (IdentityManagerView main_window)
{
this.main_window = main_window;
this.select_default = true;
public void add_card(IdCard card) {
}
+ public void update_card(IdCard card) {
+ }
+
public void remove_card(IdCard card) {
}
[DBus (name = "org.janet.Moonshot")]
public class MoonshotServer : Object {
- private MainWindow main_window;
+ private IdentityManagerView main_window;
public MoonshotServer (Gtk.Window window)
{
- this.main_window = (MainWindow) window;
+ this.main_window = (IdentityManagerView) window;
}
public async bool get_identity (string nai,
* process ends
*/
public class MoonshotServer : Object {
- private static MainWindow main_window;
+ private static IdentityManagerView main_window;
private static MoonshotServer instance = null;
public static void start (Gtk.Window window)
{
- main_window = (MainWindow) window;
+ main_window = (IdentityManagerView) window;
Rpc.server_start (MoonshotRpcInterface.spec, "/org/janet/Moonshot", Rpc.Flags.PER_USER);
}
private ListStore listmodel;
private TreeModelFilter filter;
- public IdentitiesManager identities_manager;
+ public IdentityManagerModel identities_manager;
private SList<IdCard> candidates;
- private MoonshotServer ipc_server;
+// private MoonshotServer ipc_server;
private IdCard default_id_card;
public Queue<IdentityRequest> request_queue;
setup_identities_list();
load_id_cards();
connect_signals();
- init_ipc_server();
+ // init_ipc_server();
}
public void add_candidate (IdCard idcard)
private void load_id_cards ()
{
- identities_manager = new IdentitiesManager ();
+ // identities_manager = new IdentityManagerModel();
if (identities_manager.id_card_list == null)
return;
{
this.destroy.connect (Gtk.main_quit);
}
-
+/*
#if IPC_MSRPC
private void init_ipc_server ()
{
- /* Errors will currently be sent via g_log - ie. to an
- * obtrusive message box, on Windows
- */
+ // Errors will currently be sent via g_log - ie. to an
+ // obtrusive message box, on Windows
+ //
this.ipc_server = MoonshotServer.get_instance ();
MoonshotServer.start (this);
}
});
}
#endif
-
+*/
}