File TODO changed (mode: 100644) (index be61baf..3d6995e) |
1 |
1 |
- perhaps search for album art using custom patterns with format arguments |
- perhaps search for album art using custom patterns with format arguments |
2 |
2 |
|
|
3 |
3 |
- perhaps search for album art in subdirectories (named like 'covers' or |
- perhaps search for album art in subdirectories (named like 'covers' or |
4 |
|
similair) |
|
|
4 |
|
similar) |
5 |
5 |
|
|
6 |
6 |
- perhaps add an option to pop-up a message after stopping playback |
- perhaps add an option to pop-up a message after stopping playback |
7 |
7 |
|
|
8 |
8 |
- tunable duration of notifications (it seems like this depends only from |
- tunable duration of notifications (it seems like this depends only from |
9 |
9 |
notification daemon) |
notification daemon) |
|
10 |
|
|
|
11 |
|
- refactor code and break it into several classes |
|
12 |
|
|
|
13 |
|
- rewrite README file using markdown |
File src/notifier.cpp changed (mode: 100644) (index 1bfc75f..a153877) |
... |
... |
Notifier::Notifier() : QObject() |
37 |
37 |
{ |
{ |
38 |
38 |
KConfig config("mpdknotifierrc"); |
KConfig config("mpdknotifierrc"); |
39 |
39 |
KConfigGroup generalGroup(&config, "General"); |
KConfigGroup generalGroup(&config, "General"); |
40 |
|
QString mpdHost = generalGroup.readEntry("MPDHost", "localhost"); |
|
|
40 |
|
QString mpdHostString = generalGroup.readEntry("MPDHost", "localhost"); |
|
41 |
|
QString mpdHost; |
|
42 |
|
parseHostString(mpdHostString, mpdHost, m_password); |
41 |
43 |
QString mpdPort = generalGroup.readEntry("MPDPort", "6600"); |
QString mpdPort = generalGroup.readEntry("MPDPort", "6600"); |
42 |
44 |
|
|
43 |
45 |
m_musicDir = generalGroup.readEntry("MusicDir", "/mnt/music/"); |
m_musicDir = generalGroup.readEntry("MusicDir", "/mnt/music/"); |
|
... |
... |
void Notifier::slotNewData() |
109 |
111 |
if (response.startsWith("OK")) { |
if (response.startsWith("OK")) { |
110 |
112 |
debug("'OK' response"); |
debug("'OK' response"); |
111 |
113 |
// ask for notification on any changes in 'player' subsystem |
// ask for notification on any changes in 'player' subsystem |
112 |
|
m_soc.write(QByteArray("idle player\n")); |
|
|
114 |
|
if (!m_password.isEmpty()) { |
|
115 |
|
m_soc.write(QString("password %1\n").arg(m_password).toLocal8Bit()); |
|
116 |
|
clearPassword(m_password); |
|
117 |
|
} else { |
|
118 |
|
m_soc.write(QByteArray("idle player\n")); |
|
119 |
|
} |
113 |
120 |
} else if (response.startsWith("changed")) { |
} else if (response.startsWith("changed")) { |
114 |
121 |
// there are some changes in subsystem |
// there are some changes in subsystem |
115 |
122 |
debug("'changed' response"); |
debug("'changed' response"); |
|
... |
... |
void Notifier::slotNewData() |
136 |
143 |
debug("currentsong response"); |
debug("currentsong response"); |
137 |
144 |
showSongInfo(response.split("\n")); |
showSongInfo(response.split("\n")); |
138 |
145 |
m_soc.write(QByteArray("idle player\n")); |
m_soc.write(QByteArray("idle player\n")); |
|
146 |
|
} else if (response.startsWith("ACK")) { |
|
147 |
|
debug("'ACK' response: " + response); |
|
148 |
|
m_soc.write(QByteArray("idle player\n")); |
|
149 |
|
} else { |
|
150 |
|
debug("unknown response: " + response); |
139 |
151 |
} |
} |
140 |
152 |
} |
} |
141 |
153 |
|
|
|
154 |
|
void Notifier::clearPassword(QString& _password) const |
|
155 |
|
{ |
|
156 |
|
_password.replace(0, m_password.length(), static_cast<QChar>('\0')); |
|
157 |
|
_password.clear(); |
|
158 |
|
} |
|
159 |
|
|
|
160 |
|
void Notifier::parseHostString(const QString& _hostString, QString& _host, |
|
161 |
|
QString& _password) const |
|
162 |
|
{ |
|
163 |
|
int atIndex = _hostString.indexOf('@'); |
|
164 |
|
_host = _hostString.mid(atIndex + 1); |
|
165 |
|
_password = (atIndex >= 0) ? _hostString.left(atIndex) : ""; |
|
166 |
|
} |
|
167 |
|
|
142 |
168 |
void Notifier::showSongInfo(const QStringList& _songInfo) |
void Notifier::showSongInfo(const QStringList& _songInfo) |
143 |
169 |
{ |
{ |
144 |
170 |
QString file, aart; |
QString file, aart; |
File src/notifier.h changed (mode: 100644) (index ee850bb..9680fcc) |
... |
... |
private slots: |
45 |
45 |
void displayError(QAbstractSocket::SocketError _socketError); |
void displayError(QAbstractSocket::SocketError _socketError); |
46 |
46 |
|
|
47 |
47 |
private: |
private: |
|
48 |
|
QString m_password; |
48 |
49 |
// some state variables |
// some state variables |
49 |
50 |
KNotification* m_notification; |
KNotification* m_notification; |
50 |
51 |
QTcpSocket m_soc; |
QTcpSocket m_soc; |
|
... |
... |
private: |
68 |
69 |
QString m_lastArt; |
QString m_lastArt; |
69 |
70 |
QString m_lastArtFilename; |
QString m_lastArtFilename; |
70 |
71 |
|
|
|
72 |
|
void clearPassword(QString& _password) const; |
|
73 |
|
void parseHostString(const QString& _hostString, QString& _host, |
|
74 |
|
QString& _password) const; |
71 |
75 |
void showSongInfo(const QStringList& _songInfo); |
void showSongInfo(const QStringList& _songInfo); |
72 |
76 |
void initLogging(const QString& _logFile); |
void initLogging(const QString& _logFile); |
73 |
77 |
bool loadImg(const QString& _file, QPixmap& _pixmap); |
bool loadImg(const QString& _file, QPixmap& _pixmap); |