Changeset View
Changeset View
Standalone View
Standalone View
runners/bookmarks/browsers/firefox.cpp
Show All 28 Lines | |||||
29 | #include "bookmarkmatch.h" | 29 | #include "bookmarkmatch.h" | ||
30 | #include "favicon.h" | 30 | #include "favicon.h" | ||
31 | #include "fetchsqlite.h" | 31 | #include "fetchsqlite.h" | ||
32 | #include "faviconfromblob.h" | 32 | #include "faviconfromblob.h" | ||
33 | 33 | | |||
34 | Firefox::Firefox(QObject *parent) : | 34 | Firefox::Firefox(QObject *parent) : | ||
35 | QObject(parent), | 35 | QObject(parent), | ||
36 | m_favicon(new FallbackFavicon(this)), | 36 | m_favicon(new FallbackFavicon(this)), | ||
37 | m_fetchsqlite(0) | 37 | m_fetchsqlite(nullptr), | ||
38 | m_fetchsqlite_fav(nullptr) | ||||
38 | { | 39 | { | ||
39 | reloadConfiguration(); | 40 | reloadConfiguration(); | ||
40 | //qDebug() << "Loading Firefox Bookmarks Browser"; | 41 | //qDebug() << "Loading Firefox Bookmarks Browser"; | ||
41 | } | 42 | } | ||
42 | 43 | | |||
43 | 44 | | |||
44 | Firefox::~Firefox() | 45 | Firefox::~Firefox() | ||
45 | { | 46 | { | ||
46 | if (!m_dbCacheFile.isEmpty()) { | 47 | if (!m_dbCacheFile.isEmpty()) { | ||
47 | QFile db_CacheFile(m_dbCacheFile); | 48 | QFile db_CacheFile(m_dbCacheFile); | ||
48 | if (db_CacheFile.exists()) { | 49 | if (db_CacheFile.exists()) { | ||
49 | //qDebug() << "Cache file was removed: " << db_CacheFile.remove(); | 50 | //qDebug() << "Cache file was removed: " << db_CacheFile.remove(); | ||
50 | } | 51 | } | ||
51 | } | 52 | } | ||
52 | //qDebug() << "Deleted Firefox Bookmarks Browser"; | 53 | //qDebug() << "Deleted Firefox Bookmarks Browser"; | ||
53 | } | 54 | } | ||
54 | 55 | | |||
55 | void Firefox::prepare() | 56 | void Firefox::prepare() | ||
56 | { | 57 | { | ||
57 | if (m_dbCacheFile.isEmpty()) { | 58 | if (m_dbCacheFile.isEmpty()) { | ||
58 | m_dbCacheFile = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("bookmarkrunnerfirefoxdbfile.sqlite"); | 59 | m_dbCacheFile = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("bookmarkrunnerfirefoxdbfile.sqlite"); | ||
59 | } | 60 | } | ||
61 | if (m_dbCacheFile_fav.isEmpty()) { | ||||
62 | m_dbCacheFile_fav = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/bookmarkrunnerfirefoxfavdbfile.sqlite"); | ||||
63 | } | ||||
60 | if (!m_dbFile.isEmpty()) { | 64 | if (!m_dbFile.isEmpty()) { | ||
61 | m_fetchsqlite = new FetchSqlite(m_dbFile, m_dbCacheFile); | 65 | m_fetchsqlite = new FetchSqlite(m_dbFile, m_dbCacheFile); | ||
62 | m_fetchsqlite->prepare(); | 66 | m_fetchsqlite->prepare(); | ||
67 | } | ||||
68 | if (!m_dbFile_fav.isEmpty()) { | ||||
69 | m_fetchsqlite_fav = new FetchSqlite(m_dbFile_fav, m_dbCacheFile_fav); | ||||
davidedmundson: where does this get deleted? | |||||
z3ntu: Sorry, fixed it. | |||||
70 | m_fetchsqlite_fav->prepare(); | ||||
63 | 71 | | |||
64 | delete m_favicon; | 72 | delete m_favicon; | ||
65 | m_favicon = 0; | 73 | m_favicon = 0; | ||
66 | 74 | | |||
67 | m_favicon = FaviconFromBlob::firefox(m_fetchsqlite, this); | 75 | m_favicon = FaviconFromBlob::firefox(m_fetchsqlite_fav, this); | ||
68 | } | 76 | } | ||
69 | } | 77 | } | ||
70 | 78 | | |||
71 | QList< BookmarkMatch > Firefox::match(const QString& term, bool addEverything) | 79 | QList< BookmarkMatch > Firefox::match(const QString& term, bool addEverything) | ||
72 | { | 80 | { | ||
73 | QList< BookmarkMatch > matches; | 81 | QList< BookmarkMatch > matches; | ||
74 | if (!m_fetchsqlite) { | 82 | if (!m_fetchsqlite) { | ||
75 | return matches; | 83 | return matches; | ||
Show All 31 Lines | |||||
107 | return matches; | 115 | return matches; | ||
108 | } | 116 | } | ||
109 | 117 | | |||
110 | 118 | | |||
111 | void Firefox::teardown() | 119 | void Firefox::teardown() | ||
112 | { | 120 | { | ||
113 | if(m_fetchsqlite) { | 121 | if(m_fetchsqlite) { | ||
114 | m_fetchsqlite->teardown(); | 122 | m_fetchsqlite->teardown(); | ||
123 | } | ||||
124 | if(m_fetchsqlite_fav) { | ||||
125 | m_fetchsqlite_fav->teardown(); | ||||
115 | delete m_favicon; | 126 | delete m_favicon; | ||
116 | m_favicon = 0; | 127 | m_favicon = 0; | ||
117 | } | 128 | } | ||
118 | } | 129 | } | ||
119 | 130 | | |||
120 | 131 | | |||
121 | 132 | | |||
122 | void Firefox::reloadConfiguration() | 133 | void Firefox::reloadConfiguration() | ||
Show All 30 Lines | 140 | if (m_dbFile.isEmpty() || QFile::exists(m_dbFile)) { | |||
153 | if (profilePath.isEmpty()) { | 164 | if (profilePath.isEmpty()) { | ||
154 | //qDebug() << "No default firefox profile found"; | 165 | //qDebug() << "No default firefox profile found"; | ||
155 | return; | 166 | return; | ||
156 | } | 167 | } | ||
157 | //qDebug() << "Profile " << profilePath << " found"; | 168 | //qDebug() << "Profile " << profilePath << " found"; | ||
158 | profilePath.prepend(QStringLiteral("%1/.mozilla/firefox/").arg(QDir::homePath())); | 169 | profilePath.prepend(QStringLiteral("%1/.mozilla/firefox/").arg(QDir::homePath())); | ||
159 | m_dbFile = profilePath + "/places.sqlite"; | 170 | m_dbFile = profilePath + "/places.sqlite"; | ||
160 | grp.writeEntry("dbfile", m_dbFile); | 171 | grp.writeEntry("dbfile", m_dbFile); | ||
172 | m_dbFile_fav = profilePath + "/favicons.sqlite"; | ||||
161 | } | 173 | } | ||
162 | } else { | 174 | } else { | ||
163 | //qDebug() << "SQLITE driver isn't available"; | 175 | //qDebug() << "SQLITE driver isn't available"; | ||
164 | } | 176 | } | ||
165 | } | 177 | } |
where does this get deleted?