~cszikszoy/do-plugins/pastebin

« back to all changes in this revision

Viewing changes to Tomboy/src/TomboyDBus.cs

* Cleanup Tomboy.
* Add Firefox.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//  TomboyItems.cs
 
1
//  TomboyDBus.cs
2
2
//
3
3
//  GNOME Do is the legal property of its developers, whose names are too numerous
4
4
//  to list here.  Please refer to the COPYRIGHT file distributed with this
7
7
//  This program is free software: you can redistribute it and/or modify
8
8
//  it under the terms of the GNU General Public License as published by
9
9
//  the Free Software Foundation, either version 3 of the License, or
10
 
//  (at your option) any later version.
 
10
//   (at your option) any later version.
11
11
//
12
12
//  This program is distributed in the hope that it will be useful,
13
13
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
24
24
 
25
25
namespace Tomboy
26
26
{
27
 
        [Interface("org.gnome.Tomboy.RemoteControl")]
 
27
        [Interface ("org.gnome.Tomboy.RemoteControl")]
28
28
        public interface ITBoy
29
29
        {
30
 
            string CreateNote();
31
 
                string CreateNamedNote(string linked_title);
32
 
                bool DisplayNote(string uri);
33
 
                void DisplaySearch();   
34
 
                string FindNote(string title);
35
 
                long GetNoteChangeDate(string uri);
36
 
                string GetNoteTitle(string uri);
37
 
                string[] ListAllNotes();
38
 
                void DisplaySearchWithText(string search_text);
39
 
                string Version();
 
30
            string CreateNote ();
 
31
                string CreateNamedNote (string linked_title);
 
32
                bool DisplayNote (string uri);
 
33
                void DisplaySearch ();  
 
34
                string FindNote (string title);
 
35
                long GetNoteChangeDate (string uri);
 
36
                string GetNoteTitle (string uri);
 
37
                string[] ListAllNotes ();
 
38
                void DisplaySearchWithText (string search_text);
 
39
                string Version ();
40
40
        }
41
41
        
42
42
        class TomboyDBus        
46
46
                
47
47
                private static ITBoy TomboyInstance = null;
48
48
 
49
 
                static private ITBoy FindInstance() {
 
49
                static private ITBoy FindInstance () {
50
50
                        // try to start the service by default
51
 
                        Bus.Session.StartServiceByName(BUS_NAME);
52
 
 
53
 
                        if (!Bus.Session.NameHasOwner(BUS_NAME))
54
 
                    throw new Exception(String.Format("Name {0} has no owner", BUS_NAME));
55
 
 
56
 
                return Bus.Session.GetObject<ITBoy>(BUS_NAME, new ObjectPath (OBJECT_PATH));
 
51
                        Bus.Session.StartServiceByName (BUS_NAME);
 
52
 
 
53
                        if  (!Bus.Session.NameHasOwner (BUS_NAME))
 
54
                    throw new Exception (String.Format ("Name {0} has no owner", BUS_NAME));
 
55
 
 
56
                return Bus.Session.GetObject<ITBoy> (BUS_NAME, new ObjectPath  (OBJECT_PATH));
57
57
            }
58
58
                
59
 
                public TomboyDBus() {
 
59
                public TomboyDBus () {
60
60
                        
61
61
                        try {
62
 
                    TomboyInstance = FindInstance();
63
 
                } catch(Exception) {
64
 
                    Console.Error.WriteLine("Could not locate Tomboy on D-Bus. Perhaps it's not running?");
 
62
                    TomboyInstance = FindInstance ();
 
63
                } catch (Exception) {
 
64
                    Console.Error.WriteLine ("Could not locate Tomboy on D-Bus. Perhaps it's not running?");
65
65
                }
66
66
                
67
 
                BusG.Init();
68
 
                        //Console.WriteLine("Tomboy Version: {0}", TomboyInstance.Version());                   
 
67
                BusG.Init ();
 
68
                        //Console.WriteLine ("Tomboy Version: {0}", TomboyInstance.Version ());                 
69
69
                }
70
70
                
71
 
                public ArrayList GetAllNoteTitles() {
 
71
                public ArrayList GetAllNoteTitles () {
72
72
                        string[] AllNotes = null;
73
 
                        AllNotes = TomboyInstance.ListAllNotes();
74
 
                        ArrayList AllNoteTitles = new ArrayList();
 
73
                        AllNotes = TomboyInstance.ListAllNotes ();
 
74
                        ArrayList AllNoteTitles = new ArrayList ();
75
75
                        
76
 
                        foreach(string Uri in AllNotes) {
77
 
                                AllNoteTitles.Add(TomboyInstance.GetNoteTitle(Uri));
 
76
                        foreach (string Uri in AllNotes) {
 
77
                                AllNoteTitles.Add (TomboyInstance.GetNoteTitle (Uri));
78
78
                        }
79
79
                        
80
80
                        return AllNoteTitles;
81
81
                }
82
82
                
83
 
                public long GetNoteChangedDate(string note_title) {
84
 
                        string note_uri = TomboyInstance.FindNote(note_title);
 
83
                public long GetNoteChangedDate (string note_title) {
 
84
                        string note_uri = TomboyInstance.FindNote (note_title);
85
85
                        try {
86
 
                                return TomboyInstance.GetNoteChangeDate(note_uri);
87
 
                        } catch (Exception) {
88
 
                    Console.Error.WriteLine("Could not find changed date for: {0}", note_title);
 
86
                                return TomboyInstance.GetNoteChangeDate (note_uri);
 
87
                        } catch  (Exception) {
 
88
                    Console.Error.WriteLine ("Could not find changed date for: {0}", note_title);
89
89
                        }
90
90
                        return 0;
91
91
                }
92
92
                
93
 
                public void OpenNote(string note_title) {
94
 
                        string note_uri = TomboyInstance.FindNote(note_title);
 
93
                public void OpenNote (string note_title) {
 
94
                        string note_uri = TomboyInstance.FindNote (note_title);
95
95
                        try {
96
 
                                TomboyInstance.DisplayNote(note_uri);
97
 
                        } catch (Exception) {
98
 
                    Console.Error.WriteLine("Could not open the note: {0}", note_title);
 
96
                                TomboyInstance.DisplayNote (note_uri);
 
97
                        } catch  (Exception) {
 
98
                    Console.Error.WriteLine ("Could not open the note: {0}", note_title);
99
99
                        }
100
100
                }
101
101
                
102
102
                /// <summary>
103
103
                /// Currently not used
104
104
                /// </summary>
105
 
                public void OpenSearch() {
106
 
                        TomboyInstance.DisplaySearch();
 
105
                public void OpenSearch () {
 
106
                        TomboyInstance.DisplaySearch ();
107
107
                }
108
108
 
109
109
                /// <summary>
112
112
                /// <returns>
113
113
                /// A <see cref="System.String"/>
114
114
                /// </returns>
115
 
                public string CreateNewNote() {
116
 
                        string uri = TomboyInstance.CreateNote();
117
 
                        TomboyInstance.DisplayNote(uri);
 
115
                public string CreateNewNote () {
 
116
                        string uri = TomboyInstance.CreateNote ();
 
117
                        TomboyInstance.DisplayNote (uri);
118
118
                        return uri;
119
119
                }
120
120
                
127
127
                /// <returns>
128
128
                /// A <see cref="System.String"/>
129
129
                /// </returns>
130
 
                public string CreateNewNote(string note_title) {
131
 
                        string uri = TomboyInstance.CreateNamedNote(note_title);
132
 
                        TomboyInstance.DisplayNote(uri);
 
130
                public string CreateNewNote (string note_title) {
 
131
                        string uri = TomboyInstance.CreateNamedNote (note_title);
 
132
                        TomboyInstance.DisplayNote (uri);
133
133
                        return uri;
134
134
                }
135
135
                
139
139
                /// <param name="search_text">
140
140
                /// A <see cref="System.String"/>
141
141
                /// </param>
142
 
                public void SearchNotes(string search_text) {
143
 
                        TomboyInstance.DisplaySearchWithText(search_text);
 
142
                public void SearchNotes (string search_text) {
 
143
                        TomboyInstance.DisplaySearchWithText (search_text);
144
144
                }
145
145
                
146
146
        }