~ubuntu-branches/ubuntu/utopic/psi/utopic

« back to all changes in this revision

Viewing changes to src/activeprofiles_win.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2010-02-19 09:37:12 UTC
  • mfrom: (6.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100219093712-e225xvm1wjcf1cgi
Tags: 0.14-2
* comment out only function which uses va_list to work around build
  problems on armel
* Set Standards-Version to 3.8.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
        bool winEvent(MSG *msg, long *result);
106
106
 
107
107
        bool sendStringList(const QString &to, const QStringList &list) const;
 
108
 
 
109
        QString pickProfile() const;
108
110
};
109
111
 
110
112
UINT ActiveProfiles::Private::psiIpcCommand = 0;
111
113
WPARAM ActiveProfiles::Private::raiseCommand = 1;
112
114
 
 
115
QString ActiveProfiles::Private::pickProfile() const
 
116
{
 
117
        QStringList profiles = getProfilesList();
 
118
        foreach (QString p, profiles) {
 
119
                if (ap->isActive(p)) {
 
120
                        return p;
 
121
                }
 
122
        }
 
123
        return QString();
 
124
}
 
125
 
113
126
bool ActiveProfiles::Private::sendMessage(const QString &to, UINT message, WPARAM wParam, LPARAM lParam) const
114
127
{
 
128
        QString profile = to;
 
129
        if (profile.isEmpty()) {
 
130
                profile = pickProfile();
 
131
        }
 
132
        if (profile.isEmpty()) {
 
133
                return false;
 
134
        }
 
135
 
115
136
        HWND hwnd;
116
137
        QT_WA(
117
138
                hwnd = FindWindowW(0, (LPCWSTR)windowName(to).utf16());
151
172
 
152
173
bool ActiveProfiles::Private::winEvent(MSG *msg, long *result)
153
174
{
154
 
        *result = 1;    // by default - not ok
155
 
 
156
175
        if (msg->message == WM_COPYDATA) {
 
176
                *result = FALSE;
157
177
                COPYDATASTRUCT *cd = (COPYDATASTRUCT *)msg->lParam;
158
178
                if (cd->dwData == stringListMessage) {
159
179
                        char *data = (char*)cd->lpData;
172
192
                                data += strlen(data) + 1;
173
193
                        }
174
194
 
175
 
                        if (list[0] == "openUri") {
176
 
                                QUrl uri;
177
 
                                uri.setEncodedUrl(list[1].toLatin1());
178
 
                                emit ap->openUri(uri);
179
 
                                *result = 0;    // ok
 
195
                        if (list.count() > 1) {
 
196
                                if (list[0] == "openUri") {
 
197
                                        emit ap->openUriRequested(list.value(1));
 
198
                                        *result = TRUE;
 
199
                                } else if (list[0] == "setStatus") {
 
200
                                        emit ap->setStatusRequested(list.value(1), list.value(2));
 
201
                                        *result = TRUE;
 
202
                                }
180
203
                        }
181
204
                }
182
205
                return true;
183
206
        }
184
207
        else if (msg->message == psiIpcCommand) {
 
208
                *result = FALSE;
185
209
                if (msg->wParam == raiseCommand) {
186
 
                        emit ap->raiseMainWindow();
187
 
                        *result = 0; // ok
 
210
                        emit ap->raiseRequested();
 
211
                        *result = TRUE;
188
212
                }
189
213
                return true;
190
214
        }
273
297
        }
274
298
}
275
299
 
276
 
bool ActiveProfiles::raiseOther(QString profile, bool withUI) const
 
300
bool ActiveProfiles::isAnyActive() const
 
301
{
 
302
        return !d->pickProfile().isEmpty();
 
303
}
 
304
 
 
305
 
 
306
bool ActiveProfiles::raise(const QString &profile, bool withUI) const
277
307
{
278
308
        QLabel *lab = 0;
279
309
        if (withUI) {
291
321
        return res;
292
322
}
293
323
 
294
 
bool ActiveProfiles::sendOpenUri(const QString &uri, const QString &profile) const
 
324
bool ActiveProfiles::openUri(const QString &profile, const QString &uri) const
295
325
{
296
326
        QStringList list;
297
327
        list << "openUri" << uri;
298
 
        return d->sendStringList(isActive(profile)? profile : pickProfile(), list);
 
328
        return d->sendStringList(profile, list);
 
329
}
 
330
 
 
331
bool ActiveProfiles::setStatus(const QString &profile, const QString &status, const QString &message) const
 
332
{
 
333
        QStringList list;
 
334
        list << "setStatus" << status << message;
 
335
        return d->sendStringList(profile, list);
299
336
}