35 class KEmoticonsPrivate
40 void loadServiceList();
44 QList<KService::Ptr> m_loaded;
45 QHash<QString, KEmoticonsTheme> m_themes;
50 void themeChanged(
const QString &path);
53 KEmoticonsPrivate::KEmoticonsPrivate(
KEmoticons *parent)
58 KEmoticonsPrivate::~KEmoticonsPrivate()
65 return (s1->property(
"X-KDE-Priority").toInt() > s2->property(
"X-KDE-Priority").toInt());
68 void KEmoticonsPrivate::loadServiceList()
70 QString constraint(
"(exist Library)");
79 kWarning() <<
"Invalid plugin factory for" << service->library();
86 void KEmoticonsPrivate::themeChanged(
const QString &path)
91 if (m_themes.contains(name)) {
98 const int numberOfTheme = m_loaded.size();
99 for (
int i = 0; i < numberOfTheme; ++i) {
100 const QString fName = m_loaded.at(i)->property(
"X-KDE-EmoticonsFileName").toString();
103 if (QFile::exists(path)) {
106 theme.loadTheme(path);
107 m_themes.insert(name, theme);
109 if (!m_dirwatch->contains(path)) {
110 m_dirwatch->addFile(path);
119 : d(new KEmoticonsPrivate(this))
121 d->loadServiceList();
123 connect(d->m_dirwatch, SIGNAL(dirty(
QString)),
this, SLOT(themeChanged(
QString)));
138 if (d->m_themes.contains(name)) {
139 return d->m_themes.value(name);
142 return d->loadTheme(name);
157 for (
int i = 0; i < themeDirs.count(); ++i) {
158 QDir themeQDir(themeDirs[i]);
159 themeQDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
160 themeQDir.setSorting(QDir::Name);
161 ls << themeQDir.entryList();
198 if (localThemesDir.isEmpty()) {
199 kError() <<
"Could not find a suitable place in which to install the emoticon theme";
205 if (currentBundleMimeType ==
"application/zip" ||
206 currentBundleMimeType ==
"application/x-zip" ||
207 currentBundleMimeType ==
"application/x-zip-compressed") {
208 archive =
new KZip(archiveName);
209 }
else if (currentBundleMimeType ==
"application/x-compressed-tar" ||
210 currentBundleMimeType ==
"application/x-bzip-compressed-tar" ||
211 currentBundleMimeType ==
"application/x-lzma-compressed-tar" ||
212 currentBundleMimeType ==
"application/x-xz-compressed-tar" ||
213 currentBundleMimeType ==
"application/x-gzip" ||
214 currentBundleMimeType ==
"application/x-bzip" ||
215 currentBundleMimeType ==
"application/x-lzma" ||
216 currentBundleMimeType ==
"application/x-xz") {
217 archive =
new KTar(archiveName);
218 }
else if (archiveName.endsWith(QLatin1String(
"jisp")) || archiveName.endsWith(QLatin1String(
"zip"))) {
219 archive =
new KZip(archiveName);
221 archive =
new KTar(archiveName);
224 if (!archive || !archive->
open(QIODevice::ReadOnly)) {
225 kError() <<
"Could not open" << archiveName <<
"for unpacking";
234 for (QStringList::ConstIterator it = entries.begin(); it != entries.end(); ++it) {
240 for (
int i = 0; i < d->m_loaded.size(); ++i) {
241 QString fName = d->m_loaded.at(i)->property(
"X-KDE-EmoticonsFileName").toString();
243 if (currentDir && currentDir->
entry(fName) != NULL) {
244 foundThemes.append(currentDir->
name());
250 if (foundThemes.isEmpty()) {
251 kError() <<
"The file" << archiveName <<
"is not a valid emoticon theme archive";
257 for (
int themeIndex = 0; themeIndex < foundThemes.size(); ++themeIndex) {
261 if (currentEntry == 0) {
262 kDebug() <<
"couldn't get next archive entry";
269 if (currentDir == 0) {
270 kDebug() <<
"couldn't cast archive entry to KArchiveDirectory";
274 currentDir->
copyTo(localThemesDir + theme);
297 #include "kemoticons.moc"