michael@0: /* michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #ifndef NOTIFICATION_H michael@0: #define NOTIFICATION_H michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: class Dialogs: public CPlugin { michael@0: Q_OBJECT michael@0: public: michael@0: explicit Dialogs(Cordova *cordova): CPlugin(cordova), _alertCallback(0) { michael@0: } michael@0: michael@0: virtual const QString fullName() override { michael@0: return Dialogs::fullID(); michael@0: } michael@0: michael@0: virtual const QString shortName() override { michael@0: return "Notification"; michael@0: } michael@0: michael@0: static const QString fullID() { michael@0: return "Notification"; michael@0: } michael@0: public slots: michael@0: void beep(int scId, int ecId, int times); michael@0: void alert(int scId, int ecId, const QString &message, const QString &title, const QString &buttonLabel); michael@0: void confirm(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels); michael@0: void prompt(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels, const QString &defaultText); michael@0: michael@0: void notificationDialogButtonPressed(int buttonId, const QString &text, bool prompt) { michael@0: if (prompt) { michael@0: QVariantMap res; michael@0: res.insert("buttonIndex", buttonId); michael@0: res.insert("input1", text); michael@0: this->cb(_alertCallback, res); michael@0: } else { michael@0: this->cb(_alertCallback, buttonId); michael@0: } michael@0: _alertCallback = 0; michael@0: } michael@0: michael@0: private: michael@0: int _alertCallback; michael@0: QMediaPlayer _player; michael@0: }; michael@0: michael@0: #endif