~simonschneegans/do-plugins/grooveshark

« back to all changes in this revision

Viewing changes to Opera/src/OperaBookmarkItemSource.cs

  • Committer: Robert Dyer
  • Date: 2009-11-23 15:18:44 UTC
  • Revision ID: psybers@gmail.com-20091123151844-hmmyg01gqiy5dstv
index Opera bookmarks for all versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
                }
26
26
 
27
27
                public override string Description { 
28
 
                        get { return AddinManager.CurrentLocalizer.GetString ("Indexes your Opera 6 bookmarks"); } 
 
28
                        get { return AddinManager.CurrentLocalizer.GetString ("Indexes your Opera bookmarks"); } 
29
29
                }
30
30
 
31
31
                public override string Icon { 
42
42
                public override void UpdateItems ()
43
43
                {
44
44
                        string home = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
45
 
                        string path = "~/.opera/opera6.adr".Replace ("~", home);
 
45
                        string[] paths = {"~/.opera/opera6.adr".Replace ("~", home),
 
46
                                                        "~/.opera/bookmarks.adr".Replace ("~", home)};
46
47
                        
47
48
                        items.Clear();
48
 
                        try {
49
 
                                using (StreamReader streamReader = new StreamReader (path)) {
50
 
                                        string strName;
51
 
                                        string strURL;
52
 
                                        while((strName = streamReader.ReadLine ()) != null) {
53
 
                                                if (!strName.Contains ("NAME")) continue;
54
 
 
55
 
                                                strURL = streamReader.ReadLine ();
56
 
 
57
 
                                                if (string.IsNullOrEmpty (strURL) || !strURL.Contains ("URL")) continue;
58
 
 
59
 
                                                strName = strName.Replace ("NAME=", "");
60
 
                                                strURL = strURL.Replace ("URL=", "");
61
 
                                                items.Add (new BookmarkItem (strName, strURL));                                         
 
49
                        foreach (string path in paths) {
 
50
                                if (File.Exists (path)) {
 
51
                                        try {
 
52
                                                using (StreamReader streamReader = new StreamReader (path)) {
 
53
                                                        string strName;
 
54
                                                        string strURL;
 
55
                                                        while((strName = streamReader.ReadLine ()) != null) {
 
56
                                                                if (!strName.Contains ("NAME")) continue;
 
57
 
 
58
                                                                strURL = streamReader.ReadLine ();
 
59
 
 
60
                                                                if (string.IsNullOrEmpty (strURL) || !strURL.Contains ("URL")) continue;
 
61
 
 
62
                                                                strName = strName.Replace ("NAME=", "");
 
63
                                                                strURL = strURL.Replace ("URL=", "");
 
64
                                                                items.Add (new BookmarkItem (strName, strURL));                                         
 
65
                                                        }
 
66
                                                }
 
67
                                        } catch (Exception e) {
 
68
                                                Log.Error ("Could not read Opera Bookmarks file {0}: {1}", path, e.Message);
 
69
                                                Log.Debug (e.StackTrace);
62
70
                                        }
63
71
                                }
64
72
                        }
65
 
                        catch (Exception e) {
66
 
                                Log.Error ("Could not read Opera Bookmarks file {0}: {1}", path, e.Message);
67
 
                                Log.Debug (e.StackTrace);
68
 
                        }
69
73
                }
70
74
        }
71
75
}