├── translations ├── wp_bb10.pro ├── Makefile └── wp_bb10.ts ├── icon.png ├── assets ├── images │ ├── add.png │ ├── blank.png │ ├── edit.png │ ├── pages.png │ ├── posts.png │ ├── reply.png │ ├── save.png │ ├── spam.png │ ├── wplogo.png │ ├── addimage.png │ ├── approve.png │ ├── comments.png │ ├── loading.gif │ ├── overlay.png │ ├── refresh.png │ ├── unapprove.png │ └── splashscreen-1024600.png ├── 720x720 │ ├── images │ │ ├── wplogo.png │ │ └── splashscreen720720.png │ └── Login.qml ├── 720x1280 │ └── images │ │ └── splashscreen-7201280.png ├── 768x1280 │ └── images │ │ └── splashscreen-1280768.png ├── .assets.index ├── CustomIndicator.qml ├── CustomDialogCategories.qml ├── BlogsSelectionDialog.qml ├── ReplyDialog.qml ├── viewcomment.qml ├── blogslist.qml ├── showPost.qml ├── editcomment.qml ├── Login.qml ├── makePost.qml ├── editpost.qml ├── postslist.qml ├── main.qml └── commentslist.qml ├── beta ├── wp_bb10-1_0_0_1.bar ├── wp_bb10-1_1_1_1.bar ├── wp_bb10-1_2_5_1.bar └── wp_bb10-1_2_7_2.bar ├── doc └── final-documentation.pdf ├── precompiled.h ├── Makefile ├── wp_bb10.pro ├── src ├── applicationui.hpp ├── applicationui.cpp ├── SBError.hpp ├── Crypto.hpp ├── DRBG.hpp ├── GlobalContext.hpp ├── main.cpp ├── Crypto.cpp ├── AESKey.hpp ├── AESParams.hpp ├── AESParams.cpp ├── AESKey.cpp ├── GlobalContext.cpp ├── DRBG.cpp ├── WPUtils.h ├── SBError.cpp └── WPUtils.cpp ├── README.md ├── config.pri ├── bar-descriptor.xml └── LICENSE /translations/wp_bb10.pro: -------------------------------------------------------------------------------- 1 | include (../wp_bb10.pro) 2 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/icon.png -------------------------------------------------------------------------------- /assets/images/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/images/add.png -------------------------------------------------------------------------------- /assets/images/blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/images/blank.png -------------------------------------------------------------------------------- /assets/images/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/images/edit.png -------------------------------------------------------------------------------- /assets/images/pages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/images/pages.png -------------------------------------------------------------------------------- /assets/images/posts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/images/posts.png -------------------------------------------------------------------------------- /assets/images/reply.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/images/reply.png -------------------------------------------------------------------------------- /assets/images/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/images/save.png -------------------------------------------------------------------------------- /assets/images/spam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/images/spam.png -------------------------------------------------------------------------------- /assets/images/wplogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/images/wplogo.png -------------------------------------------------------------------------------- /beta/wp_bb10-1_0_0_1.bar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/beta/wp_bb10-1_0_0_1.bar -------------------------------------------------------------------------------- /beta/wp_bb10-1_1_1_1.bar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/beta/wp_bb10-1_1_1_1.bar -------------------------------------------------------------------------------- /beta/wp_bb10-1_2_5_1.bar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/beta/wp_bb10-1_2_5_1.bar -------------------------------------------------------------------------------- /beta/wp_bb10-1_2_7_2.bar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/beta/wp_bb10-1_2_7_2.bar -------------------------------------------------------------------------------- /assets/images/addimage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/images/addimage.png -------------------------------------------------------------------------------- /assets/images/approve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/images/approve.png -------------------------------------------------------------------------------- /assets/images/comments.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/images/comments.png -------------------------------------------------------------------------------- /assets/images/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/images/loading.gif -------------------------------------------------------------------------------- /assets/images/overlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/images/overlay.png -------------------------------------------------------------------------------- /assets/images/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/images/refresh.png -------------------------------------------------------------------------------- /assets/images/unapprove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/images/unapprove.png -------------------------------------------------------------------------------- /doc/final-documentation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/doc/final-documentation.pdf -------------------------------------------------------------------------------- /assets/720x720/images/wplogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/720x720/images/wplogo.png -------------------------------------------------------------------------------- /assets/images/splashscreen-1024600.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/images/splashscreen-1024600.png -------------------------------------------------------------------------------- /assets/720x720/images/splashscreen720720.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/720x720/images/splashscreen720720.png -------------------------------------------------------------------------------- /assets/720x1280/images/splashscreen-7201280.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/720x1280/images/splashscreen-7201280.png -------------------------------------------------------------------------------- /assets/768x1280/images/splashscreen-1280768.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/WordPress-BlackBerry/master/assets/768x1280/images/splashscreen-1280768.png -------------------------------------------------------------------------------- /precompiled.h: -------------------------------------------------------------------------------- 1 | // This file is used to store precompiled headers. 2 | // It is intentionally left blank. It is up to you to decide which headers should be included here. 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | QMAKE_TARGET = wp_bb10 2 | PROJECT_DIR := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))) 3 | I18N_DIR := $(PROJECT_DIR)/translations 4 | 5 | include mk/cs-base.mk 6 | 7 | -------------------------------------------------------------------------------- /translations/Makefile: -------------------------------------------------------------------------------- 1 | QMAKE_TARGET = wp_bb10 2 | LUPDATE = $(QNX_HOST)/usr/bin/lupdate 3 | LRELEASE = $(QNX_HOST)/usr/bin/lrelease 4 | 5 | update: $(QMAKE_TARGET).pro FORCE 6 | $(LUPDATE) $(QMAKE_TARGET).pro 7 | 8 | release: $(QMAKE_TARGET).pro $(QMAKE_TARGET).ts 9 | $(LRELEASE) $(QMAKE_TARGET).pro 10 | 11 | FORCE: 12 | 13 | -------------------------------------------------------------------------------- /wp_bb10.pro: -------------------------------------------------------------------------------- 1 | APP_NAME = wp_bb10 2 | 3 | CONFIG += qt warn_on cascades10 4 | 5 | QT += xml network script 6 | 7 | LIBS += -lbbdata -lbbcascadespickers 8 | 9 | include(config.pri) 10 | 11 | device { 12 | CONFIG(debug, debug|release) { 13 | # Device-Debug custom configuration 14 | } 15 | 16 | CONFIG(release, debug|release) { 17 | # Device-Release custom configuration 18 | } 19 | } 20 | 21 | simulator { 22 | CONFIG(debug, debug|release) { 23 | # Simulator-Debug custom configuration 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/applicationui.hpp: -------------------------------------------------------------------------------- 1 | // Default empty project template 2 | #ifndef ApplicationUI_HPP_ 3 | #define ApplicationUI_HPP_ 4 | 5 | #include 6 | 7 | namespace bb { namespace cascades { class Application; }} 8 | 9 | /*! 10 | * @brief Application pane object 11 | * 12 | *Use this object to create and init app UI, to create context objects, to register the new meta types etc. 13 | */ 14 | class ApplicationUI : public QObject 15 | { 16 | Q_OBJECT 17 | public: 18 | ApplicationUI(bb::cascades::Application *app); 19 | virtual ~ApplicationUI() {} 20 | }; 21 | 22 | 23 | #endif /* ApplicationUI_HPP_ */ 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | WordPress-BlackBerry 2 | ==================== 3 | 4 | WordPress for BlackBerry 10 5 | 6 | 7 | GSoC 2013 project 8 | 9 | Requirements: 10 | ============= 11 | 12 | * BlackBerry Native SDK 13 | * simulator 14 | 15 | (you can find both here : https://developer.blackberry.com/native/download/) 16 | 17 | Build&Run: 18 | ========== 19 | 20 | 1. Launch the Native SDK 21 | 2. On the File Menu, click Import 22 | 3. Expand General, and select Existing Projects into Workspace. Click Next. 23 | 4. Browse to the location where you clone the repo and click OK. 24 | 5. Click Finish to import the project into your workspace. 25 | 6. Click Project Menu, and select Build Project. 26 | 7. Click Run menu, select Run. 27 | 8. Enjoy -------------------------------------------------------------------------------- /assets/.assets.index: -------------------------------------------------------------------------------- 1 | 1 2 | 35 3 | .CustomDialogCategories.qml.swp 4 | pageslist.qml 5 | blogslist.qml 6 | ReplyDialog.qml 7 | editpost.qml 8 | BlogsSelectionDialog.qml 9 | viewcomment.qml 10 | .pageslist.qml.swp 11 | CustomDialogCategories.qml 12 | CustomIndicator.qml 13 | editcomment.qml 14 | commentslist.qml 15 | showPost.qml 16 | makePost.qml 17 | images/wplogo.png 18 | images/add.png 19 | images/overlay.png 20 | images/comments.png 21 | images/reply.png 22 | images/spam.png 23 | images/refresh.png 24 | images/approve.png 25 | images/pages.png 26 | images/unapprove.png 27 | images/save.png 28 | images/loading.gif 29 | images/edit.png 30 | images/addimage.png 31 | images/posts.png 32 | postslist.qml 33 | main.qml 34 | Login.qml 35 | wpbb10.db 36 | wplogo.png 37 | posts.png 38 | -------------------------------------------------------------------------------- /src/applicationui.cpp: -------------------------------------------------------------------------------- 1 | #include "applicationui.hpp" 2 | 3 | #include "WPUtils.h" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | 11 | using namespace bb::cascades; 12 | 13 | ApplicationUI::ApplicationUI(bb::cascades::Application *app) 14 | : QObject(app) 15 | { 16 | // create scene document from main.qml asset 17 | // set parent to created document to ensure it exists for the whole application lifetime 18 | QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this); 19 | 20 | WPUtils *wpu = new WPUtils(); 21 | qml->setContextProperty("wpu", wpu); 22 | 23 | // create root object for the UI 24 | AbstractPane *root = qml->createRootObject(); 25 | // set created root object as a scene 26 | app->setScene(root); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/SBError.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2013 BlackBerry Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | **/ 16 | #ifndef SBERROR_HPP_ 17 | #define SBERROR_HPP_ 18 | 19 | #include 20 | #include 21 | 22 | class SBError { 23 | public: 24 | static QString getErrorText(int error); 25 | 26 | private: 27 | SBError() {} 28 | virtual ~SBError() {} 29 | 30 | static QMap errors; 31 | static void buildErrors(); 32 | }; 33 | 34 | #endif /* SBERROR_HPP_ */ 35 | -------------------------------------------------------------------------------- /src/Crypto.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2013 BlackBerry Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | **/ 16 | #ifndef CRYPTO_HPP_ 17 | #define CRYPTO_HPP_ 18 | 19 | #include 20 | 21 | class Crypto { 22 | public: 23 | virtual ~Crypto() {} 24 | 25 | virtual bool isValid() = 0; 26 | 27 | int lastError() { 28 | return _lastError; 29 | } 30 | 31 | protected: 32 | Crypto(const char * name); 33 | bool maybeLog(const char * message, int result); 34 | void invalid(); 35 | 36 | private: 37 | QString _name; 38 | int _lastError; 39 | }; 40 | 41 | #endif /* CRYPTO_HPP_ */ 42 | -------------------------------------------------------------------------------- /src/DRBG.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2013 BlackBerry Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | **/ 16 | #ifndef DRBG_H_ 17 | #define DRBG_H_ 18 | 19 | #include 20 | #include 21 | 22 | #include "GlobalContext.hpp" 23 | 24 | class DRBG : public Crypto { 25 | public: 26 | DRBG(GlobalContext & context); 27 | virtual ~DRBG(); 28 | 29 | int getBytes(QByteArray & buffer); 30 | 31 | virtual bool isValid() { 32 | return rngCtx!=NULL; 33 | } 34 | 35 | private: 36 | GlobalContext & context; 37 | sb_RNGCtx rngCtx; 38 | }; 39 | 40 | #endif /* DRBG_H_ */ 41 | -------------------------------------------------------------------------------- /src/GlobalContext.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2013 BlackBerry Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | **/ 16 | #ifndef GLOBALCONTEXT_H_ 17 | #define GLOBALCONTEXT_H_ 18 | 19 | #include 20 | 21 | #include "Crypto.hpp" 22 | 23 | class GlobalContext : public Crypto { 24 | public: 25 | GlobalContext(); 26 | virtual ~GlobalContext(); 27 | 28 | sb_GlobalCtx ctx() { 29 | return _ctx; 30 | } 31 | 32 | virtual bool isValid() { 33 | return valid && _ctx!=NULL; 34 | } 35 | 36 | private: 37 | sb_GlobalCtx _ctx; 38 | bool valid; 39 | }; 40 | 41 | #endif /* GLOBALCONTEXT_H_ */ 42 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * main.cpp 3 | * 4 | * Author: Daniele (b0unc3) Maio 5 | */ 6 | 7 | // Default empty project template 8 | #include 9 | 10 | #include 11 | #include 12 | #include "applicationui.hpp" 13 | 14 | // include JS Debugger / CS Profiler enabler 15 | // this feature is enabled by default in the debug build only 16 | #include 17 | 18 | using namespace bb::cascades; 19 | 20 | Q_DECL_EXPORT int main(int argc, char **argv) 21 | { 22 | // this is where the server is started etc 23 | Application app(argc, argv); 24 | 25 | // localization support 26 | QTranslator translator; 27 | QString locale_string = QLocale().name(); 28 | QString filename = QString( "wp_bb10_%1" ).arg( locale_string ); 29 | if (translator.load(filename, "app/native/qm")) { 30 | app.installTranslator( &translator ); 31 | } 32 | 33 | new ApplicationUI(&app); 34 | 35 | // we complete the transaction started in the app constructor and start the client event loop here 36 | return Application::exec(); 37 | // when loop is exited the Application deletes the scene which deletes all its children (per qt rules for children) 38 | } 39 | -------------------------------------------------------------------------------- /src/Crypto.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2013 BlackBerry Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | **/ 16 | #include "Crypto.hpp" 17 | 18 | #include 19 | #include 20 | 21 | #include "SBError.hpp" 22 | 23 | Crypto::Crypto(const char * name) : _name(name), _lastError(SB_SUCCESS) { 24 | } 25 | 26 | bool Crypto::maybeLog(const char * message, int result) { 27 | if (result!=SB_SUCCESS) { 28 | qDebug() << "FAILED" << _name << message << result << SBError::getErrorText(result); 29 | _lastError = result; 30 | return false; 31 | } 32 | return true; 33 | } 34 | 35 | void Crypto::invalid() { 36 | qDebug() << "FAILED invalid params given to " << _name; 37 | } 38 | -------------------------------------------------------------------------------- /src/AESKey.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2013 BlackBerry Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | **/ 16 | #ifndef AESKEY_H_ 17 | #define AESKEY_H_ 18 | 19 | #include 20 | #include "huaes.h" 21 | 22 | #include "AESParams.hpp" 23 | 24 | class AESKey : public Crypto { 25 | public: 26 | AESKey(AESParams & params, const QByteArray & value); 27 | virtual ~AESKey(); 28 | 29 | sb_Key aesKey() { 30 | return _aesKey; 31 | } 32 | 33 | AESParams & params() { 34 | return _params; 35 | } 36 | 37 | virtual bool isValid() { 38 | return _aesKey!=NULL; 39 | } 40 | 41 | private: 42 | AESParams & _params; 43 | sb_Key _aesKey; 44 | }; 45 | 46 | #endif /* AESKEY_H_ */ 47 | -------------------------------------------------------------------------------- /src/AESParams.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2013 BlackBerry Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | **/ 16 | #ifndef AESPARAMS_H_ 17 | #define AESPARAMS_H_ 18 | 19 | #include 20 | 21 | #include "GlobalContext.hpp" 22 | 23 | class AESParams : public Crypto { 24 | public: 25 | AESParams(GlobalContext & gc); 26 | virtual ~AESParams(); 27 | 28 | sb_Params aesParams() { 29 | return _aesParams; 30 | } 31 | 32 | GlobalContext & globalContext() { 33 | return _globalContext; 34 | } 35 | 36 | virtual bool isValid() { 37 | return _aesParams!=NULL; 38 | } 39 | 40 | private: 41 | GlobalContext & _globalContext; 42 | sb_Params _aesParams; 43 | }; 44 | 45 | #endif /* AESPARAMS_H_ */ 46 | -------------------------------------------------------------------------------- /src/AESParams.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2013 BlackBerry Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | **/ 16 | #include 17 | 18 | #include "AESParams.hpp" 19 | 20 | AESParams::AESParams(GlobalContext & g) : 21 | Crypto("AESParams"), _globalContext(g), _aesParams(NULL) { 22 | int rc = hu_AESParamsCreate(SB_AES_CBC, SB_AES_128_BLOCK_BITS, NULL, NULL, 23 | &_aesParams, _globalContext.ctx()); 24 | maybeLog("AESParamsCreate", rc); 25 | } 26 | 27 | AESParams::~AESParams() { 28 | if (_aesParams != NULL) { 29 | // cowardly ignoring return code. 30 | int rc = hu_AESParamsDestroy(&_aesParams, _globalContext.ctx()); 31 | maybeLog("AESParamsDestroy", rc); 32 | _aesParams = NULL; 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /src/AESKey.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2013 BlackBerry Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | **/ 16 | #include 17 | #include 18 | 19 | #include "AESKey.hpp" 20 | 21 | AESKey::AESKey(AESParams & p, const QByteArray & content) : 22 | Crypto("AESKey"), _params(p), _aesKey(NULL) { 23 | int rc = hu_AESKeySet(_params.aesParams(), content.length() * 8, 24 | (unsigned char *) content.constData(), &_aesKey, 25 | _params.globalContext().ctx()); 26 | maybeLog("AESKey", rc); 27 | } 28 | 29 | AESKey::~AESKey() { 30 | if (_aesKey != NULL) { 31 | int rc = hu_AESKeyDestroy(_params.aesParams(), &_aesKey, 32 | _params.globalContext().ctx()); 33 | maybeLog("~AESKey", rc); 34 | _aesKey = NULL; 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /src/GlobalContext.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2013 BlackBerry Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | **/ 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "GlobalContext.hpp" 22 | 23 | bool falseFunc() { 24 | return false; 25 | } 26 | 27 | GlobalContext::GlobalContext() : 28 | Crypto("GlobalContext"), _ctx(NULL), valid(false) { 29 | valid = maybeLog("Create", hu_GlobalCtxCreateDefault(&_ctx)) 30 | && maybeLog("Register", hu_RegisterSbg56(_ctx)) 31 | && maybeLog("Register Seed", hu_RegisterSystemSeed(_ctx)) 32 | && maybeLog("Init SBG 56", hu_InitSbg56(_ctx)); 33 | } 34 | 35 | GlobalContext::~GlobalContext() { 36 | if (_ctx != NULL) { 37 | int rc = hu_GlobalCtxDestroy(&_ctx); 38 | maybeLog("GlobalCtxDestroy", rc); 39 | _ctx = NULL; 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /src/DRBG.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2013 BlackBerry Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | **/ 16 | #include 17 | 18 | #include "DRBG.hpp" 19 | 20 | DRBG::DRBG(GlobalContext & gc) : 21 | Crypto("DRBG"), context(gc), rngCtx(NULL) { 22 | int rc = hu_RngDrbgCreate(HU_DRBG_HASH, 112, false, 0, NULL, NULL, &rngCtx, 23 | context.ctx()); 24 | maybeLog("DRBGCreate", rc); 25 | } 26 | 27 | DRBG::~DRBG() { 28 | if (rngCtx != NULL) { 29 | int rc = hu_RngDrbgDestroy(&rngCtx, context.ctx()); 30 | maybeLog("DRBGDestroy", rc); 31 | rngCtx = NULL; 32 | } 33 | } 34 | 35 | int DRBG::getBytes(QByteArray & buffer) { 36 | if (isValid()) { 37 | int rc = hu_RngGetBytes(rngCtx, buffer.length(), 38 | (unsigned char *) buffer.data(), context.ctx()); 39 | maybeLog("RNGGetBytes", rc); 40 | return rc; 41 | } 42 | return -1; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /assets/CustomIndicator.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * CustomIndicator.qml 3 | * 4 | * Author: Daniele (b0unc3) Maio 5 | */ 6 | 7 | import bb.cascades 1.0 8 | 9 | Dialog { 10 | id: bi 11 | property alias body: theBody.text 12 | 13 | Container { 14 | horizontalAlignment: HorizontalAlignment.Center 15 | verticalAlignment: VerticalAlignment.Center 16 | layout: DockLayout { 17 | } 18 | 19 | ImageView { 20 | imageSource: "asset:///images/overlay.png" 21 | } 22 | 23 | Container { 24 | 25 | horizontalAlignment: HorizontalAlignment.Center 26 | verticalAlignment: VerticalAlignment.Center 27 | 28 | preferredHeight: 363 29 | preferredWidth: 557 30 | 31 | background: Color.create(0.0, 0.0, 0.0, 0.8) 32 | 33 | ActivityIndicator { 34 | id: theIndicator 35 | horizontalAlignment: HorizontalAlignment.Center 36 | verticalAlignment: VerticalAlignment.Center 37 | preferredHeight: 150 38 | preferredWidth: 150 39 | } 40 | 41 | Divider { 42 | preferredWidth: 25 43 | } 44 | 45 | Label { 46 | id: theBody 47 | horizontalAlignment: HorizontalAlignment.Center 48 | verticalAlignment: VerticalAlignment.Center 49 | multiline: true 50 | 51 | textStyle { 52 | base: SystemDefaults.TextStyles.BodyText 53 | color: Color.White 54 | fontWeight: FontWeight.Bold 55 | } 56 | } 57 | } 58 | } 59 | onOpened: { 60 | theIndicator.running = true; 61 | } 62 | onClosed: { 63 | theIndicator.running = false; 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /assets/CustomDialogCategories.qml: -------------------------------------------------------------------------------- 1 | import bb.cascades 1.0 2 | 3 | Dialog { 4 | id: cdcp 5 | 6 | property variant cats; 7 | 8 | function onDataReady(val) 9 | { 10 | cats = wpu.getRes(); 11 | /* not work? */ 12 | for (var event in cats) { 13 | var dataCopy = cats[event] 14 | 15 | for (var key in dataCopy) { 16 | //console.log("dataCopy[key] = " + dataCopy[key]); 17 | } 18 | // console.log("event = " + event); 19 | if ( event == "name" ) { 20 | // console.log("add name " + cats[event]); 21 | var option = optionControlDefinition.createObject(); 22 | option.text = cats[event] 23 | dropDown.add(option) 24 | } 25 | } 26 | 27 | cdcind.stop(); 28 | } 29 | 30 | attachedObjects: [ 31 | ComponentDefinition { 32 | id: optionControlDefinition 33 | Option { 34 | } 35 | } 36 | ] 37 | 38 | Container { 39 | horizontalAlignment: HorizontalAlignment.Center 40 | verticalAlignment: VerticalAlignment.Center 41 | 42 | background: Color.create(0.0, 0.0, 0.0, 0.5) 43 | 44 | layout: StackLayout {} 45 | 46 | DropDown { 47 | Option { 48 | text: cats.name //<--? 49 | } 50 | } 51 | 52 | Divider { 53 | 54 | } 55 | Button { 56 | horizontalAlignment: HorizontalAlignment.Center 57 | text: qsTr("Done"); 58 | onClicked: { 59 | customdialogcat.close(); 60 | } 61 | } 62 | } 63 | 64 | onCreationCompleted: { 65 | wpu.getCategories(); 66 | wpu.dataReady.connect(cdcp.onDataReady); 67 | } 68 | } -------------------------------------------------------------------------------- /config.pri: -------------------------------------------------------------------------------- 1 | # Auto-generated by IDE. Any changes made by user will be lost! 2 | BASEDIR = $$quote($$_PRO_FILE_PWD_) 3 | 4 | device { 5 | CONFIG(debug, debug|release) { 6 | SOURCES += $$quote($$BASEDIR/src/WPUtils.cpp) \ 7 | $$quote($$BASEDIR/src/applicationui.cpp) \ 8 | $$quote($$BASEDIR/src/main.cpp) 9 | 10 | HEADERS += $$quote($$BASEDIR/src/WPUtils.h) \ 11 | $$quote($$BASEDIR/src/applicationui.hpp) 12 | } 13 | 14 | CONFIG(release, debug|release) { 15 | SOURCES += $$quote($$BASEDIR/src/WPUtils.cpp) \ 16 | $$quote($$BASEDIR/src/applicationui.cpp) \ 17 | $$quote($$BASEDIR/src/main.cpp) 18 | 19 | HEADERS += $$quote($$BASEDIR/src/WPUtils.h) \ 20 | $$quote($$BASEDIR/src/applicationui.hpp) 21 | } 22 | } 23 | 24 | simulator { 25 | CONFIG(debug, debug|release) { 26 | SOURCES += $$quote($$BASEDIR/src/WPUtils.cpp) \ 27 | $$quote($$BASEDIR/src/applicationui.cpp) \ 28 | $$quote($$BASEDIR/src/main.cpp) 29 | 30 | HEADERS += $$quote($$BASEDIR/src/WPUtils.h) \ 31 | $$quote($$BASEDIR/src/applicationui.hpp) 32 | } 33 | } 34 | 35 | INCLUDEPATH += $$quote($$BASEDIR/src) 36 | 37 | CONFIG += precompile_header 38 | 39 | PRECOMPILED_HEADER = $$quote($$BASEDIR/precompiled.h) 40 | 41 | lupdate_inclusion { 42 | SOURCES += $$quote($$BASEDIR/../src/*.c) \ 43 | $$quote($$BASEDIR/../src/*.c++) \ 44 | $$quote($$BASEDIR/../src/*.cc) \ 45 | $$quote($$BASEDIR/../src/*.cpp) \ 46 | $$quote($$BASEDIR/../src/*.cxx) \ 47 | $$quote($$BASEDIR/../assets/*.qml) \ 48 | $$quote($$BASEDIR/../assets/*.js) \ 49 | $$quote($$BASEDIR/../assets/*.qs) 50 | 51 | HEADERS += $$quote($$BASEDIR/../src/*.h) \ 52 | $$quote($$BASEDIR/../src/*.h++) \ 53 | $$quote($$BASEDIR/../src/*.hh) \ 54 | $$quote($$BASEDIR/../src/*.hpp) \ 55 | $$quote($$BASEDIR/../src/*.hxx) 56 | } 57 | 58 | TRANSLATIONS = $$quote($${TARGET}.ts) 59 | -------------------------------------------------------------------------------- /assets/BlogsSelectionDialog.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * BlogsSelectionDialog.qml 3 | * 4 | * Author: Daniele (b0unc3) Maio 5 | */ 6 | 7 | import bb.cascades 1.0 8 | 9 | Dialog { 10 | id: bsd 11 | 12 | function getRegisteredBlogs() 13 | { 14 | bdd.removeAll(); 15 | var val = wpu.getBI(); 16 | var cb = wpu.getCurrentBlog(); 17 | var bi = cb.split("-"); 18 | for (var event in val) { 19 | var dataCopy = val[event] 20 | 21 | if ( event != "" && val[event] != "" ) 22 | { 23 | console.log("event = " + event); 24 | console.log("val[event] = " + val[event]); 25 | var option = optionControlDefinition.createObject(); 26 | option.value = qsTr(event); 27 | option.text = qsTr(val[event]); 28 | if ( event == bi[0] && val[event] == bi[1]) 29 | option.selected = true; 30 | 31 | bdd.add(option); 32 | } 33 | } 34 | } 35 | 36 | attachedObjects: [ 37 | ComponentDefinition { 38 | id: optionControlDefinition 39 | Option { 40 | } 41 | } 42 | ] 43 | 44 | Container { 45 | horizontalAlignment: HorizontalAlignment.Center 46 | verticalAlignment: VerticalAlignment.Center 47 | 48 | background: Color.create(0.0, 0.0, 0.0, 0.5) 49 | 50 | layout: StackLayout { 51 | } 52 | 53 | DropDown { 54 | id: bdd 55 | } 56 | 57 | Divider { 58 | 59 | } 60 | Button { 61 | horizontalAlignment: HorizontalAlignment.Center 62 | text: qsTr("Done") 63 | onClicked: { 64 | /* set the new blog */ 65 | wpu.setCurrentBlog(bdd.selectedOption.value, bdd.selectedOption.text); 66 | bsdo.close(); 67 | } 68 | } 69 | } 70 | 71 | onOpened: { 72 | getRegisteredBlogs(); 73 | } 74 | onClosed: { 75 | if ( navcommentspane.firstPage ) 76 | navcommentspane.firstPage.comment_restoreItems() 77 | else if ( navpostpane.firstPage ) 78 | navpostpane.firstPage.post_loadData(); 79 | else if ( navpagepane.firstPage ) 80 | navpagepane.firstPage.post_loadData(); 81 | 82 | } 83 | } 84 | 85 | -------------------------------------------------------------------------------- /assets/ReplyDialog.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * ReplyDialog.qml 3 | * 4 | * Author: Daniele (b0unc3) Maio 5 | */ 6 | 7 | import bb.cascades 1.0 8 | 9 | Dialog { 10 | id: rd 11 | property string parent_id; 12 | property string post_id; 13 | 14 | function rd_onDataReady() 15 | { 16 | var rd_a = wpu.getRes(); 17 | 18 | if (rd_a["ERROR"]) { 19 | //myQmlToast.show(); <- TBD 20 | console.log("ERRORE"); 21 | // wpu.resetRes(); 22 | } else if (rd_a["newcommentid"]) { 23 | close(); 24 | } 25 | } 26 | 27 | 28 | Container { 29 | horizontalAlignment: HorizontalAlignment.Center 30 | verticalAlignment: VerticalAlignment.Center 31 | layout: StackLayout { } 32 | 33 | background: Color.create(0.0, 0.0, 0.0, 0.8) 34 | 35 | Container { 36 | layout: DockLayout { 37 | 38 | } 39 | 40 | Label { 41 | horizontalAlignment: HorizontalAlignment.Left 42 | text: qsTr("Leave a reply") 43 | } 44 | 45 | 46 | Button { 47 | horizontalAlignment: HorizontalAlignment.Right 48 | text: qsTr("Cancel reply") 49 | 50 | onClicked: { 51 | close(); 52 | } 53 | 54 | } 55 | } 56 | Container { 57 | layout: StackLayout { } 58 | 59 | TextArea { 60 | id: rep_content 61 | horizontalAlignment: HorizontalAlignment.Fill 62 | preferredHeight: 250; 63 | hintText: "Enter your comment here"; 64 | } 65 | } 66 | 67 | Button { 68 | id: pc 69 | horizontalAlignment: HorizontalAlignment.Right 70 | verticalAlignment: VerticalAlignment.Bottom 71 | text: qsTr("Post Comment") 72 | 73 | 74 | onClicked: { 75 | if ( rep_content.text && post_id && parent_id ) 76 | { 77 | pc.imageSource = "asset:///images/loading.gif"; 78 | pc.enabled = false; 79 | wpu.buildWPXML("wp.newComment", true, ["post_id"], [post_id], ["content", "comment_parent"], [rep_content.text, parent_id]); 80 | wpu.dataReady_newComment.connect(rd.rd_onDataReady); 81 | } 82 | 83 | } 84 | } 85 | } 86 | 87 | onOpened: { 88 | pc.imageSource = ''; 89 | pc.enabled = true; 90 | rep_content.text = ''; 91 | } 92 | } 93 | 94 | -------------------------------------------------------------------------------- /assets/viewcomment.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * viewcomment.qml 3 | * 4 | * Author: Daniele (b0unc3) Maio 5 | */ 6 | 7 | import bb.cascades 1.0 8 | 9 | Page { 10 | id: vcp 11 | 12 | property string vc_cid; 13 | property variant vc_infos; 14 | 15 | onVc_cidChanged: { 16 | wpu.buildWPXML("wp.getComment", true, ["comment_id"], [vcp.vc_cid], [], []); 17 | wpu.dataReady_getComment.connect(vcp.vc_onDataReady); 18 | } 19 | 20 | function vc_onDataReady() 21 | { 22 | var vc_a = wpu.getRes(); 23 | vc_infos = vc_a; 24 | vcind.stop(); 25 | } 26 | 27 | actions: [ 28 | InvokeActionItem { 29 | ActionBar.placement: ActionBarPlacement.OnBar 30 | query { 31 | mimeType: "text/plain" 32 | invokeActionId: "bb.action.SHARE" 33 | } 34 | onTriggered: { 35 | data = vc_infos.post_title + "\n" + vc_infos.link 36 | } 37 | } 38 | ] 39 | 40 | content: Container { 41 | horizontalAlignment: HorizontalAlignment.Center 42 | verticalAlignment: VerticalAlignment.Top 43 | layout: DockLayout { } 44 | ActivityIndicator { 45 | id: vcind 46 | horizontalAlignment: HorizontalAlignment.Center 47 | verticalAlignment: VerticalAlignment.Center 48 | 49 | preferredHeight: 500 50 | preferredWidth: 500 51 | 52 | running: true 53 | } 54 | Container { 55 | layout: StackLayout { 56 | orientation: LayoutOrientation.TopToBottom 57 | } 58 | 59 | topPadding: 25 60 | bottomPadding: 25 61 | rightPadding: 25 62 | leftPadding: 25 63 | 64 | Label { 65 | id: auth 66 | text: ( vc_infos ) ? qsTr(vc_infos.author) : "" 67 | 68 | textStyle.base: SystemDefaults.TextStyles.BodyText 69 | } 70 | Label { 71 | id: authmail 72 | text: (vc_infos ) ? "" + vc_infos.author_email + "" : "" 73 | 74 | textFormat: TextFormat.Html 75 | textStyle.base: SystemDefaults.TextStyles.SubtitleText 76 | } 77 | Label { 78 | id: authurl 79 | text: (vc_infos ) ? "" + vc_infos.author_url + "" : "" 80 | 81 | textFormat: TextFormat.Html 82 | textStyle.base: SystemDefaults.TextStyles.SubtitleText 83 | } 84 | Label { 85 | id: dc 86 | text: ( vc_infos ) ? vc_infos.date : "" 87 | 88 | textStyle.base: SystemDefaults.TextStyles.SmallText 89 | } 90 | Label { 91 | id: pt 92 | text: ( vc_infos ) ? qsTr(vc_infos.post_title) : "" 93 | 94 | textFormat: TextFormat.Html 95 | textStyle.base: SystemDefaults.TextStyles.TitleText 96 | } 97 | Divider { 98 | horizontalAlignment: HorizontalAlignment.Fill 99 | preferredHeight: 50 100 | } 101 | Label { 102 | id: cont 103 | text: ( vc_infos ) ? qsTr(vc_infos.content) : "" 104 | multiline: true 105 | 106 | textFormat: TextFormat.Html 107 | textStyle.base: SystemDefaults.TextStyles.BodyText 108 | } 109 | } 110 | } 111 | 112 | 113 | } 114 | 115 | -------------------------------------------------------------------------------- /assets/blogslist.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * blogslist.qml 3 | * 4 | * Author: Daniele (b0unc3) Maio 5 | */ 6 | 7 | import bb.cascades 1.0 8 | import bb.data 1.0 9 | import bb.system 1.0 10 | 11 | Page { 12 | id: blp 13 | 14 | property string blogid: "" 15 | property string blogurl: "" 16 | 17 | property string mystr; 18 | property alias bl_xml: blp.mystr 19 | 20 | actions: [ 21 | MultiSelectActionItem { 22 | id: msa 23 | multiSelectHandler: listView.multiSelectHandler 24 | title: qsTr("select blog(s)") 25 | } 26 | ] 27 | 28 | attachedObjects: [ 29 | SystemToast { 30 | id: myQmlToast 31 | body: qsTr("Unable to register account\nPlease try again.") 32 | button.label: "Ok" 33 | button.enabled: true 34 | } 35 | 36 | ] 37 | 38 | function moveOn() 39 | { 40 | navigationPane.mb = true; 41 | navigationPane.pop(); 42 | } 43 | 44 | onMystrChanged: { 45 | listView.setDataModel(wpu.setModel(mystr)); 46 | } 47 | 48 | content: Container { 49 | layout: DockLayout {} 50 | 51 | ListView { 52 | id: listView 53 | multiSelectAction: MultiSelectActionItem { } 54 | 55 | 56 | multiSelectHandler { 57 | status: qsTr("None selected"); 58 | actions: [ 59 | ActionItem { 60 | title: qsTr("add selected") 61 | imageSource: "asset:///images/add.png" 62 | 63 | onTriggered: { 64 | if (enabled) { 65 | var selectionList = listView.selectionList(); 66 | for (var i = 0; i < selectionList.length; i ++) { 67 | var selectedItem = listView.dataModel.data(selectionList[i]); 68 | wpu.setBlogsInfo(selectedItem.blogid, selectedItem.xmlrpc); 69 | 70 | moveOn(); 71 | } 72 | 73 | } 74 | } 75 | } 76 | ] 77 | } 78 | 79 | onSelectionChanged: { 80 | if (selectionList().length > 1) { 81 | multiSelectHandler.status = selectionList().length + " blogs selected"; 82 | } else if (selectionList().length == 1) { 83 | multiSelectHandler.status = "1 blog selected"; 84 | } else { 85 | multiSelectHandler.status = "None selected"; 86 | } 87 | } 88 | 89 | listItemComponents: [ 90 | ListItemComponent { 91 | type: "item" 92 | StandardListItem { 93 | id: bitem 94 | imageSpaceReserved: false 95 | textFormat: TextFormat.Html 96 | title: qsTr(ListItemData.blogName) 97 | description: ListItemData.url 98 | 99 | 100 | 101 | } // end of second ListItemComponent 102 | } // end standardlistitem 103 | ] // end of listItemComponents list 104 | 105 | 106 | onTriggered: { 107 | var selectedItem = listView.dataModel.data(indexPath); 108 | blogid = selectedItem.blogid; 109 | blogurl = selectedItem.xmlrpc; 110 | } 111 | } // end of ListView 112 | } // end of Container 113 | } 114 | 115 | -------------------------------------------------------------------------------- /assets/showPost.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * showPost.qml 3 | * 4 | * Author: Daniele (b0unc3) Maio 5 | */ 6 | 7 | import bb.cascades 1.2 8 | 9 | Page { 10 | 11 | id: sp 12 | 13 | property string sp_postid 14 | property alias sp_apostid: sp.sp_postid 15 | property variant sp_myObj 16 | 17 | property bool post_show_page; 18 | property bool show_img: false 19 | 20 | onCreationCompleted: { 21 | /* hack to avoid app crash on 10.2.0.429 */ 22 | webView.html = "\"desc\""; 23 | } 24 | 25 | onSp_postidChanged: { 26 | wpu.buildWPXML("wp.getPost", true, ["post_id"], [sp.sp_postid], [], []); 27 | /* assumes pages and posts are treated at the same way **/ 28 | // wpu.getPost(sp.post_show_page, sp.sp_postid); 29 | // if ( sp.post_show_page ) 30 | // wpu.dataReady_getPage.connect(sp.sp_onDataReady); 31 | // else 32 | wpu.dataReady_getPost.connect(sp.sp_onDataReady); 33 | } 34 | 35 | function sp_onDataReady() { 36 | //aspe` 37 | sp_myObj = wpu.getRes(); 38 | if ( sp_myObj.post_content.indexOf("img") != -1 ) 39 | sp.show_img = true; 40 | else webView.settings.viewport = { "initial-scale" : 1.0} 41 | 42 | if ( spind.running ) 43 | spind.stop(); 44 | 45 | webView.html = getWebViewText(); 46 | 47 | } 48 | 49 | function getLabelText() 50 | { 51 | var res = ""; 52 | if ( sp_myObj ) 53 | { 54 | if ( !sp.show_img ) 55 | return "" + qsTr(sp_myObj.post_content) + "" 56 | } 57 | 58 | return res 59 | } 60 | 61 | function getWebViewText() { 62 | if (sp_myObj) { 63 | if ( sp.show_img ) 64 | return "" + qsTr(sp_myObj.post_content) + "" 65 | else return "" + qsTr(sp_myObj.post_content) + ""; 66 | } 67 | } 68 | 69 | actionBarVisibility: ChromeVisibility.Visible 70 | 71 | actions: [ 72 | InvokeActionItem { 73 | ActionBar.placement: ActionBarPlacement.OnBar 74 | query { 75 | mimeType: "text/plain" 76 | invokeActionId: "bb.action.SHARE" 77 | } 78 | onTriggered: { 79 | data = sp_myObj.post_title + "\n" + sp_myObj.link; 80 | } 81 | } 82 | ] 83 | 84 | 85 | titleBar: TitleBar { 86 | title: (sp_myObj) ? qsTr(sp_myObj.post_title) : "" 87 | } 88 | content: ScrollView { 89 | verticalAlignment: VerticalAlignment.Fill 90 | 91 | topMargin: 30 92 | bottomMargin: 30 93 | leftMargin: 30 94 | rightMargin: 30 95 | 96 | scrollViewProperties { 97 | scrollMode: ScrollMode.Both 98 | pinchToZoomEnabled: true 99 | maxContentScale: 5 100 | minContentScale: 0.5 101 | } 102 | 103 | Container { 104 | layout: DockLayout { } 105 | 106 | ActivityIndicator { 107 | id: spind 108 | horizontalAlignment: HorizontalAlignment.Center 109 | verticalAlignment: VerticalAlignment.Center 110 | 111 | preferredHeight: 500 112 | preferredWidth: 500 113 | 114 | running: true 115 | } 116 | 117 | Container { 118 | layout: StackLayout { } 119 | 120 | verticalAlignment: VerticalAlignment.Fill 121 | 122 | topMargin: 15 123 | bottomMargin: 15 124 | leftMargin: 15 125 | rightMargin: 15 126 | topPadding: 15 127 | bottomPadding: 15 128 | rightPadding: 15 129 | leftPadding: 15 130 | 131 | WebView { 132 | id: webView 133 | preferredWidth: 738 134 | settings.activeTextEnabled: true 135 | settings.defaultFontSize: 18 136 | settings.imageDownloadingEnabled: true 137 | settings.textAutosizingEnabled: true 138 | } 139 | } 140 | } 141 | 142 | } 143 | 144 | } 145 | -------------------------------------------------------------------------------- /src/WPUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * WPUtils.h 3 | * 4 | * Author: Daniele (b0unc3) Maio 5 | */ 6 | 7 | #ifndef WPUTILS_H_ 8 | #define WPUTILS_H_ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | /* TO BE ROMEVED, USE QXml* */ 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #include 33 | 34 | #include 35 | 36 | #include 37 | 38 | #include 39 | 40 | #include 41 | #include 42 | 43 | #include 44 | 45 | #include 46 | #include 47 | 48 | #include "GlobalContext.hpp" 49 | 50 | 51 | using namespace bb::data; 52 | using namespace bb::cascades; //? 53 | 54 | 55 | class WPUtils: public QObject { 56 | Q_OBJECT 57 | 58 | public: 59 | QVariantMap res; 60 | bb::cascades::GroupDataModel *model; 61 | 62 | 63 | WPUtils(QObject *parent = 0); 64 | virtual ~WPUtils(); 65 | 66 | Q_INVOKABLE void buildWPXML(QString, bool, QStringList, QStringList, QStringList, QStringList); 67 | 68 | Q_INVOKABLE void getBlogs(QString, QString, QString); 69 | 70 | Q_INVOKABLE void setBlogsInfo(QString,QString); 71 | 72 | // Q_INVOKABLE void getCategories(); // <-- unused 73 | 74 | Q_INVOKABLE void uploadFile(QString); 75 | Q_INVOKABLE bb::cascades::GroupDataModel *setModel(QByteArray); /* should be getModel, since the model is setted in another func */ 76 | QString searchEndPoint(QString); 77 | 78 | /* maybe temporary */ 79 | Q_INVOKABLE QMap getRes() { return res; } 80 | Q_INVOKABLE void resetRes() { res.clear(); } 81 | Q_INVOKABLE void setUsername(QString u) { _username = u; } 82 | Q_INVOKABLE void setPassword(QString p) { _password = p; } 83 | 84 | Q_INVOKABLE void setPosition(int p) { _position = p; } 85 | Q_INVOKABLE bool blogsInfo(); 86 | Q_INVOKABLE void getBlogsInfo(); 87 | Q_INVOKABLE void setCurrentBlog(QString, QString); 88 | Q_INVOKABLE QString getCurrentBlog(); 89 | Q_INVOKABLE bool info_registered(); 90 | Q_INVOKABLE QMap getBI(); 91 | 92 | /* crypt/decrypt stuff */ 93 | Q_INVOKABLE QString generate(); 94 | Q_INVOKABLE QString encrypt(QString); 95 | Q_INVOKABLE QString decrypt(QString); 96 | /***********************/ 97 | 98 | 99 | private: 100 | int _position; 101 | bool _info_registered; 102 | static const QString dbName; 103 | QMap _blogs; 104 | QString _totbid; 105 | QString _totburl; 106 | QString _endpoint; 107 | QString _url; 108 | QEventLoop _loop; 109 | QByteArray _xml; 110 | QString _username; 111 | QString _password; 112 | QString _blogid; 113 | QString _emit; 114 | QSqlDatabase _db; 115 | 116 | 117 | int getPosition(); //<--- TBR 118 | QString sanitize(QString); 119 | bool validate(QString); 120 | void getRegisteredData(); 121 | 122 | /* crypt/decrypt stuff */ 123 | GlobalContext globalContext; 124 | QString _key; 125 | QString _iv; 126 | bool fromHex(const QString in, QByteArray & out); 127 | QString toHex(const QByteArray & in); 128 | 129 | void pad(QByteArray & in); 130 | bool removePadding(QByteArray & out); 131 | 132 | bool crypt(bool isEncrypt, const QByteArray & in, QByteArray & out); 133 | char nibble(char); 134 | /***********************/ 135 | 136 | 137 | signals: 138 | void dataReady(QByteArray); //QVariant);//QString); 139 | 140 | void dataReady_getUsersBlogs(); 141 | void dataReady_getBlogs(QByteArray); 142 | 143 | void dataReady_getPosts(); 144 | void dataReady_getPost(); 145 | void dataReady_viewPost(); 146 | void dataReady_editPost(); 147 | void dataReady_delPost(); 148 | void dataReady_newPost(); 149 | 150 | void dataReady_getComments(); 151 | void dataReady_getComment(); 152 | void dataReady_newComment(); 153 | void dataReady_viewComment(); 154 | void dataReady_editComment(); 155 | void dataReady_delComment(); 156 | 157 | void dataReady_getPages(); 158 | void dataReady_getPage(); 159 | void dataReady_viewPage(); 160 | void dataReady_editPage(); 161 | void dataReady_delPage(); 162 | void dataReady_newPage(); 163 | 164 | void blogsReady(QHash); 165 | private slots: 166 | void replyFinished(QNetworkReply*); 167 | void repFinished(QNetworkReply*); 168 | void checkForPingback(QNetworkReply*); 169 | 170 | }; 171 | 172 | #endif /* WPUTILS_H_ */ 173 | -------------------------------------------------------------------------------- /assets/editcomment.qml: -------------------------------------------------------------------------------- 1 | import bb.cascades 1.0 2 | 3 | Page { 4 | id: ecp 5 | 6 | actionBarVisibility: ChromeVisibility.Visible 7 | 8 | property string ec_comment_id; 9 | property variant ec_cinfos; 10 | 11 | onEc_comment_idChanged: { 12 | wpu.buildWPXML("wp.getComment", true, ["post_id"], [ec_comment_id], [], []); 13 | wpu.dataReady_getComment.connect(ecp.ec_onDataReady); 14 | } 15 | 16 | function ec_onDataReady() 17 | { 18 | var ec_a = wpu.getRes(); 19 | 20 | if ( ec_a['delpost'] ) 21 | { 22 | ec_ci.close(); 23 | navcommentspane.pop(); 24 | navcommentspane.firstPage.comment_init(); 25 | 26 | } else { 27 | ec_cinfos = ec_a; 28 | edind.stop(); 29 | } 30 | } 31 | 32 | actions: [ 33 | ActionItem { 34 | title: qsTr("Edit") 35 | imageSource: "asset:///images/save.png" 36 | ActionBar.placement: ActionBarPlacement.OnBar 37 | 38 | 39 | onTriggered: { 40 | //crude (in)sanity check 41 | if ( auth.text != "" && authmail.text !="" && authurl.text != "" && ccontent.text !="" && cstate.selectedValue != "" ) 42 | { 43 | ec_ci.body = qsTr("Making changes\nPlease wait..."); 44 | ec_ci.open(); 45 | wpu.buildWPXML("wp.editComment", true, ["comment_id"], [ec_comment_id], ["status", "content", "author", "author_email", "author_url"], [cstate.selectedValue, ccontent.text, auth.text, authmail.text, authurl.text] ); 46 | wpu.dataReady_editComment.connect(ecp.ec_onDataReady); 47 | } 48 | } 49 | } 50 | ] 51 | 52 | attachedObjects: [ 53 | CustomIndicator { 54 | id: ec_ci 55 | } 56 | ] 57 | 58 | titleBar: TitleBar { 59 | title: qsTr("Edit Comment") 60 | } 61 | 62 | content: Container { 63 | layout: DockLayout { } 64 | 65 | 66 | 67 | Container { 68 | layout: StackLayout { 69 | orientation: LayoutOrientation.TopToBottom 70 | } 71 | 72 | topMargin: 25 73 | bottomMargin: 25 74 | rightMargin: 25 75 | leftMargin: 25 76 | topPadding: 25 77 | bottomPadding: 25 78 | rightPadding: 25 79 | leftPadding: 25 80 | 81 | Label { 82 | text: qsTr("Author"); 83 | } 84 | TextField { 85 | id: auth 86 | text: (ec_cinfos) ? qsTr(ec_cinfos.author) : "" 87 | } 88 | Label { 89 | text: qsTr("Author e-mail") 90 | } 91 | TextField { 92 | id: authmail 93 | text: (ec_cinfos) ? qsTr(ec_cinfos.author_email) : "" 94 | } 95 | Label { 96 | text: qsTr("Author url") 97 | } 98 | TextField { 99 | id: authurl 100 | text: (ec_cinfos) ? qsTr(ec_cinfos.author_url) : "" 101 | } 102 | Label { 103 | text: qsTr("Content") 104 | } 105 | TextArea { 106 | id: ccontent 107 | minHeight: 150 108 | preferredHeight: 200 109 | text: (ec_cinfos) ? qsTr(ec_cinfos.content) : "" 110 | } 111 | Divider { 112 | 113 | } 114 | DropDown { 115 | id: cstate 116 | title: qsTr("State") 117 | 118 | Option { 119 | value: "approve" 120 | text: qsTr("Approved") 121 | selected: (ec_cinfos) ? (value == ec_cinfos.status) : false 122 | } 123 | Option { 124 | value: "hold" 125 | text: qsTr("Waiting for approve") 126 | selected: (ec_cinfos) ? (value == ec_cinfos.status) : false 127 | } 128 | Option { 129 | value: "spam" 130 | text: qsTr("Spam") 131 | selected: (ec_cinfos) ? (value == ec_cinfos.status) : false 132 | } 133 | } 134 | Divider { 135 | 136 | } 137 | } 138 | ActivityIndicator { 139 | id: edind 140 | horizontalAlignment: HorizontalAlignment.Center 141 | verticalAlignment: VerticalAlignment.Bottom 142 | 143 | preferredHeight: 500 144 | preferredWidth: 500 145 | 146 | running: true 147 | } 148 | } 149 | } 150 | 151 | -------------------------------------------------------------------------------- /bar-descriptor.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 26 | 27 | 29 | WordPress 30 | 31 | 33 | WordPress 34 | 35 | 38 | 1.0.0 39 | 40 | 42 | 1 43 | 44 | 45 | 46 | 47 | 49 | The WordPress mobile app for BlackBerry 10 devices. 50 | 51 | 52 | 53 | 54 | 55 | Daniele (b0unc3) Maio 56 | gYAAgDgPZJ7fUOQgacNxC0t_Vyw 57 | 58 | 59 | 60 | 61 | 62 | portrait 63 | false 64 | none 65 | false 66 | 67 | 68 | 69 | core.games 70 | 71 | armle-v7 72 | wp_bb10 73 | 74 | 75 | Qnx/Cascades 76 | armle-v7 77 | wp_bb10.so 78 | 79 | 80 | armle-v7 81 | wp_bb10 82 | 83 | 84 | x86 85 | wp_bb10 86 | 87 | 88 | 89 | 90 | icon.png 91 | 92 | 93 | icon.png 94 | assets 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | assets/wplogo.png 103 | 104 | assets/posts.png 105 | 106 | 107 | run_native 108 | access_shared 109 | access_internet 110 | use_camera 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /assets/720x720/Login.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Login.qml 3 | * 4 | * Author: Daniele (b0unc3) Maio 5 | */ 6 | 7 | import bb.cascades 1.0 8 | import bb.system 1.0 9 | 10 | Page { 11 | id: lp 12 | 13 | actionBarVisibility: ChromeVisibility.Hidden 14 | 15 | attachedObjects: [ 16 | ComponentDefinition { 17 | id: pageDefinition 18 | source: "blogslist.qml" 19 | }, 20 | ComponentDefinition { 21 | id: polist 22 | source: "postslist.qml" 23 | }, 24 | SystemToast { 25 | id: myQmlToast 26 | body: "Unable to register account\nPlease try again." 27 | button.label: "Ok" 28 | button.enabled: true 29 | } 30 | 31 | ] 32 | 33 | function onDataReady() { 34 | var a = wpu.getRes(); 35 | 36 | if (a["ERROR"]) { 37 | myQmlToast.show(); 38 | usr.text = ''; 39 | pwd.text = ''; 40 | blgd.text = ''; 41 | si.enabled = true 42 | si.imageSource = ''; 43 | // wpu.resetRes(); 44 | } else if ( a["oneblog"] ) { 45 | wpu.setUsername(usr.text); 46 | wpu.setPassword(pwd.text); 47 | 48 | navigationPane.pop(); 49 | /* 50 | var ppost_ = polist.createObject(); 51 | ppost_.post_showpage = false; 52 | navpostpane.push(ppost_); 53 | ppost_.post_loadData(); 54 | */ 55 | wpu.resetRes(); 56 | } 57 | else { 58 | wpu.setUsername(usr.text); 59 | wpu.setPassword(pwd.text); 60 | 61 | var newPage = pageDefinition.createObject(); 62 | newPage.bl_xml = "val"; 63 | 64 | si.imageSource = ''; 65 | si.enabled = true 66 | usr.text = ''; 67 | pwd.text = ''; 68 | blgd.text = ''; 69 | 70 | navigationPane.push(newPage); 71 | } 72 | 73 | } 74 | 75 | Container { 76 | layout: DockLayout { } 77 | ScrollView { 78 | Container { 79 | layout: StackLayout { 80 | } 81 | 82 | Container { 83 | verticalAlignment: VerticalAlignment.Top 84 | horizontalAlignment: HorizontalAlignment.Center 85 | layout: StackLayout { 86 | } 87 | 88 | //header - logo 89 | ImageView { 90 | imageSource: "asset:///images/wplogo.png" 91 | minHeight: 211; 92 | preferredHeight: 211; 93 | } 94 | } 95 | Container { 96 | verticalAlignment: VerticalAlignment.Center 97 | horizontalAlignment: HorizontalAlignment.Center 98 | layout: StackLayout { 99 | } 100 | 101 | topPadding: 50 102 | leftPadding: 50 103 | rightPadding: 50 104 | bottomPadding: 50 105 | 106 | Label { 107 | text: qsTr("Username") 108 | } 109 | 110 | TextField { 111 | id: usr 112 | clearButtonVisible: true 113 | hintText: qsTr("username") 114 | 115 | input.flags: TextInputFlag.AutoCapitalizationOff 116 | } 117 | 118 | Label { 119 | topMargin: 50 120 | text: qsTr("Password") 121 | } 122 | 123 | TextField { 124 | id: pwd 125 | inputMode: TextFieldInputMode.Password 126 | 127 | hintText: qsTr("YouRpAsSwOrD") 128 | } 129 | 130 | Label { 131 | topMargin: 50 132 | text: qsTr("Blog Address") 133 | } 134 | 135 | TextField { 136 | id: blgd 137 | 138 | hintText: qsTr("leave empty if unsure") 139 | input.flags: TextInputFlag.AutoCapitalizationOff 140 | 141 | } 142 | } 143 | Container { 144 | verticalAlignment: VerticalAlignment.Bottom 145 | horizontalAlignment: HorizontalAlignment.Center 146 | layout: StackLayout { 147 | } 148 | 149 | topPadding: 50 150 | //bottomPadding: 25//50 151 | Button { 152 | id: si 153 | text: qsTr("Sign In") 154 | 155 | onClicked: { 156 | if (usr.text && pwd.text) { 157 | si.imageSource = "asset:///images/loading.gif"; 158 | si.enabled = false; 159 | wpu.setUsername(usr.text); 160 | wpu.setPassword(pwd.text); 161 | wpu.getBlogs(usr.text, pwd.text, blgd.text); 162 | wpu.dataReady_getUsersBlogs.connect(lp.onDataReady); 163 | } else {; /*** TODO ***/ 164 | } 165 | } 166 | 167 | } 168 | } 169 | } 170 | } 171 | } 172 | } 173 | 174 | 175 | -------------------------------------------------------------------------------- /assets/Login.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Login.qml 3 | * 4 | * Author: Daniele (b0unc3) Maio 5 | */ 6 | 7 | import bb.cascades 1.0 8 | import bb.system 1.0 9 | 10 | Page { 11 | id: lp 12 | 13 | actionBarVisibility: ChromeVisibility.Hidden 14 | 15 | attachedObjects: [ 16 | ComponentDefinition { 17 | id: pageDefinition 18 | source: "blogslist.qml" 19 | }, 20 | ComponentDefinition { 21 | id: polist 22 | source: "postslist.qml" 23 | }, 24 | SystemToast { 25 | id: myQmlToast 26 | body: "Unable to register account\nPlease try again." 27 | button.label: "Ok" 28 | button.enabled: true 29 | } 30 | 31 | ] 32 | 33 | function onDataReady() { 34 | var a = wpu.getRes(); 35 | 36 | if (a["ERROR"]) { 37 | myQmlToast.show(); 38 | usr.text = ''; 39 | pwd.text = ''; 40 | blgd.text = ''; 41 | si.enabled = true 42 | si.imageSource = ''; 43 | // wpu.resetRes(); 44 | } else if ( a["oneblog"] ) { 45 | wpu.setUsername(usr.text); 46 | wpu.setPassword(pwd.text); 47 | 48 | navigationPane.pop(); 49 | /* 50 | var ppost_ = polist.createObject(); 51 | ppost_.post_showpage = false; 52 | navpostpane.push(ppost_); 53 | ppost_.post_loadData(); 54 | */ 55 | wpu.resetRes(); 56 | } 57 | else { 58 | wpu.setUsername(usr.text); 59 | wpu.setPassword(pwd.text); 60 | 61 | var newPage = pageDefinition.createObject(); 62 | newPage.bl_xml = "val"; 63 | 64 | si.imageSource = ''; 65 | si.enabled = true 66 | usr.text = ''; 67 | pwd.text = ''; 68 | blgd.text = ''; 69 | 70 | navigationPane.push(newPage); 71 | } 72 | 73 | } 74 | 75 | Container { 76 | layout: DockLayout { } 77 | ScrollView { 78 | Container { 79 | layout: StackLayout { 80 | } 81 | 82 | Container { 83 | verticalAlignment: VerticalAlignment.Top 84 | horizontalAlignment: HorizontalAlignment.Center 85 | layout: StackLayout { 86 | } 87 | 88 | //header - logo 89 | ImageView { 90 | imageSource: "asset:///images/wplogo.png" 91 | minHeight: 422; 92 | preferredHeight: 422; 93 | } 94 | } 95 | Container { 96 | verticalAlignment: VerticalAlignment.Center 97 | horizontalAlignment: HorizontalAlignment.Center 98 | layout: StackLayout { 99 | } 100 | 101 | topPadding: 50 102 | leftPadding: 50 103 | rightPadding: 50 104 | bottomPadding: 50 105 | 106 | Label { 107 | text: qsTr("Username") 108 | } 109 | 110 | TextField { 111 | id: usr 112 | clearButtonVisible: true 113 | hintText: qsTr("username") 114 | 115 | input.flags: TextInputFlag.AutoCapitalizationOff 116 | } 117 | 118 | Label { 119 | topMargin: 50 120 | text: qsTr("Password") 121 | } 122 | 123 | TextField { 124 | id: pwd 125 | inputMode: TextFieldInputMode.Password 126 | 127 | hintText: qsTr("YouRpAsSwOrD") 128 | } 129 | 130 | Label { 131 | topMargin: 50 132 | text: qsTr("Blog Address") 133 | } 134 | 135 | TextField { 136 | id: blgd 137 | 138 | hintText: qsTr("leave empty if unsure") 139 | input.flags: TextInputFlag.AutoCapitalizationOff 140 | 141 | } 142 | } 143 | Container { 144 | verticalAlignment: VerticalAlignment.Bottom 145 | horizontalAlignment: HorizontalAlignment.Center 146 | layout: StackLayout { 147 | } 148 | 149 | topPadding: 50 150 | //bottomPadding: 25//50 151 | Button { 152 | id: si 153 | text: qsTr("Sign In") 154 | 155 | onClicked: { 156 | if (usr.text && pwd.text) { 157 | si.imageSource = "asset:///images/loading.gif"; 158 | si.enabled = false; 159 | wpu.setUsername(usr.text); 160 | wpu.setPassword(pwd.text); 161 | wpu.getBlogs(usr.text, pwd.text, blgd.text); 162 | wpu.dataReady_getUsersBlogs.connect(lp.onDataReady); 163 | } else {; /*** TODO ***/ 164 | } 165 | } 166 | 167 | } 168 | } 169 | } 170 | } 171 | } 172 | } 173 | 174 | 175 | -------------------------------------------------------------------------------- /assets/makePost.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * makePost.qml 3 | * 4 | * Author: Daniele (b0unc3) Maio 5 | */ 6 | 7 | import bb.cascades 1.0 8 | import bb.system 1.0 9 | import bb.cascades.pickers 1.0 10 | 11 | Page { 12 | id: mp_mpp 13 | 14 | property bool post_showpage; 15 | 16 | attachedObjects: [ 17 | CustomIndicator { 18 | id: mp_ci 19 | }, 20 | SystemProgressToast { 21 | id: mp_spt 22 | progress: -1 23 | body: qsTr("Creating the new post, please wait"); 24 | state: SystemUiProgressState.Active 25 | }, 26 | FilePicker { 27 | id: mp_filePicker 28 | type: FileType.Picture 29 | title: qsTr("Select Picture") 30 | mode: FilePickerMode.Picker 31 | onFileSelected: { 32 | wpu.uploadFile(selectedFiles[0]); 33 | wpu.dataReady.connect(mp_mpp.mp_onDataReady); 34 | mp_ci.body = qsTr("Uploading picture\nplease wait..."); 35 | mp_ci.open(); 36 | } 37 | } 38 | 39 | ] 40 | 41 | actions: [ 42 | ActionItem { 43 | title: qsTr("Save") 44 | imageSource: "asset:///images/save.png" 45 | ActionBar.placement: ActionBarPlacement.OnBar 46 | 47 | onTriggered: { 48 | if ( posttitle.text, postcontent.text, poststatus.selectedValue ) 49 | { 50 | mp_ci.body = qsTr("Creating the new " +((mp_mpp.post_showpage) ? "page" : "post") + "\nplaease wait..."); 51 | mp_ci.open(); 52 | wpu.buildWPXML("wp.newPost", true, [], [], ["post_type", "post_status", "post_title", "post_content"], [ ( (mp_mpp.post_showpage) ? "page" : ((posttype.selectedValue) ? posttype.selectedValue : "" ) ), poststatus.selectedValue, posttitle.text, postcontent.text.trim()] ); 53 | if ( mp_mpp.post_showpage ) 54 | wpu.dataReady_newPage.connect(mp_mpp.mp_onDataReady); 55 | else wpu.dataReady_newPost.connect(mp_mpp.mp_onDataReady); 56 | } else { 57 | mp_spt.body = qsTr('Insufficient parameters to make a new post!'); 58 | mp_spt.exec(); 59 | } 60 | } 61 | }, 62 | ActionItem { 63 | title: qsTr("Add Image"); 64 | imageSource: "asset:///images/addimage.png" 65 | ActionBar.placement: ActionBarPlacement.OnBar 66 | 67 | onTriggered: { 68 | mp_filePicker.open(); 69 | } 70 | } 71 | 72 | ] 73 | 74 | function mp_onDataReady() 75 | { 76 | var mp_a = wpu.getRes(); 77 | 78 | if (mp_a['newpostid'] ) 79 | { 80 | mp_ci.close(); 81 | if ( !post_showpage ) 82 | { 83 | navpostpane.pop(); 84 | navpostpane.firstPage.post_loadData(); 85 | } else { 86 | navpagepane.pop(); 87 | navpagepane.firstPage.post_loadData(); 88 | } 89 | } else if (mp_a['file'] ) 90 | { 91 | postcontent.editor.insertPlainText("\"desc\""); // width=\"480\" height=\"800\" class=\"aligncenter\" />"); 92 | mp_ci.close(); 93 | } else console.log("wrg : smtg wrong"); /* TODO */ 94 | 95 | wpu.resetRes(); 96 | } 97 | 98 | paneProperties: NavigationPaneProperties { 99 | backButton: ActionItem { 100 | onTriggered: { 101 | if ( postcontent.text.length > 0 ) 102 | { 103 | warningDialog.show(); 104 | } else { 105 | if ( !post_showpage ) 106 | navpostpane.pop(); 107 | else navpagepane.pop(); 108 | } 109 | } 110 | } 111 | } 112 | 113 | 114 | titleBar: TitleBar { 115 | title: (!post_showpage) ? qsTr("New Post") : qsTr("New Page") 116 | } 117 | 118 | content: Container { 119 | layout: StackLayout { } 120 | 121 | TextField { 122 | horizontalAlignment: HorizontalAlignment.Fill 123 | id: posttitle 124 | 125 | hintText: qsTr("Post Title"); 126 | } 127 | 128 | TextArea { 129 | id: postcontent 130 | editable: true 131 | hintText: qsTr("Post Content"); 132 | 133 | minHeight: 150 134 | preferredHeight: 400 135 | } 136 | Divider { 137 | 138 | 139 | } 140 | /* 141 | TextField { 142 | horizontalAlignment: HorizontalAlignment.Fill 143 | id: posttags 144 | hintText: qsTr("Post tags (Separate tags with commas)"); 145 | } 146 | 147 | 148 | 149 | * ***FIXME*** 150 | * not yet fully implemented 151 | Button { 152 | text: qsTr("Categories") 153 | 154 | onClicked: { 155 | customdialogcat.open(); 156 | } 157 | } 158 | */ 159 | 160 | DropDown { 161 | id: poststatus 162 | title: qsTr("Status") 163 | 164 | Option { 165 | text: qsTr("Draft") 166 | value: "draft" 167 | selected: true 168 | } 169 | Option { 170 | text: qsTr("Pending") 171 | value: "pending" 172 | } 173 | Option { 174 | text: qsTr("Public"); 175 | value: "publish" 176 | } 177 | Option { 178 | text: qsTr("Private"); 179 | value: "private" 180 | } 181 | } 182 | 183 | DropDown { 184 | id: posttype 185 | title: qsTr("Format"); 186 | visible: !post_showpage 187 | 188 | Option { 189 | text: qsTr("Standard"); 190 | value: "post" 191 | selected: true 192 | } 193 | Option { 194 | text: qsTr("Aside"); 195 | value: "aside" 196 | } 197 | Option { 198 | text: qsTr("Image"); 199 | value: "image" 200 | } 201 | Option { 202 | text: qsTr("Video"); 203 | value: "video" 204 | } 205 | Option { 206 | text: qsTr("Quote"); 207 | value: "quote" 208 | } 209 | Option { 210 | text: qsTr("Link"); 211 | value: "link" 212 | } 213 | } 214 | 215 | } 216 | } 217 | 218 | -------------------------------------------------------------------------------- /assets/editpost.qml: -------------------------------------------------------------------------------- 1 | import bb.cascades 1.0 2 | import bb.cascades.pickers 1.0 3 | 4 | Page { 5 | id: ep 6 | 7 | property string post_id; 8 | property variant pinfos 9 | property bool textHasChanged : true; 10 | 11 | property bool post_showpage; 12 | 13 | onPost_idChanged: { 14 | wpu.buildWPXML("wp.getPost", true, ["post_id"], [post_id], ["post_type"], [((ep.post_showpage) ? "page" : "post")]); 15 | if ( ep.post_showpage ) 16 | wpu.dataReady_getPage.connect(ep.ep_onDataReady); 17 | else wpu.dataReady_getPost.connect(ep.ep_onDataReady); 18 | } 19 | 20 | function ep_onDataReady() { 21 | var ep_a = wpu.getRes(); 22 | if (ep_a['delpost'] ) 23 | { 24 | ci_ep.close(); 25 | if ( !post_showpage ) 26 | { 27 | navpostpane.pop(); 28 | navpostpane.firstPage.post_loadData(); 29 | } else { 30 | navpagepane.pop(); 31 | navpagepane.firstPage.post_loadData(); 32 | } 33 | } else if (ep_a['file']) { 34 | pcontent.editor.insertPlainText("\"desc\""); // width=\"480\" height=\"800\" class=\"aligncenter\" />"); 35 | ci_ep.close(); 36 | } else { 37 | pinfos = ep_a; 38 | epind.stop(); 39 | } 40 | } 41 | 42 | paneProperties: NavigationPaneProperties { 43 | backButton: ActionItem { 44 | onTriggered: { 45 | if ( textHasChanged ) 46 | { 47 | warningDialog.show(); 48 | } else { 49 | if ( !post_showpage ) 50 | navpostpane.pop(); 51 | else navpagepane.pop(); 52 | } 53 | } 54 | } 55 | } 56 | 57 | attachedObjects: [ 58 | CustomIndicator { 59 | id: ci_ep 60 | }, 61 | FilePicker { 62 | id: ep_filePicker 63 | type: FileType.Picture 64 | title: qsTr("Select Picture") 65 | mode: FilePickerMode.Picker 66 | onFileSelected: { 67 | wpu.uploadFile(selectedFiles[0]); 68 | wpu.dataReady.connect(ep.ep_onDataReady); 69 | ci_ep.body = qsTr("Uploading picture\nplease wait..."); 70 | ci_ep.open(); 71 | } 72 | } 73 | ] 74 | 75 | actions: [ 76 | ActionItem { 77 | title: qsTr("Edit") 78 | imageSource: "asset:///images/save.png" 79 | ActionBar.placement: ActionBarPlacement.OnBar 80 | 81 | onTriggered: { 82 | if ( ptitle.text != "" && pcontent.text != "" && pstate.selectedValue != "" && pformat.selectedValue != "" ) 83 | { 84 | ci_ep.body = qsTr("Editing post\nPlease wait..."); 85 | ci_ep.open(); 86 | wpu.buildWPXML("wp.editPost", true, ["post_id"], [ep.post_id], ["post_title", "post_content", "post_status", "post_format", "post_type"], [ptitle.text, pcontent.text, pstate.selectedValue, pformat.selectedValue, (ep.post_showpage) ? "page" : "post"] ); 87 | if ( ep.post_showpage ) 88 | wpu.dataReady_editPage.connect(ep.ep_onDataReady); 89 | else wpu.dataReady_editPost.connect(ep.ep_onDataReady); 90 | } 91 | } 92 | }, 93 | ActionItem { 94 | title: qsTr("Add Image") 95 | imageSource: "asset:///images/addimage.png" 96 | ActionBar.placement: ActionBarPlacement.OnBar 97 | 98 | onTriggered: { 99 | ep_filePicker.open(); 100 | } 101 | } 102 | ] 103 | 104 | titleBar: TitleBar { 105 | title: (!post_showpage) ? qsTr("Edit Post") : qsTr("Edit Page") 106 | 107 | } 108 | 109 | content: Container { 110 | layout: DockLayout { } 111 | 112 | ActivityIndicator { 113 | id: epind 114 | horizontalAlignment: HorizontalAlignment.Center 115 | verticalAlignment: VerticalAlignment.Bottom 116 | 117 | preferredHeight: 500 118 | preferredWidth: 500 119 | 120 | running: true 121 | } 122 | 123 | Container { 124 | layout: StackLayout { 125 | orientation: LayoutOrientation.TopToBottom 126 | } 127 | 128 | topMargin: 15 129 | topPadding: 15 130 | bottomMargin: 15 131 | bottomPadding: 15 132 | rightMargin: 15 133 | rightPadding: 15 134 | leftMargin: 15 135 | leftPadding: 15 136 | 137 | TextField { 138 | id: ptitle 139 | text: (pinfos) ? qsTr(pinfos.post_title) : "" 140 | } 141 | TextArea { 142 | id: pcontent 143 | preferredHeight: 300 144 | text: (pinfos) ? qsTr(pinfos.post_content) : "" 145 | onTextChanged: { 146 | textHasChanged = !textHasChanged; 147 | } 148 | } 149 | /* 150 | * ***FIXME**** 151 | * to be implemented 152 | TextField { 153 | id: ptags 154 | text: pinfos.name 155 | } 156 | */ 157 | Divider { 158 | preferredHeight: 50 159 | } 160 | 161 | DropDown { 162 | id: pstate 163 | title: qsTr("Status") 164 | 165 | Option { 166 | text: qsTr("Draft") 167 | value: "draft" 168 | selected: (pinfos) ? (value == pinfos.post_status ) : false 169 | } 170 | Option { 171 | text: qsTr("Pending") 172 | value: "pending" 173 | selected: (pinfos) ? (value == pinfos.post_status ) : false 174 | } 175 | Option { 176 | text: qsTr("Public") 177 | value: "publish" 178 | selected: (pinfos) ? (value == pinfos.post_status ) : false 179 | } 180 | Option { 181 | text: qsTr("Private") 182 | value: "private" 183 | selected: (pinfos) ? (value == pinfos.post_status ) : false 184 | } 185 | } 186 | 187 | 188 | DropDown { 189 | id: pformat 190 | title: qsTr("Type") 191 | visible: !post_showpage 192 | selectedIndex: -1 193 | Option { 194 | text: qsTr("Standard") 195 | value: "post" 196 | selected: (pinfos) ? (value == pinfos.post_type ) : false 197 | } 198 | Option { 199 | text: qsTr("Aside") 200 | value: "aside" 201 | selected: (pinfos) ? (value == pinfos.post_type ) : false 202 | } 203 | Option { 204 | text: qsTr("Image") 205 | value: "image" 206 | selected: (pinfos) ? (value == pinfos.post_type ) : false 207 | } 208 | Option { 209 | text: qsTr("Video") 210 | value: "video" 211 | selected: (pinfos) ? (value == pinfos.post_type ) : false 212 | } 213 | Option { 214 | text: qsTr("Quote") 215 | value: "quote" 216 | selected: (pinfos) ? (value == pinfos.post_type ) : false 217 | } 218 | Option { 219 | text: qsTr("Link") 220 | value: "link" 221 | selected: (pinfos) ? (value == pinfos.post_type ) : false 222 | } 223 | } 224 | } 225 | } 226 | } 227 | 228 | -------------------------------------------------------------------------------- /translations/wp_bb10.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BlogsSelectionDialog 6 | 7 | Done 8 | 9 | 10 | 11 | 12 | CustomDialogCategories 13 | 14 | Done 15 | 16 | 17 | 18 | 19 | blogslist 20 | 21 | None selected 22 | 23 | 24 | 25 | 26 | commentslist 27 | 28 | DELETE COMMENT 29 | 30 | 31 | 32 | Cancel 33 | 34 | 35 | 36 | Are you sure to delete this comment? 37 | 38 | 39 | 40 | Yes 41 | 42 | 43 | 44 | 45 | editcomment 46 | 47 | Author 48 | 49 | 50 | 51 | Author e-mail 52 | 53 | 54 | 55 | Author url 56 | 57 | 58 | 59 | content 60 | 61 | 62 | 63 | State 64 | 65 | 66 | 67 | Approved 68 | 69 | 70 | 71 | Waiting for approve 72 | 73 | 74 | 75 | Spam 76 | 77 | 78 | 79 | Edit Comment 80 | 81 | 82 | 83 | 84 | editpost 85 | 86 | Status 87 | 88 | 89 | 90 | Public 91 | 92 | 93 | 94 | Private 95 | 96 | 97 | 98 | Standard 99 | 100 | 101 | 102 | Aside 103 | 104 | 105 | 106 | Image 107 | 108 | 109 | 110 | Video 111 | 112 | 113 | 114 | Quote 115 | 116 | 117 | 118 | Link 119 | 120 | 121 | 122 | Edit Post 123 | 124 | 125 | 126 | Edit Page 127 | 128 | 129 | 130 | 131 | main 132 | 133 | Change blog 134 | 135 | 136 | 137 | Posts 138 | 139 | 140 | 141 | Comments 142 | 143 | 144 | 145 | Pages 146 | 147 | 148 | 149 | 150 | makePost 151 | 152 | Creating the new post, please wait 153 | 154 | 155 | 156 | Select Picture 157 | 158 | 159 | 160 | Add Image 161 | 162 | 163 | 164 | New Post 165 | 166 | 167 | 168 | Post Title 169 | 170 | 171 | 172 | Post Content 173 | 174 | 175 | 176 | Status 177 | 178 | 179 | 180 | Public 181 | 182 | 183 | 184 | Private 185 | 186 | 187 | 188 | Format 189 | 190 | 191 | 192 | Standard 193 | 194 | 195 | 196 | Aside 197 | 198 | 199 | 200 | Image 201 | 202 | 203 | 204 | Video 205 | 206 | 207 | 208 | Quote 209 | 210 | 211 | 212 | Link 213 | 214 | 215 | 216 | New Page 217 | 218 | 219 | 220 | 221 | pageslist 222 | 223 | DELETE PAGE 224 | 225 | 226 | 227 | Are you sure to delete this page? 228 | 229 | 230 | 231 | Yes 232 | 233 | 234 | 235 | Cancel 236 | 237 | 238 | 239 | 240 | postslist 241 | 242 | Deleting post, please wait 243 | 244 | 245 | 246 | DELETE POST 247 | 248 | 249 | 250 | Cancel 251 | 252 | 253 | 254 | Yes 255 | 256 | 257 | 258 | 259 | -------------------------------------------------------------------------------- /assets/postslist.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * postslist.qml 3 | * 4 | * Author: Daniele (b0unc3) Maio 5 | */ 6 | 7 | import bb.cascades 1.0 8 | import bb.system 1.0 9 | 10 | Page { 11 | id: post_plp 12 | 13 | property bool post_showpage; 14 | property variant post_savemodel; 15 | property string post_type; 16 | 17 | 18 | onPost_showpageChanged: { 19 | if ( post_plp.post_showpage ) 20 | post_type = "page"; 21 | else post_type = "post" 22 | } 23 | 24 | function post_restoreItems() 25 | { 26 | if ( post_savemodel ) 27 | { 28 | post_plListView.setDataModel(null); 29 | post_plListView.setDataModel(post_savemodel); 30 | } else { 31 | post_plp.post_loadData(); 32 | } 33 | } 34 | 35 | function post_loadData() { 36 | if (post_plListView.dataModel) //plListView.dataModel.clear(); 37 | post_plListView.setDataModel(null); 38 | 39 | post_plind.start(); 40 | wpu.buildWPXML("wp.getPosts", true, [], [], ["post_type"], [post_type]); 41 | if ( post_plp.post_showpage ) 42 | wpu.dataReady_getPages.connect(post_plp.post_onDataReady); 43 | else wpu.dataReady_getPosts.connect(post_plp.post_onDataReady); 44 | } 45 | 46 | function post_onDataReady(val) { 47 | var d = new Date(); 48 | 49 | var post_pa = wpu.getRes(); 50 | 51 | if (post_pa["ERROR"]) { 52 | //myQmlToast.show(); 53 | console.log("ERRORE"); 54 | // wpu.resetRes(); 55 | } else if (post_pa["delpost"]) { 56 | if (post_pa["delpost"] == 1) { 57 | post_delDialog.cancel(); 58 | post_ci_pl.close(); 59 | post_plp.post_loadData(); 60 | } else console.log("delete fail"); 61 | 62 | } else { 63 | post_plListView.setDataModel(wpu.setModel("post_mystr")); 64 | post_plind.stop(); 65 | } 66 | 67 | } 68 | 69 | titleBar: TitleBar { 70 | title: (!post_plp.post_showpage ) ? qsTr("Posts") : qsTr("Pages") 71 | } 72 | 73 | attachedObjects: [ 74 | CustomIndicator { 75 | id: post_ci_pl 76 | }, 77 | SystemDialog { 78 | property string ptitle 79 | property string pid 80 | id: post_delDialog 81 | title: qsTr("DELETE POST") 82 | body: qsTr("Are you sure to delete post \"" + ptitle + "\" ?"); 83 | //id = " + pid) 84 | 85 | confirmButton.label: qsTr("Yes") 86 | confirmButton.enabled: true 87 | cancelButton.label: qsTr("Cancel") 88 | cancelButton.enabled: true 89 | onFinished: { 90 | var x = result; 91 | if (x == SystemUiResult.ConfirmButtonSelection) { 92 | post_ci_pl.body = qsTr("Deleting post \"" + ptitle + "\" \nPlease wait..."); 93 | post_ci_pl.open(); 94 | wpu.buildWPXML("wp.deletePost", true, ["post_id"], [pid], [], []); 95 | wpu.dataReady_delPost.connect(post_plp.post_onDataReady); 96 | /* 97 | wpu.deletePost(post_plp.post_showpage,pid); 98 | if ( post_plp.post_showpage ) 99 | wpu.dataReady_delPage.connect(post_plp.post_onDataReady); 100 | else wpu.dataReady_delPost.connect(post_plp.post_onDataReady); 101 | */ 102 | } else if (x == SystemUiResult.CancelButtonSelection) { 103 | console.log("cancel"); 104 | } 105 | } 106 | } 107 | ] 108 | 109 | actions: [ 110 | ActionItem { 111 | title: qsTr("New") 112 | imageSource: "asset:///images/add.png" 113 | ActionBar.placement: ActionBarPlacement.InOverflow 114 | 115 | onTriggered: { 116 | post_savemodel = post_plListView.dataModel; 117 | var newPage = post_makePost.createObject(); 118 | newPage.post_showpage = post_plp.post_showpage 119 | if (post_plp.post_showpage) 120 | navpagepane.push(newPage); 121 | else navpostpane.push(newPage); 122 | } 123 | }, 124 | ActionItem { 125 | title: qsTr("Refresh") 126 | imageSource: "asset:///images/refresh.png" 127 | 128 | ActionBar.placement: ActionBarPlacement.InOverflow 129 | 130 | onTriggered: { 131 | post_plp.post_loadData(); 132 | } 133 | } 134 | ] 135 | 136 | content: Container { 137 | layout: DockLayout { 138 | } 139 | 140 | ActivityIndicator { 141 | id: post_plind 142 | horizontalAlignment: HorizontalAlignment.Center 143 | verticalAlignment: VerticalAlignment.Center 144 | 145 | preferredHeight: 500 146 | preferredWidth: 500 147 | 148 | running: true 149 | } 150 | 151 | Container { 152 | layout: StackLayout { 153 | } 154 | 155 | ListView { 156 | id: post_plListView 157 | 158 | listItemComponents: [ 159 | ListItemComponent { 160 | type: "item" 161 | id: post_listItemContainer 162 | 163 | StandardListItem { 164 | id: post_sli 165 | property variant internalWpu 166 | textFormat: TextFormat.Html 167 | title: qsTr(ListItemData.post_title) 168 | description: ListItemData.date //post_date 169 | status: ListItemData.post_status 170 | imageSpaceReserved: false 171 | 172 | contextActions: [ 173 | ActionSet { 174 | title: ListItemData.post_title 175 | ActionItem { 176 | title: "Edit" 177 | imageSource: "asset:///images/edit.png" 178 | onTriggered: { 179 | post_sli.ListItem.view.post_goEdit(ListItemData.post_id); 180 | } 181 | } 182 | DeleteActionItem { 183 | title: "Delete" 184 | onTriggered: { 185 | post_sli.ListItem.view.post_goToDel(ListItemData.post_id, ListItemData.post_title) 186 | } 187 | 188 | } 189 | } 190 | ] 191 | } 192 | } 193 | ] 194 | function post_goToDel(id, title) { 195 | post_delDialog.pid = id; 196 | post_delDialog.ptitle = title; 197 | post_delDialog.show(); 198 | } 199 | function post_goEdit(id) { 200 | post_savemodel = post_plListView.dataModel; 201 | var p = post_editPost.createObject(); 202 | p.post_id = id; 203 | p.post_showpage = post_plp.post_showpage; 204 | if (post_plp.post_showpage) 205 | navpagepane.push(p) 206 | else navpostpane.push(p); 207 | } 208 | onTriggered: { 209 | post_savemodel = post_plListView.dataModel; 210 | var selectedItem = post_plListView.dataModel.data(indexPath); 211 | var newPage = post_showPost.createObject(); 212 | newPage.post_show_page = post_plp.post_showpage; 213 | newPage.sp_apostid = selectedItem.post_id; 214 | if ( post_plp.post_showpage ) 215 | navpagepane.push(newPage) 216 | else navpostpane.push(newPage); 217 | } 218 | } // end of plListView 219 | 220 | } 221 | 222 | } 223 | 224 | } 225 | 226 | -------------------------------------------------------------------------------- /assets/main.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * main.qml 3 | * 4 | * Author: Daniele (b0unc3) Maio 5 | */ 6 | 7 | import bb.cascades 1.0 8 | import bb.system 1.0 9 | 10 | TabbedPane { 11 | id: tabbedPane 12 | showTabsOnActionBar: false 13 | peekEnabled: false 14 | 15 | property alias mbs: navigationPane.mb 16 | 17 | Menu.definition: MenuDefinition { 18 | actions: [ 19 | ActionItem { 20 | id: cb 21 | title: qsTr("Change blog"); 22 | enabled: mbs || !wpu.blogsInfo() 23 | 24 | onTriggered: { 25 | bsdo.open(); 26 | } 27 | } 28 | ] 29 | 30 | } 31 | attachedObjects: [ 32 | BlogsSelectionDialog { 33 | id: bsdo 34 | }, 35 | ComponentDefinition { 36 | id: postsList 37 | source: "postslist.qml" 38 | }, 39 | ComponentDefinition { 40 | id: loginPage 41 | source: "Login.qml" 42 | }, 43 | ComponentDefinition { 44 | id: blogsList 45 | source: "blogslist.qml" 46 | }, 47 | ComponentDefinition { 48 | id: commentsList 49 | source: "commentslist.qml" 50 | }, 51 | /* post */ 52 | 53 | ComponentDefinition { 54 | id: post_showPost 55 | source: "showPost.qml" 56 | }, 57 | ComponentDefinition { 58 | id: post_makePost 59 | source: "makePost.qml" 60 | }, 61 | ComponentDefinition { 62 | id: post_editPost 63 | source: "editpost.qml" 64 | }, 65 | SystemDialog { 66 | id: warningDialog 67 | title: "Warning" 68 | body: "Continue and you'll lose your changes" 69 | onFinished: { 70 | if (warningDialog.result == SystemUiResult.ConfirmButtonSelection) 71 | { 72 | if ( tabbedPane.activeTab == postsTab ) 73 | navpostpane.pop(); 74 | else navpagepane.pop(); 75 | } 76 | } 77 | } 78 | ] 79 | 80 | onCreationCompleted: { 81 | if ( wpu.info_registered() ) 82 | { 83 | tabbedPane.activeTab = postsTab; 84 | 85 | tabbedPane.remove(loginregisterTab); 86 | tabbedPane.showTabsOnActionBar = false; 87 | tabbedPane.peekEnabled = true; 88 | 89 | var newPage = postsList.createObject(); 90 | newPage.post_showpage = false; 91 | navpostpane.push(newPage); 92 | newPage.post_loadData(); 93 | } else console.log("no info registered"); 94 | } 95 | Tab { 96 | id: loginregisterTab 97 | NavigationPane { 98 | id: navigationPane 99 | peekEnabled: false 100 | backButtonsVisible: false 101 | property bool mb: false; 102 | 103 | onCreationCompleted: { 104 | var page = loginPage.createObject(); 105 | navigationPane.push(page); 106 | } 107 | 108 | onPopTransitionEnded: { 109 | if ( firstPage ) 110 | firstPage.destroy(); 111 | 112 | if ( page ) 113 | page.destroy(); 114 | //plp.loadData(); 115 | 116 | 117 | 118 | tabbedPane.activeTab = postsTab; 119 | 120 | tabbedPane.remove(loginregisterTab); 121 | tabbedPane.showTabsOnActionBar = false; 122 | tabbedPane.peekEnabled = true; 123 | 124 | var newPage = postsList.createObject(); 125 | newPage.post_showpage = false; 126 | navpostpane.push(newPage); 127 | newPage.post_loadData(); 128 | } 129 | } 130 | } 131 | Tab { 132 | id: postsTab 133 | title: qsTr("Posts") 134 | imageSource: "asset:///images/posts.png" 135 | 136 | NavigationPane { 137 | id: navpostpane 138 | 139 | 140 | 141 | onPopTransitionEnded: { 142 | 143 | if ( page ) 144 | page.destroy(); 145 | 146 | if (navpostpane.firstPage) { 147 | navpostpane.firstPage.post_restoreItems() 148 | } else { 149 | var post_ = postsList.createObject(); 150 | post_.post_showpage = false; 151 | navpostpane.push(post_); 152 | post_.post_loadData(); 153 | 154 | } 155 | } 156 | 157 | } 158 | 159 | onTriggered: { 160 | console.log("here we are"); 161 | if (navpagepane.count() > 0) { 162 | for (var i = 0; i < navpagepane.count(); i ++) 163 | navpagepane.remove(navpostpane.at(i)); 164 | } 165 | if ( navpagepane.top ) { 166 | navpagepane.remove(navpagepane.top); 167 | } 168 | if (navpostpane.count() == 0) { 169 | var newPage_post_ = postsList.createObject(); 170 | newPage_post_.post_showpage = false; 171 | navpostpane.push(newPage_post_); 172 | newPage_post_.post_loadData(); 173 | } else { 174 | if ( navpostpane.firstPage ) 175 | { 176 | navpostpane.firstPage.post_loadData(); 177 | } else { 178 | var post_p = postsList.createObject(); 179 | navpostpane.push(post_p); 180 | post_p.post_showpage = false; 181 | post_p.post_loadData(); 182 | } 183 | } 184 | 185 | } 186 | } 187 | 188 | Tab { 189 | id: commentsTab 190 | title: qsTr("Comments") 191 | imageSource: "asset:///images/comments.png" 192 | 193 | NavigationPane { 194 | id: navcommentspane 195 | 196 | onPopTransitionEnded: { 197 | if ( page ) 198 | page.destroy(); 199 | 200 | if (navcommentspane.firstPage ) 201 | { 202 | navcommentspane.firstPage.comment_restoreItems() 203 | } else { 204 | var p = commentsList.createObject(); 205 | navcommentspane.push(p); 206 | } 207 | } 208 | 209 | } 210 | 211 | onTriggered: { 212 | if (navpostpane.count() > 0) { 213 | for (var i = 0; i < navpostpane.count(); i ++) 214 | navpostpane.remove(navpostpane.at(i)); 215 | } 216 | if ( navpostpane.top ) 217 | { 218 | navpostpane.remove(navpostpane.top); 219 | } 220 | if ( navcommentspane.count() == 0 ) 221 | { 222 | var newPage = commentsList.createObject(); 223 | navcommentspane.push(newPage); 224 | } else { 225 | navcommentspane.firstPage.comment_init(); 226 | } 227 | } 228 | 229 | } 230 | Tab { 231 | id: pagesTab 232 | title: qsTr("Pages") 233 | imageSource: "asset:///images/pages.png" 234 | 235 | NavigationPane { 236 | id: navpagepane 237 | 238 | onPopTransitionEnded: { 239 | 240 | if ( page ) 241 | page.destroy(); 242 | 243 | if (navpagepane.firstPage) { 244 | navpagepane.firstPage.post_restoreItems() 245 | } else { 246 | var post_ = postsList.createObject(); 247 | post_.post_showpage = true; 248 | navpagepane.push(post_); 249 | post_.post_loadData(); 250 | 251 | } 252 | } 253 | 254 | } 255 | 256 | onTriggered: { 257 | if (navpostpane.count() > 0) { 258 | for (var i = 0; i < navpostpane.count(); i ++) 259 | navpostpane.remove(navpagepane.at(i)); 260 | } 261 | if ( navpostpane.top ) { 262 | navpostpane.remove(navpostpane.top); 263 | } 264 | if (navpagepane.count() == 0) { 265 | var newPage_post_ = postsList.createObject(); 266 | newPage_post_.post_showpage = true; 267 | navpagepane.push(newPage_post_); 268 | newPage_post_.post_loadData(); 269 | } else { 270 | if ( navpagepane.firstPage ) 271 | { 272 | navpagepane.firstPage.post_loadData(); 273 | } else { 274 | var post_p = postsList.createObject(); 275 | navpagepane.push(post_p); 276 | post_p.post_showpage = true; 277 | post_p.post_loadData(); 278 | } 279 | } 280 | 281 | } 282 | /* 283 | 284 | 285 | onPopTransitionEnded: { 286 | if (page) 287 | page.destroy(); 288 | 289 | if (navpagepane.firstPage) { 290 | navpagepane.firstPage.post_restoreItems() 291 | } else { 292 | var page_p = pagesList.createObject(); 293 | page_p.post_showpage = true; 294 | navpagepane.push(page_p); 295 | page_p.post_loadData(); 296 | } 297 | } 298 | 299 | } 300 | 301 | onTriggered: { 302 | if ( navpostpane.count() > 0) 303 | { 304 | for ( var i=0; i in reply to " + comment_csli.ListItem.view.commentsbyid["" + p]; 212 | else return d; 213 | } else return d; 214 | 215 | } 216 | function getStatus(s) 217 | { 218 | if ( s == "approve" ) 219 | return "

" + s + "

"; 220 | else if ( s == "hold" ) 221 | return "

" + s + "

"; 222 | else return s; 223 | 224 | } 225 | 226 | textFormat: TextFormat.Html 227 | title: qsTr(ListItemData.content) 228 | description: getDescription(ListItemData.parent, ListItemData.author) 229 | status: getStatus(ListItemData.status) // + "\n" + ListItemData.date //_created_gmt 230 | imageSpaceReserved: false 231 | 232 | property bool current_status: (ListItemData.status == "hold") 233 | 234 | contextActions: [ 235 | ActionSet { 236 | //title: ListItemData.title 237 | ActionItem { 238 | title: qsTr("Approve"); 239 | imageSource: "asset:///images/approve.png" 240 | enabled: current_status 241 | 242 | onTriggered: { 243 | 244 | comment_csli.ListItem.view.modIt(ListItemData.comment_id, "approve"); 245 | 246 | } 247 | } 248 | ActionItem { 249 | title: qsTr("Unapprove") 250 | enabled: !current_status //ListItemData.status == "approve" 251 | imageSource: "asset:///images/unapprove.png" 252 | 253 | onTriggered: { 254 | comment_csli.ListItem.view.modIt(ListItemData.comment_id, "hold"); 255 | } 256 | } 257 | ActionItem { 258 | title: qsTr("Reply") 259 | imageSource: "asset:///images/reply.png" 260 | 261 | onTriggered: { 262 | comment_csli.ListItem.view.rep(ListItemData.comment_id, ListItemData.post_id); 263 | } 264 | } 265 | ActionItem { 266 | title: qsTr("Edit") 267 | imageSource: "asset:///images/edit.png" 268 | onTriggered: { 269 | comment_csli.ListItem.view.goEdit(ListItemData.comment_id); 270 | 271 | } 272 | } 273 | ActionItem { 274 | title: qsTr("Spam") 275 | imageSource: "asset:///images/spam.png" 276 | 277 | onTriggered: { 278 | comment_csli.ListItem.view.modIt(ListItemData.comment_id, "spam"); 279 | } 280 | } 281 | DeleteActionItem { 282 | title: qsTr("Trash") 283 | 284 | onTriggered: { 285 | comment_csli.ListItem.view.delComment(ListItemData.comment_id); 286 | } 287 | 288 | } 289 | } 290 | ] 291 | } 292 | } 293 | ] 294 | onTriggered: { 295 | comment_cp_savemodel = comment_clListView.dataModel; 296 | var selectedItem = comment_clListView.dataModel.data(indexPath); 297 | var vc_p = comment_vc.createObject(); 298 | vc_p.vc_cid = selectedItem.comment_id 299 | navcommentspane.push(vc_p); 300 | } 301 | 302 | } // end of clListView 303 | } 304 | } 305 | 306 | onCreationCompleted: { 307 | if ( !comment_clListView.dataModel ) 308 | comment_cp.comment_init(); 309 | } 310 | } 311 | 312 | -------------------------------------------------------------------------------- /src/SBError.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2013 BlackBerry Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | **/ 16 | #include "SBError.hpp" 17 | 18 | QMap SBError::errors; 19 | 20 | QString SBError::getErrorText(int error) { 21 | if (errors.size()==0) { 22 | buildErrors(); 23 | } 24 | if (errors.contains(error)) { 25 | return QString("%1 (%2)").arg(errors[error]).arg(error); 26 | } 27 | return QString("[Unknown error: %1]").arg(error); 28 | } 29 | 30 | void SBError::buildErrors() { 31 | QMap & map(errors); 32 | map[0x0000] = "SB_SUCCESS"; 33 | map[-1] = "Crypto objects are invalid"; 34 | map[0xFFFE] = "SB_NOT_IMPLEMENTED"; 35 | map[0xFFFF] = "SB_FAILURE"; 36 | map[0xE101] = "SB_ERR_NULL_PARAMS"; 37 | map[0xE102] = "SB_ERR_NULL_PARAMS_PTR"; 38 | map[0xE103] = "SB_ERR_BAD_PARAMS"; 39 | map[0xE104] = "SB_ERR_NULL_CONTEXT"; 40 | map[0xE105] = "SB_ERR_NULL_CONTEXT_PTR"; 41 | map[0xE106] = "SB_ERR_BAD_CONTEXT"; 42 | map[0xE107] = "SB_ERR_NULL_RNG"; 43 | map[0xE108] = "SB_ERR_NO_RNG"; 44 | map[0xE109] = "SB_ERR_BAD_RNG_TYPE"; 45 | map[0xE10A] = "SB_ERR_BAD_RNG_CONTEXT"; 46 | map[0xE10B] = "SB_ERR_BAD_YIELD_CONTEXT"; 47 | map[0xE10C] = "SB_ERR_NULL_KEY"; 48 | map[0xE10D] = "SB_ERR_NULL_KEY_PTR"; 49 | map[0xE10E] = "SB_ERR_BAD_KEY"; 50 | map[0xE10F] = "SB_ERR_NULL_KEY_LEN"; 51 | map[0xE110] = "SB_ERR_BAD_KEY_LEN"; 52 | map[0xE111] = "SB_ERR_NULL_PRIVATE_KEY"; 53 | map[0xE112] = "SB_ERR_BAD_PRIVATE_KEY"; 54 | map[0xE113] = "SB_ERR_NULL_PRI_KEY_BUF"; 55 | map[0xE114] = "SB_ERR_BAD_PRI_KEY_BUF_LEN"; 56 | map[0xE115] = "SB_ERR_NULL_PUBLIC_KEY"; 57 | map[0xE116] = "SB_ERR_BAD_PUBLIC_KEY"; 58 | map[0xE117] = "SB_ERR_NULL_PUB_KEY_BUF"; 59 | map[0xE118] = "SB_ERR_BAD_PUB_KEY_BUF_LEN"; 60 | map[0xE119] = "SB_ERR_NULL_INPUT"; 61 | map[0xE11A] = "SB_ERR_NULL_INPUT_LEN"; 62 | map[0xE11B] = "SB_ERR_BAD_INPUT_LEN"; 63 | map[0xE11C] = "SB_ERR_NULL_INPUT_BUF"; 64 | map[0xE11D] = "SB_ERR_BAD_INPUT_BUF_LEN"; 65 | map[0xE11E] = "SB_ERR_BAD_INPUT"; 66 | map[0xE11F] = "SB_ERR_NULL_OUTPUT"; 67 | map[0xE120] = "SB_ERR_NULL_OUTPUT_BUF"; 68 | map[0xE121] = "SB_ERR_NULL_OUTPUT_BUF_LEN_PTR"; 69 | map[0xE122] = "SB_ERR_NULL_OUTPUT_BUF_LEN"; 70 | map[0xE123] = "SB_ERR_BAD_OUTPUT_BUF_LEN"; 71 | map[0xE124] = "SB_ERR_NULL_ADDINFO"; 72 | map[0xE125] = "SB_ERR_BAD_ALG"; 73 | map[0xE126] = "SB_ERR_BAD_FLAG"; 74 | map[0xE127] = "SB_ERR_NULL_BUFFER"; 75 | map[0xE128] = "SB_ERR_NULL_LENGTH"; 76 | map[0xE129] = "SB_ERR_BAD_LENGTH"; 77 | map[0xE12A] = "SB_ERR_OVERFLOW"; 78 | map[0xE12B] = "SB_ERR_NULL_HASH_INFO"; 79 | map[0xE12C] = "SB_ERR_PRI_KEY_NOT_EXPORTABLE"; 80 | map[0xE12D] = "SB_ERR_PUB_KEY_NOT_EXPORTABLE"; 81 | map[0xE12E] = "SB_ERR_SYM_KEY_NOT_EXPORTABLE"; 82 | map[0xE201] = "SB_ERR_NULL_EPHEM_PRI_KEY"; 83 | map[0xE202] = "SB_ERR_BAD_EPHEM_PRI_KEY"; 84 | map[0xE203] = "SB_ERR_NULL_EPHEM_PUB_KEY"; 85 | map[0xE204] = "SB_ERR_BAD_EPHEM_PUB_KEY"; 86 | map[0xE205] = "SB_ERR_NULL_REM_EPHEM_PUB_KEY"; 87 | map[0xE206] = "SB_ERR_BAD_REM_EPHEM_PUB_KEY"; 88 | map[0xE207] = "SB_ERR_NULL_REM_PUB_KEY"; 89 | map[0xE208] = "SB_ERR_BAD_REM_PUB_KEY"; 90 | map[0xE301] = "SB_ERR_NULL_SIGNATURE"; 91 | map[0xE302] = "SB_ERR_NULL_SIGNATURE_LEN"; 92 | map[0xE303] = "SB_ERR_BAD_SIGNATURE_LEN"; 93 | map[0xE305] = "SB_ERR_NULL_S_VALUE"; 94 | map[0xE306] = "SB_ERR_NULL_S_VALUE_LEN"; 95 | map[0xE307] = "SB_ERR_BAD_S_VALUE_LEN"; 96 | map[0xE308] = "SB_ERR_NULL_R_VALUE"; 97 | map[0xE309] = "SB_ERR_NULL_R_VALUE_LEN"; 98 | map[0xE30A] = "SB_ERR_BAD_R_VALUE_LEN"; 99 | map[0xE30B] = "SB_ERR_BAD_HASH_TYPE"; 100 | map[0xE501] = "SB_ERR_NULL_ORDER_INT"; 101 | map[0xE502] = "SB_ERR_NULL_ORDER_INT_PTR"; 102 | map[0xE503] = "SB_ERR_BAD_ORDER_INT"; 103 | map[0xE504] = "SB_ERR_NULL_ECPOINT"; 104 | map[0xE505] = "SB_ERR_NULL_ECPOINT_PTR"; 105 | map[0xE506] = "SB_ERR_BAD_ECPOINT"; 106 | map[0xE601] = "SB_ERR_NULL_IDLC_P"; 107 | map[0xE602] = "SB_ERR_BAD_IDLC_P_LEN"; 108 | map[0xE603] = "SB_ERR_BAD_IDLC_P"; 109 | map[0xE604] = "SB_ERR_NULL_IDLC_Q"; 110 | map[0xE605] = "SB_ERR_BAD_IDLC_Q_LEN"; 111 | map[0xE606] = "SB_ERR_BAD_IDLC_Q"; 112 | map[0xE607] = "SB_ERR_NULL_IDLC_G"; 113 | map[0xE608] = "SB_ERR_BAD_IDLC_G_LEN"; 114 | map[0xE609] = "SB_ERR_BAD_IDLC_G"; 115 | map[0xE701] = "SB_ERR_BAD_PUB_EXP_LEN"; 116 | map[0xE702] = "SB_ERR_NULL_RSA_N"; 117 | map[0xE703] = "SB_ERR_BAD_RSA_N_LEN"; 118 | map[0xE704] = "SB_ERR_BAD_RSA_N"; 119 | map[0xE705] = "SB_ERR_NULL_RSA_E"; 120 | map[0xE706] = "SB_ERR_BAD_RSA_E_LEN"; 121 | map[0xE707] = "SB_ERR_BAD_RSA_E"; 122 | map[0xE708] = "SB_ERR_NULL_RSA_D"; 123 | map[0xE709] = "SB_ERR_BAD_RSA_D_LEN"; 124 | map[0xE70A] = "SB_ERR_BAD_RSA_D"; 125 | map[0xE70B] = "SB_ERR_NULL_RSA_P"; 126 | map[0xE70C] = "SB_ERR_BAD_RSA_P_LEN"; 127 | map[0xE70D] = "SB_ERR_BAD_RSA_P"; 128 | map[0xE70E] = "SB_ERR_NULL_RSA_Q"; 129 | map[0xE70F] = "SB_ERR_BAD_RSA_Q_LEN"; 130 | map[0xE711] = "SB_ERR_BAD_RSA_Q"; 131 | map[0xE712] = "SB_ERR_NULL_RSA_QINV"; 132 | map[0xE713] = "SB_ERR_BAD_RSA_QINV_LEN"; 133 | map[0xE714] = "SB_ERR_BAD_RSA_QINV"; 134 | map[0xE715] = "SB_ERR_NULL_RSA_DP"; 135 | map[0xE716] = "SB_ERR_BAD_RSA_DP_LEN"; 136 | map[0xE717] = "SB_ERR_BAD_RSA_DP"; 137 | map[0xE718] = "SB_ERR_NULL_RSA_DQ"; 138 | map[0xE719] = "SB_ERR_BAD_RSA_DQ_LEN"; 139 | map[0xE71A] = "SB_ERR_BAD_RSA_DQ"; 140 | map[0xE71B] = "SB_ERR_RSA_CRT_NOT_AVAILABLE"; 141 | map[0xE801] = "SB_ERR_BAD_MODE"; 142 | map[0xE802] = "SB_ERR_BAD_ALGORITHM"; 143 | map[0xE803] = "SB_ERR_BAD_KEY_PARITY"; 144 | map[0xE804] = "SB_ERR_BAD_KEY_OPTION"; 145 | map[0xE805] = "SB_ERR_BAD_NUM_KEYS"; 146 | map[0xE806] = "SB_ERR_BAD_ROUNDS"; 147 | map[0xE807] = "SB_ERR_NULL_IV"; 148 | map[0xE808] = "SB_ERR_BAD_IV_LEN"; 149 | map[0xE809] = "SB_ERR_WEAK_KEY"; 150 | map[0xE80A] = "SB_ERR_BAD_BLOCK_LEN"; 151 | map[0xE80B] = "SB_ERR_BAD_KEY_UNWRAP"; 152 | map[0xE80C] = "SB_ERR_NO_MODE"; 153 | map[0xE80D] = "SB_ERR_INVALID_MAC"; 154 | map[0xE80E] = "SB_ERR_MAC_INVALID"; 155 | map[0xE80F] = "SB_ERR_BAD_IV"; 156 | map[0xE901] = "SB_ERR_BAD_DIGEST_LEN"; 157 | map[0xE902] = "SB_ERR_BAD_MESSAGE_LEN"; 158 | map[0xEA01] = "SB_ERR_RNG_BAD_DRBG_CONTEXT"; 159 | map[0xEA02] = "SB_ERR_RNG_INVALID_HANDLE"; 160 | map[0xEA03] = "SB_ERR_RNG_BAD_HANDLE"; 161 | map[0xEA04] = "SB_ERR_RNG_NO_MORE_HANDLE"; 162 | map[0xEA05] = "SB_ERR_RNG_SECURITY_STRENGTH_TOO_SMALL"; 163 | map[0xEA06] = "SB_ERR_RNG_SECURITY_STRENGTH_NOT_SUPPORTED"; 164 | map[0xEA07] = "SB_ERR_RNG_PREDICTIVE_RESISTANCE_NOT_SUPPORTED"; 165 | map[0xEA08] = "SB_ERR_RNG_PERSONALIZATION_STRING_TOO_BIG"; 166 | map[0xEA09] = "SB_ERR_RNG_ADDITIONAL_INPUT_TOO_BIG"; 167 | map[0xEA0A] = "SB_ERR_RNG_REQUESTED_BYTES_TOO_BIG"; 168 | map[0xEA0B] = "SB_ERR_RNG_REQUESTED_SECURITY_TOO_BIG"; 169 | map[0xEA0C] = "SB_ERR_RNG_REQUESTED_HASH_DERIVE_TOO_BIG"; 170 | map[0xEA0D] = "SB_ERR_RNG_RESEED_IS_REQUIRED"; 171 | map[0xEA0E] = "SB_ERR_RNG_NULL_TIME_CALLBACK"; 172 | map[0xEF01] = "SB_ERR_NULL_GLOBAL_CTX"; 173 | map[0xEF02] = "SB_ERR_NULL_GLOBAL_CTX_PTR"; 174 | map[0xEF03] = "SB_ERR_BAD_GLOBAL_CTX"; 175 | map[0xF001] = "SB_FAIL_ALLOC"; 176 | map[0xF002] = "SB_FAIL_KEYGEN"; 177 | map[0xF003] = "SB_FAIL_LOCK"; 178 | map[0xF004] = "SB_FAIL_UNLOCK"; 179 | map[0xF005] = "SB_FAIL_NULL_PTR"; 180 | map[0xF006] = "SB_FAIL_INVALID_PRIVATE_KEY"; 181 | map[0xF007] = "SB_FAIL_CANNOT_LOAD_LIBRARY"; 182 | map[0xF008] = "SB_FAIL_LIBRARY_DISABLED"; 183 | map[0xF009] = "SB_FAIL_INTEGRITY"; 184 | map[0xF00A] = "SB_FAIL_KAT"; 185 | map[0xF00B] = "SB_FAIL_OPEN_FILE"; 186 | map[0xF00C] = "SB_FAIL_READ_FILE"; 187 | map[0xF00D] = "SB_FAIL_LIBRARY_ALREADY_INIT"; 188 | map[0xF00E] = "SB_FAIL_LIBRARY_NOT_INIT"; 189 | map[0xF501] = "SB_FAIL_ECIES_HMAC"; 190 | map[0xF502] = "SB_FAIL_INVALID_SHARED_SECRET"; 191 | map[0xF503] = "SB_FAIL_INVALID_SIGNATURE"; 192 | map[0xF701] = "SB_FAIL_BAD_PADDING"; 193 | map[0xF702] = "SB_FAIL_PKCS1_DECRYPT"; 194 | map[0xFA01] = "SB_FAIL_RANDOM_GEN"; 195 | map[0xFB01] = "SB_FAIL_DIVIDE_BY_ZERO"; 196 | map[0xFB02] = "SB_FAIL_NO_INVERSE"; 197 | map[0xFC01] = "SB_FAIL_NO_SOLUTION"; 198 | map[0xFC02] = "SB_ERR_MODULUS_TOO_BIG"; 199 | map[0xFC03] = "SB_ERR_MODULUS_TOO_SMALL"; 200 | map[0xFE01] = "SB_FAIL_PRIME_GEN"; 201 | map[0xFF00] = "SB_ERR_POINT_AT_INFINITY"; 202 | map[0x3001] = "SB_ERR_NULL_PROVIDER"; 203 | map[0x3002] = "SB_ERR_NULL_PROVIDER_PTR"; 204 | map[0x3004] = "SB_ERR_NULL_SESSION"; 205 | map[0x3005] = "SB_ERR_NULL_SESSION_PTR"; 206 | map[0x3006] = "SB_ERR_BAD_SESSION"; 207 | map[0x3007] = "SB_ERR_NOT_SUPPORTED"; 208 | map[0x3008] = "SB_ERR_BAD_CIPHER_TYPE"; 209 | map[0x3009] = "SB_ERR_BAD_MODE_TYPE"; 210 | map[0x300A] = "SB_ERR_BAD_MAC_TYPE"; 211 | map[0x300B] = "SB_ERR_BAD_ECDH_TYPE"; 212 | map[0x300F] = "SB_ERR_BAD_PARAMETER"; 213 | map[0x3010] = "SB_ERR_NULL_OID"; 214 | map[0x3011] = "SB_ERR_BAD_INPUT_FORMAT"; 215 | map[0x3012] = "SB_ERR_NULL_HANDLE"; 216 | map[0x3013] = "SB_ERR_BAD_HANDLE"; 217 | map[0x3014] = "SB_ERR_BAD_ALLOC_POLICY"; 218 | map[0x3015] = "SB_ERR_ECC_NOT_SUPPORTED"; 219 | map[0x3016] = "SB_ERR_ECC_CURVE_SECT163K1_NOT_SUPPORTED"; 220 | map[0x3017] = "SB_ERR_ECC_CURVE_SECT163R2_NOT_SUPPORTED"; 221 | map[0x3018] = "SB_ERR_ECC_CURVE_SECT233K1_NOT_SUPPORTED"; 222 | map[0x3019] = "SB_ERR_ECC_CURVE_SECT233R1_NOT_SUPPORTED"; 223 | map[0x301A] = "SB_ERR_ECC_CURVE_SECT239K1_NOT_SUPPORTED"; 224 | map[0x301B] = "SB_ERR_ECC_CURVE_SECT283K1_NOT_SUPPORTED"; 225 | map[0x301C] = "SB_ERR_ECC_CURVE_SECT283R1_NOT_SUPPORTED"; 226 | map[0x301D] = "SB_ERR_ECC_CURVE_SECT409K1_NOT_SUPPORTED"; 227 | map[0x301E] = "SB_ERR_ECC_CURVE_SECT409R1_NOT_SUPPORTED"; 228 | map[0x301F] = "SB_ERR_ECC_CURVE_SECT571K1_NOT_SUPPORTED"; 229 | map[0x3020] = "SB_ERR_ECC_CURVE_SECT571R1_NOT_SUPPORTED"; 230 | map[0x3021] = "SB_ERR_ECC_CURVE_SECP160R1_NOT_SUPPORTED"; 231 | map[0x3022] = "SB_ERR_ECC_CURVE_SECP192R1_NOT_SUPPORTED"; 232 | map[0x3023] = "SB_ERR_ECC_CURVE_SECP224R1_NOT_SUPPORTED"; 233 | map[0x3024] = "SB_ERR_ECC_CURVE_SECP256R1_NOT_SUPPORTED"; 234 | map[0x3025] = "SB_ERR_ECC_CURVE_SECP384R1_NOT_SUPPORTED"; 235 | map[0x3026] = "SB_ERR_ECC_CURVE_SECP521R1_NOT_SUPPORTED"; 236 | map[0x3027] = "SB_ERR_ECC_CURVE_WTLS5_NOT_SUPPORTED"; 237 | map[0x3028] = "SB_ERR_ECC_CURVE_WAPI1_NOT_SUPPORTED"; 238 | map[0x3029] = "SB_ERR_ECC_CURVE_GBP320T1_NOT_SUPPORTED"; 239 | map[0x302A] = "SB_ERR_ECC_CURVE_GBP320R1_NOT_SUPPORTED"; 240 | map[0x302F] = "SB_ERR_ECC_BAD_CURVE"; 241 | map[0x3030] = "SB_ERR_RSA_NOT_SUPPORTED"; 242 | map[0x3031] = "SB_ERR_IDLC_NOT_SUPPORTED"; 243 | map[0x3032] = "SB_ERR_AES_NOT_SUPPORTED"; 244 | map[0x3033] = "SB_ERR_DES_NOT_SUPPORTED"; 245 | map[0x3034] = "SB_ERR_ARC2_NOT_SUPPORTED"; 246 | map[0x3035] = "SB_ERR_ARC4_NOT_SUPPORTED"; 247 | map[0x3036] = "SB_ERR_RC5_NOT_SUPPORTED"; 248 | map[0x3037] = "SB_ERR_AUTHENC_NOT_SUPPORTED"; 249 | map[0x3040] = "SB_ERR_MD2_NOT_SUPPORTED"; 250 | map[0x3041] = "SB_ERR_MD4_NOT_SUPPORTED"; 251 | map[0x3042] = "SB_ERR_MD5_NOT_SUPPORTED"; 252 | map[0x3043] = "SB_ERR_SHA1_NOT_SUPPORTED"; 253 | map[0x3044] = "SB_ERR_SHA224_NOT_SUPPORTED"; 254 | map[0x3045] = "SB_ERR_SHA256_NOT_SUPPORTED"; 255 | map[0x3046] = "SB_ERR_SHA384_NOT_SUPPORTED"; 256 | map[0x3047] = "SB_ERR_SHA512_NOT_SUPPORTED"; 257 | map[0x3048] = "SB_ERR_AES_MMO_NOT_SUPPORTED"; 258 | map[0x3050] = "SB_ERR_HMAC_MD2_NOT_SUPPORTED"; 259 | map[0x3051] = "SB_ERR_HMAC_MD4_NOT_SUPPORTED"; 260 | map[0x3052] = "SB_ERR_HMAC_MD5_NOT_SUPPORTED"; 261 | map[0x3053] = "SB_ERR_HMAC_SHA1_NOT_SUPPORTED"; 262 | map[0x3054] = "SB_ERR_HMAC_SHA224_NOT_SUPPORTED"; 263 | map[0x3055] = "SB_ERR_HMAC_SHA256_NOT_SUPPORTED"; 264 | map[0x3056] = "SB_ERR_HMAC_SHA384_NOT_SUPPORTED"; 265 | map[0x3057] = "SB_ERR_HMAC_SHA512_NOT_SUPPORTED"; 266 | map[0x3058] = "SB_ERR_MAC_XCBC_AES_NOT_SUPPORTED"; 267 | map[0x3059] = "SB_ERR_MAC_CMAC_AES_NOT_SUPPORTED"; 268 | map[0x3060] = "SB_ERR_RNG_NOT_SUPPORTED"; 269 | map[0x3061] = "SB_ERR_KDF_ANSI_SHA1_NOT_SUPPORTED"; 270 | map[0x3062] = "SB_ERR_KDF_IEEE_KDF1_SHA1_NOT_SUPPORTED"; 271 | map[0x3063] = "SB_ERR_KDF_ANSI_SHA224_NOT_SUPPORTED"; 272 | map[0x3064] = "SB_ERR_KDF_ANSI_SHA256_NOT_SUPPORTED"; 273 | map[0x3065] = "SB_ERR_KDF_ANSI_SHA384_NOT_SUPPORTED"; 274 | map[0x3066] = "SB_ERR_KDF_ANSI_SHA512_NOT_SUPPORTED"; 275 | map[0x3067] = "SB_ERR_KDF_PKCS5_V1_MD2_NOT_SUPPORTED"; 276 | map[0x3068] = "SB_ERR_KDF_PKCS5_V1_MD5_NOT_SUPPORTED"; 277 | map[0x3069] = "SB_ERR_KDF_PKCS5_V1_SHA1_NOT_SUPPORTED"; 278 | map[0x306A] = "SB_ERR_KDF_PKCS5_V2_SHA1_NOT_SUPPORTED"; 279 | map[0x306B] = "SB_ERR_KDF_PKCS5_V2_SHA256_NOT_SUPPORTED"; 280 | map[0x306C] = "SB_ERR_KDF_PKCS12_V1_SHA1_NOT_SUPPORTED"; 281 | map[0x306D] = "SB_ERR_KDF_PKCS12_V1_SHA256_NOT_SUPPORTED"; 282 | map[0x306E] = "SB_ERR_SEED_NOT_SUPPORTED"; 283 | map[0x306F] = "SB_ERR_KDF_BAD_ALGORITHM"; 284 | map[0x3070] = "SB_ERR_UNWRAP_FAILED"; 285 | map[0x3071] = "SB_ERR_MULTI_DIGEST_EXCEEDED"; 286 | map[0x3080] = "SB_ERR_IDLC_GROUP_IPSEC_1_NOT_SUPPORTED"; 287 | map[0x3081] = "SB_ERR_IDLC_GROUP_IPSEC_2_NOT_SUPPORTED"; 288 | map[0x3082] = "SB_ERR_IDLC_GROUP_IPSEC_5_NOT_SUPPORTED"; 289 | map[0x3083] = "SB_ERR_IDLC_GROUP_WTLS_1_NOT_SUPPORTED"; 290 | map[0x3084] = "SB_ERR_IDLC_GROUP_WTLS_2_NOT_SUPPORTED"; 291 | map[0x3085] = "SB_ERR_IDLC_GROUP_IPSEC_14_NOT_SUPPORTED"; 292 | map[0x3086] = "SB_ERR_IDLC_GROUP_IPSEC_15_NOT_SUPPORTED"; 293 | map[0x3087] = "SB_ERR_IDLC_GROUP_IPSEC_16_NOT_SUPPORTED"; 294 | map[0x3088] = "SB_ERR_IDLC_GROUP_IPSEC_17_NOT_SUPPORTED"; 295 | map[0x3089] = "SB_ERR_IDLC_GROUP_IPSEC_18_NOT_SUPPORTED"; 296 | map[0x308F] = "SB_ERR_IDLC_BAD_GROUP"; 297 | map[0x3090] = "SB_ERR_KDF_NIST_ALT1_NOT_SUPPORTED"; 298 | map[0x3091] = "SB_ERR_KDF_PKCS5_V2_SHA224_NOT_SUPPORTED"; 299 | map[0x3092] = "SB_ERR_KDF_PKCS5_V2_SHA384_NOT_SUPPORTED"; 300 | map[0x3093] = "SB_ERR_KDF_PKCS5_V2_SHA512_NOT_SUPPORTED"; 301 | map[0x3094] = "SB_ERR_KDF_PKCS12_V1_SHA224_NOT_SUPPORTED"; 302 | map[0x3095] = "SB_ERR_KDF_PKCS12_V1_SHA384_NOT_SUPPORTED"; 303 | map[0x3096] = "SB_ERR_KDF_PKCS12_V1_SHA512_NOT_SUPPORTED"; 304 | map[0x3097] = "SB_ERR_KS_NOT_SUPPORTED"; 305 | map[0x3098] = "SB_ERR_ZMOD_CALC_NOT_SUPPORTED"; 306 | map[0x3100] = "SB_ERR_CS_BASE"; 307 | map[0x3200] = "SB_ERR_BS_BASE"; 308 | map[0x3300] = "SB_ERR_PKCS11_VENDOR_BASE"; 309 | map[0x3400] = "SB_ERR_CAC_BASE"; 310 | map[0x3600] = "SB_ERR_OS_BASE"; 311 | map[0x3700] = "SB_ERR_CGX_BASE"; 312 | map[0x3800] = "SB_ERR_PKCS11_BASE"; 313 | map[0x3A00] = "SB_ERR_I300_BASE"; 314 | map[0x3B00] = "SB_ERR_WTP_BASE"; 315 | map[0x3C00] = "SB_ERR_PQ_BASE"; 316 | map[0x3D00] = "SB_ERR_ES_BASE"; 317 | }; 318 | 319 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | WordPress for BlackBerry 10 294 | Copyright (C) 2013 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /src/WPUtils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * WPUtils.cpp 3 | * 4 | * Author: Daniele (b0unc3) Maio 5 | */ 6 | 7 | #include "WPUtils.h" 8 | 9 | #include 10 | 11 | /* crypt/decrypt stuff */ 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "AESParams.hpp" 18 | #include "AESKey.hpp" 19 | #include "DRBG.hpp" 20 | #include "SBError.hpp" 21 | /*********************/ 22 | 23 | 24 | const QString WPUtils::dbName = "wpbb10.db"; 25 | 26 | WPUtils::WPUtils(QObject *parent) 27 | { 28 | QDir home = QDir::home(); 29 | QFile file(home.absoluteFilePath(dbName)); 30 | if (!file.exists() && file.open(QIODevice::ReadWrite) ) 31 | { 32 | SqlDataAccess sda(home.absoluteFilePath(dbName)); 33 | sda.execute("CREATE TABLE userinfo(blogid TEXT, id INTEGER PRIMARY KEY, username TEXT, password BLOB, xmlrpc BLOB);"); 34 | } 35 | /* 36 | * load crypt/decrypt stuff 37 | */ 38 | QSettings settings; 39 | if (!settings.contains("key")) { 40 | settings.setValue("key",generate()); 41 | } 42 | if (!settings.contains("iv")) { 43 | settings.setValue("iv",generate()); 44 | } 45 | _key = settings.value("key").toString(); 46 | _iv = settings.value("iv").toString(); 47 | /*****/ 48 | 49 | _position = 0; // <<== WTF? 50 | _info_registered = true; 51 | _db = QSqlDatabase::addDatabase("QSQLITE"); 52 | _db.setDatabaseName(home.absoluteFilePath(dbName)); 53 | if (!_db.open()) 54 | { 55 | qDebug() << "db not opened!"; 56 | _info_registered = false; 57 | /* FIXIT */ 58 | } 59 | if (!info_registered()) 60 | _info_registered = false; 61 | else { 62 | getRegisteredData(); 63 | } 64 | } 65 | WPUtils::~WPUtils() { 66 | // TODO Auto-generated destructor stub 67 | _db.close(); 68 | } 69 | 70 | /* 71 | * crypt/decrypt stuff 72 | * grabbed from : https://github.com/blackberry/Cascades-Community-Samples/tree/master/AESCryptoDemo 73 | * 74 | */ 75 | 76 | QString WPUtils::generate() { 77 | DRBG drbg(globalContext); 78 | QByteArray buffer(16, 0); 79 | int rc = drbg.getBytes(buffer); 80 | if (rc != SB_SUCCESS) { 81 | qDebug() << QString("Could not generate random bytes %1").arg(SBError::getErrorText(rc)); 82 | return ""; 83 | } 84 | return toHex(buffer); 85 | } 86 | 87 | void WPUtils::pad(QByteArray & in) { 88 | int padLength = 16 - (in.length() % 16); 89 | for (int i = 0; i < padLength; ++i) { 90 | in.append((char) padLength); 91 | } 92 | } 93 | 94 | QString WPUtils::encrypt(QString s) { 95 | QByteArray in(s.toUtf8());// plainText().toUtf8()); 96 | pad(in); 97 | QByteArray out(in.length(), 0); 98 | 99 | if (crypt(true, in, out)) { 100 | //setCipherText(toHex(out)); 101 | //return true; 102 | return toHex(out); 103 | } 104 | return "";//false; 105 | } 106 | 107 | bool WPUtils::crypt(bool isEncrypt, const QByteArray & in, 108 | QByteArray & out) { 109 | QByteArray key, iv; 110 | QString fail; 111 | 112 | if (!fromHex(_key, key)) { 113 | fail += "Key is not valid hex. "; 114 | } 115 | if (!fromHex(_iv, iv)) { 116 | fail += "IV is not valid hex. "; 117 | } 118 | 119 | if (!fail.isEmpty()) { 120 | qDebug() << "fail = " << fail; 121 | //toast(fail); 122 | return false; 123 | } 124 | 125 | AESParams params(globalContext); 126 | if (!params.isValid()) { 127 | //toast( 128 | qDebug () << "fails = " << QString("Could not create params. %1").arg(SBError::getErrorText(params.lastError())); 129 | return false; 130 | } 131 | 132 | AESKey aesKey(params, key); 133 | if (!aesKey.isValid()) { 134 | qDebug() << "failes = " << QString("Could not create a key. %1").arg(SBError::getErrorText(aesKey.lastError())); 135 | return false; 136 | } 137 | 138 | int rc; 139 | if (isEncrypt) { 140 | rc = hu_AESEncryptMsg(params.aesParams(), aesKey.aesKey(), iv.length(), 141 | (const unsigned char*) iv.constData(), in.length(), 142 | (const unsigned char *) in.constData(), 143 | (unsigned char *) out.data(), globalContext.ctx()); 144 | } else { 145 | rc = hu_AESDecryptMsg(params.aesParams(), aesKey.aesKey(), iv.length(), 146 | (const unsigned char*) iv.constData(), in.length(), 147 | (const unsigned char *) in.constData(), 148 | (unsigned char *) out.data(), globalContext.ctx()); 149 | } 150 | if (rc == SB_SUCCESS) { 151 | return true; 152 | } 153 | 154 | //toast 155 | qDebug() << QString("Crypto operation failed. %1").arg(SBError::getErrorText(rc)); 156 | return false; 157 | 158 | } 159 | 160 | QString WPUtils::decrypt(QString d) { 161 | QByteArray in; 162 | if (!fromHex(d, in)) { 163 | //toast 164 | qDebug() << "Cipher text is not valid hex"; 165 | return false; 166 | } 167 | QByteArray out(in.length(), 0); 168 | 169 | if (crypt(false, in, out)) { 170 | if (removePadding(out)) { 171 | QString toUse(QString::fromUtf8(out.constData(), out.length())); 172 | return toUse; 173 | //return true; 174 | } 175 | } 176 | return "";//false; 177 | } 178 | 179 | char WPUtils::nibble(char c) { 180 | if (c >= '0' && c <= '9') { 181 | return c - '0'; 182 | } else if (c >= 'a' && c <= 'f') { 183 | return c - 'a' + 10; 184 | } else if (c >= 'A' && c <= 'F') { 185 | return c - 'A' + 10; 186 | } 187 | return -1; 188 | } 189 | 190 | QString WPUtils::toHex(const QByteArray & in) { 191 | static char hexChars[] = "0123456789abcdef"; 192 | 193 | const char * c = in.constData(); 194 | QString toReturn; 195 | for (int i = 0; i < in.length(); ++i) { 196 | toReturn += hexChars[(c[i] >> 4) & 0xf]; 197 | toReturn += hexChars[(c[i]) & 0xf]; 198 | } 199 | 200 | return toReturn; 201 | } 202 | 203 | bool WPUtils::fromHex(const QString in, QByteArray & toReturn) { 204 | QString temp(in); 205 | temp.replace(" ",""); 206 | temp.replace(":",""); 207 | temp.replace(".",""); 208 | QByteArray content(temp.toLocal8Bit()); 209 | 210 | const char * c(content.constData()); 211 | 212 | if (content.length() == 0 || ((content.length() % 2) != 0)) { 213 | return false; 214 | } 215 | 216 | for (int i = 0; i < content.length(); i += 2) { 217 | char a = c[i]; 218 | char b = c[i + 1]; 219 | a = nibble(a); 220 | b = nibble(b); 221 | if (a < 0 || b < 0) { 222 | toReturn.clear(); 223 | return false; 224 | } 225 | toReturn.append((a << 4) | b); 226 | } 227 | return true; 228 | } 229 | 230 | bool WPUtils::removePadding(QByteArray & out) { 231 | char paddingLength = out[out.length() - 1]; 232 | if (paddingLength < 1 || paddingLength > 16) { 233 | //toast 234 | qDebug() << "Invalid padding length. Were the keys good?"; 235 | out.clear(); 236 | return false; 237 | } 238 | if (paddingLength > out.length()) { 239 | //toast 240 | qDebug() << "Padding is claiming to be longer than the buffer!"; 241 | out.clear(); 242 | return false; 243 | } 244 | for (int i = 1; i < paddingLength; ++i) { 245 | char next = out[out.length() - 1 - i]; 246 | if (next != paddingLength) { 247 | qDebug() << "Not all padding bytes are correct!"; 248 | out.clear(); 249 | return false; 250 | } 251 | } 252 | out.remove(out.length() - paddingLength, paddingLength); 253 | return true; 254 | } 255 | 256 | /*************************************************************/ 257 | 258 | void WPUtils::getRegisteredData() 259 | { 260 | QSqlQuery q(_db); 261 | q.exec("SELECT * FROM userinfo"); 262 | /* 263 | * table structure: 264 | * id,username,password,blogid,xmlrp 265 | * 266 | * blogid - xmlrpc <= multiple item separated by comma 267 | * TODO = create another table and link with foreign key 268 | */ 269 | //*for* sure there is only - 1 - record 270 | q.next(); 271 | _username = q.value(2).toString(); 272 | _password = decrypt(q.value(3).toString()); //<--- decrypt 273 | QString bi = q.value(0).toString(); 274 | QString xr = q.value(4).toString(); 275 | 276 | QStringList bis = bi.split(","); 277 | QStringList xrs = xr.split(","); 278 | _blogid = bis.at(0); 279 | _endpoint = xrs.at(0); 280 | 281 | int i=0; 282 | for ( i=0; i 0); 309 | } 310 | 311 | int WPUtils::getPosition() 312 | { 313 | return _position; 314 | } 315 | 316 | void WPUtils::setCurrentBlog(QString b, QString u) 317 | { 318 | if ( !b.isEmpty() && !u.isEmpty() ) 319 | { 320 | _blogid = b.trimmed(); 321 | _endpoint =u.trimmed(); 322 | QSettings settings; 323 | settings.setValue("blogid", _blogid); 324 | settings.setValue("endpoint", _endpoint); 325 | } 326 | } 327 | 328 | QString WPUtils::getCurrentBlog() 329 | { 330 | return _blogid + "-" + _endpoint; 331 | } 332 | 333 | QMap WPUtils::getBI() 334 | { 335 | return _blogs; 336 | } 337 | 338 | void WPUtils::getBlogsInfo() 339 | { 340 | 341 | // uhm 342 | 343 | } 344 | 345 | bool WPUtils::blogsInfo() 346 | { 347 | return _blogs.isEmpty(); 348 | } 349 | 350 | void WPUtils::setBlogsInfo(QString bid, QString burl) 351 | { 352 | 353 | qDebug() << "saving " << bid << burl; 354 | 355 | _blogs.insertMulti(bid, burl); 356 | 357 | _totbid += (( !_totbid.isEmpty() ) ? " , " : "" ) + bid; // + _blogid + " , " + bid; 358 | _totburl+= (( !_totburl.isEmpty() ) ? " , " : "" ) + burl; // _endpoint + " , " + burl; 359 | 360 | _blogid = bid; //_blogs.values("blogid")[_position]; 361 | _endpoint = burl;//_blogs.values("burl")[_position]; 362 | 363 | /* register infos */ 364 | QSqlQuery query(_db); 365 | 366 | if ( !info_registered() ) 367 | { 368 | qDebug() << "inserting" << _blogid << _endpoint; 369 | query.prepare("INSERT INTO userinfo (blogid,username,password,xmlrpc) VALUES (:blogid, :username, :password, :xmlrpc)"); 370 | query.bindValue(":blogid", _blogid); 371 | query.bindValue(":username", _username); // <-- crypt 372 | query.bindValue(":password", encrypt(_password)); 373 | query.bindValue(":xmlrpc", _endpoint); 374 | query.exec(); 375 | } else { 376 | qDebug() << "updating" << _totbid << _totburl; 377 | query.prepare("UPDATE userinfo set blogid=:blogid , xmlrpc=:xmlrpc"); 378 | query.bindValue(":blogid", _totbid); 379 | query.bindValue(":xmlrpc", _totburl); 380 | //QSqlError e = query.lastError(); 381 | query.exec(); 382 | } 383 | } 384 | 385 | 386 | 387 | // << -- XML/RPC stuff -- >> 388 | 389 | 390 | void WPUtils::uploadFile(QString furl) 391 | { 392 | QFile* file = new QFile(furl); 393 | 394 | 395 | 396 | if ( file->exists() ) 397 | qDebug() << "file founded."; 398 | else qDebug() << "file not found."; 399 | 400 | if ( file->isReadable() ) 401 | qDebug() << "readable"; 402 | else qDebug() << "unreadable"; 403 | 404 | file->open(QIODevice::ReadOnly); 405 | 406 | QFileInfo fileInfo(file->fileName()); 407 | QString nome(fileInfo.fileName()); 408 | 409 | _xml.clear(); 410 | QXmlStreamWriter sw(&_xml); 411 | 412 | sw.setAutoFormatting(true); 413 | sw.writeStartDocument(); 414 | 415 | sw.writeStartElement("methodCall"); 416 | sw.writeTextElement("methodName", "wp.uploadFile"); 417 | sw.writeStartElement("params"); 418 | sw.writeStartElement("param"); 419 | sw.writeCharacters("blog_id"); 420 | sw.writeTextElement("value", _blogid); 421 | sw.writeEndElement(); 422 | sw.writeStartElement("param"); 423 | sw.writeCharacters("username"); 424 | sw.writeTextElement("value", _username); 425 | sw.writeEndElement(); 426 | sw.writeStartElement("param"); 427 | sw.writeCharacters("password"); 428 | sw.writeTextElement("value", _password); 429 | sw.writeEndElement(); 430 | sw.writeStartElement("struct"); 431 | sw.writeStartElement("member"); 432 | sw.writeTextElement("name", "name"); 433 | sw.writeTextElement("value", nome); 434 | sw.writeEndElement(); 435 | sw.writeStartElement("member"); 436 | sw.writeTextElement("name", "type"); 437 | QImageReader reader(furl); 438 | 439 | sw.writeTextElement("value", "image/"+reader.format()); 440 | sw.writeEndElement(); 441 | sw.writeStartElement("member"); 442 | sw.writeTextElement("name", "bits"); 443 | sw.writeStartElement("value"); 444 | sw.writeStartElement("base64"); 445 | sw.writeCharacters(file->readAll().toBase64()); 446 | sw.writeEndElement(); 447 | sw.writeEndElement(); 448 | sw.writeEndElement(); 449 | sw.writeStartElement("member"); 450 | sw.writeTextElement("name", "overwrite"); 451 | sw.writeTextElement("value", "true"); 452 | sw.writeEndElement(); 453 | sw.writeEndElement(); 454 | sw.writeEndElement(); 455 | sw.writeEndDocument(); 456 | 457 | QNetworkAccessManager *manager = new QNetworkAccessManager(); 458 | 459 | QObject::connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); 460 | 461 | QUrl url; 462 | 463 | url.setUrl(_endpoint); 464 | QNetworkRequest request(url); 465 | int cmd = 0; 466 | request.setAttribute(QNetworkRequest::Attribute(QNetworkRequest::User + 1), QVariant((int) cmd)); /* not sure */ 467 | request.setRawHeader("User-Agent", "wp-bb10/0.0.1"); 468 | request.setHeader(QNetworkRequest::ContentTypeHeader, "text/xml"); 469 | 470 | 471 | manager->post(request,_xml); 472 | } 473 | 474 | 475 | void WPUtils::buildWPXML(QString mName, bool standardParams, 476 | QStringList other_paramsNames, QStringList other_paramsValues, 477 | QStringList memberNames , QStringList memberValues) 478 | 479 | { 480 | qDebug() << "bwpx : endpoint on = " << _endpoint; 481 | QByteArray _xml; 482 | QXmlStreamWriter sw(&_xml); 483 | 484 | sw.setAutoFormatting(true); 485 | sw.writeStartDocument(); 486 | 487 | sw.writeStartElement("methodCall"); 488 | sw.writeTextElement("methodName", mName); 489 | 490 | sw.writeStartElement("params"); 491 | 492 | if ( standardParams ) 493 | { 494 | sw.writeStartElement("param"); 495 | sw.writeCharacters("blog_id"); 496 | sw.writeTextElement("value", _blogid); 497 | sw.writeEndElement(); 498 | 499 | sw.writeStartElement("param"); 500 | sw.writeCharacters("username"); 501 | sw.writeTextElement("value", _username); 502 | sw.writeEndElement(); 503 | 504 | sw.writeStartElement("param"); 505 | sw.writeCharacters("password"); 506 | sw.writeTextElement("value", _password); 507 | sw.writeEndElement(); 508 | } 509 | 510 | int i; 511 | 512 | for ( i=0; i 0 ) 521 | { 522 | sw.writeStartElement("struct"); 523 | 524 | for ( i = 0; i < memberNames.size(); i++ ) 525 | { 526 | sw.writeStartElement("member"); 527 | sw.writeTextElement("name", memberNames.at(i).toLocal8Bit().constData()); 528 | sw.writeTextElement("value", memberValues.at(i).toLocal8Bit().constData()); 529 | sw.writeEndElement(); 530 | 531 | } 532 | 533 | sw.writeEndElement(); 534 | } 535 | 536 | 537 | sw.writeEndDocument(); 538 | 539 | QNetworkAccessManager *manager = new QNetworkAccessManager(); 540 | 541 | mName.replace("deletePost","delPost", Qt::CaseSensitive); 542 | mName.replace("deleteComment", "delComment", Qt::CaseSensitive); 543 | if ( memberValues.contains("page", Qt::CaseSensitive) ) 544 | mName.replace("Post", "Page", Qt::CaseInsensitive); 545 | 546 | manager->setObjectName(mName.replace("wp.","")); 547 | 548 | QObject::connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); 549 | 550 | QUrl url; 551 | 552 | url.setUrl(_endpoint); 553 | QNetworkRequest request(url); 554 | int cmd = 0; 555 | request.setAttribute(QNetworkRequest::Attribute(QNetworkRequest::User + 1), QVariant((int) cmd)); /* not sure */ 556 | request.setRawHeader("User-Agent", "wp-bb10/0.0.1"); 557 | request.setHeader(QNetworkRequest::ContentTypeHeader, "text/xml"); 558 | 559 | manager->post(request,_xml); 560 | } 561 | 562 | void WPUtils::getBlogs(QString u, QString p, QString blog_address) 563 | { 564 | _xml.clear(); 565 | QXmlStreamWriter sw(&_xml); 566 | 567 | sw.setAutoFormatting(true); 568 | sw.writeStartDocument(); 569 | 570 | sw.writeStartElement("methodCall"); 571 | sw.writeTextElement("methodName", "wp.getUsersBlogs"); 572 | 573 | sw.writeStartElement("params"); 574 | sw.writeStartElement("param"); 575 | sw.writeCharacters("username"); 576 | sw.writeTextElement("value", u); 577 | sw.writeEndElement(); 578 | sw.writeStartElement("param"); 579 | sw.writeCharacters("password"); 580 | sw.writeTextElement("value", p); 581 | sw.writeEndElement(); 582 | 583 | sw.writeEndDocument(); 584 | 585 | QNetworkAccessManager *manager = new QNetworkAccessManager(); 586 | 587 | manager->setObjectName("getUsersBlogs"); 588 | 589 | QObject::connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); 590 | 591 | QUrl url; 592 | 593 | //_xml = xml.toUtf8(); 594 | 595 | QString tmp_url = searchEndPoint(blog_address); 596 | if ( tmp_url.isEmpty() ) 597 | { 598 | qDebug() << "unable to found endpoint"; 599 | res.insert("ERROR","ERROR"); 600 | } else { 601 | 602 | url.setUrl(tmp_url); 603 | QNetworkRequest request(url); 604 | int cmd = 0; 605 | request.setAttribute(QNetworkRequest::Attribute(QNetworkRequest::User + 1), QVariant((int) cmd)); /* not sure */ 606 | request.setRawHeader("User-Agent", "wp-bb10/0.0.1"); 607 | request.setHeader(QNetworkRequest::ContentTypeHeader, "text/xml"); 608 | 609 | manager->post(request,_xml); 610 | } 611 | } 612 | 613 | /* not yet used 614 | * 615 | * 616 | void WPUtils::getCategories() 617 | { 618 | 619 | _xml.clear(); 620 | QDomDocument doc; 621 | QDomProcessingInstruction init = doc.createProcessingInstruction("xml version=\"1.0\"", "encoding=\"UTF-8\""); 622 | QDomElement mc = doc.createElement("methodCall"); 623 | QDomElement mn = doc.createElement("methodName"); 624 | QDomText mnt = doc.createTextNode("wp.getTerms"); 625 | QDomElement ps = doc.createElement("params"); 626 | QDomElement p1 = doc.createElement("param"); 627 | QDomText p1t = doc.createTextNode("blogid"); 628 | QDomElement v1 = doc.createElement("value"); 629 | QDomText v1t = doc.createTextNode(_blogid); 630 | QDomElement p2 = doc.createElement("param"); 631 | QDomText p2t = doc.createTextNode("username"); 632 | QDomElement v2 = doc.createElement("value"); 633 | QDomText v2t = doc.createTextNode(_username); 634 | QDomElement p3 = doc.createElement("param"); 635 | QDomText p3t = doc.createTextNode("password"); 636 | QDomElement v3 = doc.createElement("value"); 637 | QDomText v3t = doc.createTextNode(_password); 638 | QDomElement p4 = doc.createElement("param"); 639 | QDomText p4t = doc.createTextNode("taxonomy"); 640 | QDomElement v4 = doc.createElement("value"); 641 | QDomText v4t = doc.createTextNode("category"); 642 | 643 | doc.appendChild(init); 644 | doc.appendChild(mc); 645 | mc.appendChild(mn); 646 | mn.appendChild(mnt); 647 | mc.appendChild(ps); 648 | 649 | ps.appendChild(p1); 650 | p1.appendChild(p1t); 651 | p1.appendChild(v1); 652 | v1.appendChild(v1t); 653 | 654 | ps.appendChild(p2); 655 | p2.appendChild(p2t); 656 | p2.appendChild(v2); 657 | v2.appendChild(v2t); 658 | 659 | ps.appendChild(p3); 660 | p3.appendChild(p3t); 661 | p3.appendChild(v3); 662 | v3.appendChild(v3t); 663 | 664 | ps.appendChild(p4); 665 | p4.appendChild(p4t); 666 | p4.appendChild(v4); 667 | v4.appendChild(v4t); 668 | 669 | 670 | 671 | _xml = doc.toString().toUtf8(); 672 | 673 | QNetworkAccessManager *manager = new QNetworkAccessManager(); 674 | 675 | QObject::connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); 676 | 677 | QUrl url; 678 | 679 | url.setUrl(_endpoint); 680 | QNetworkRequest request(url); 681 | int cmd = 0; 682 | request.setAttribute(QNetworkRequest::Attribute(QNetworkRequest::User + 1), QVariant((int) cmd)); 683 | request.setRawHeader("User-Agent", "wp-bb10/0.0.1"); 684 | request.setHeader(QNetworkRequest::ContentTypeHeader, "text/xml"); 685 | 686 | manager->post(request,_xml); 687 | } 688 | */ 689 | 690 | void WPUtils::replyFinished(QNetworkReply *rep) 691 | { 692 | QVariantMap _res_bck; 693 | model = new GroupDataModel(QStringList() << "sortDate" ); //"date" << "date_created_gmt" << "post_date"); 694 | 695 | model->setSortedAscending(false); 696 | 697 | model->setGrouping(ItemGrouping::None); 698 | 699 | if ( model && !model->isEmpty() ) 700 | model->clear(); 701 | 702 | if ( !res.isEmpty() ) 703 | res.clear(); 704 | 705 | if (!_res_bck.isEmpty() ) 706 | _res_bck.clear(); 707 | 708 | 709 | QByteArray ret = rep->readAll(); 710 | 711 | if ( !ret.isEmpty() ) 712 | qDebug() << "reading " << ret; //rep->readAll(); 713 | else qDebug() << "ret empty -> error handling /*TODO*/"; 714 | 715 | QString _current_name = ""; 716 | 717 | QXmlStreamReader xml(ret); 718 | 719 | int _struct_counter = 0; 720 | 721 | while(!xml.atEnd() && !xml.hasError()) { 722 | QXmlStreamReader::TokenType token = xml.readNext(); 723 | if ( token == QXmlStreamReader::StartElement ) 724 | { 725 | if ( xml.name().toString() == "fault") 726 | { 727 | res["ERROR"] = "fault"; 728 | } else if ( xml.name().toString() == "struct" ) 729 | { 730 | _struct_counter++; 731 | } else if ( xml.name().toString() == "name" ) 732 | { 733 | token = xml.readNext(); 734 | _current_name = xml.text().toString(); 735 | } else if ( xml.name().toString() == "value" && !_current_name.isEmpty() ) 736 | { 737 | token = xml.readNext(); 738 | if ( xml.name().toString() == "string" || xml.name().toString() == "boolean" || xml.name().toString() == "dateTime.iso8601" ) 739 | { 740 | token = xml.readNext(); 741 | if ( _current_name == "post_date" || _current_name == "date_created_gmt" ) 742 | { 743 | QLocale c = QLocale::c(); 744 | QDateTime date = c.toDateTime(xml.text().toString(), QLatin1String("yyyyMMddTHH:mm:ss"));//ddd, dd MMM yyyy HH:mm:ss"));// '+0000")); 745 | QString outputFromat("dd MMM yyyy - HH:mm:ss"); 746 | date.setTimeSpec(Qt::UTC); 747 | res["sortDate"] = date; 748 | res["date"] = date.toString(outputFromat); 749 | /* is this insane?! */ 750 | /* 751 | QString theDate = xml.text().toString(); //"20130503T14:48:55"; 752 | QDateTime date = QDateTime::fromString(theDate, "yyyyMMddTHH:mm:ss"); 753 | res["sortDate"] = date; 754 | res["date"] = date.toString(Qt::SystemLocaleShortDate); 755 | */ 756 | } 757 | else res[_current_name] = xml.text().toString(); 758 | 759 | _current_name = ""; 760 | } else _current_name = ""; 761 | } else if ( xml.name().toString() == "string" ) 762 | { 763 | /* newpost workaround */ 764 | token = xml.readNext(); 765 | res["newpostid"] = xml.text().toString(); 766 | model->insert(res); 767 | _res_bck.unite(res); 768 | res.clear(); 769 | } else if ( xml.name().toString() == "boolean") 770 | { 771 | /* deletepost workaround */ 772 | token = xml.readNext(); 773 | res["delpost"] = xml.text().toString(); 774 | model->insert(res); 775 | _res_bck.unite(res); 776 | res.clear(); 777 | } else if ( xml.name().toString() == "int" ) 778 | { 779 | /* newcomment workaround */ 780 | token = xml.readNext(); 781 | res["newcommentid"] = xml.text().toString(); 782 | model->insert(res); 783 | _res_bck.unite(res); 784 | res.clear(); 785 | } 786 | 787 | } else if ( token == QXmlStreamReader::EndElement ) 788 | { 789 | if ( xml.name().toString() == "struct" ) 790 | { 791 | _struct_counter--; 792 | 793 | if ( _struct_counter == 0 ) 794 | { 795 | if ( !res.isEmpty() ) 796 | { 797 | model->insert(res); 798 | _res_bck.unite(res); 799 | res.clear(); 800 | } else qDebug() << "*+*+*+*+*+*+*+* ouch! res is empty!! =====DO SMTG======"; 801 | 802 | } 803 | } 804 | } 805 | } 806 | 807 | res = _res_bck; 808 | 809 | QList one_blog = res.values("blogid"); 810 | 811 | if ( !one_blog.isEmpty() ) 812 | { 813 | qDebug() << "one blog = " << one_blog; 814 | qDebug() << "size = " << QString::number(one_blog.size()); 815 | if ( one_blog.size() == 1 ) 816 | { 817 | /* skip the blog selection */ 818 | qDebug() << "adding = " << one_blog[0].toString(); 819 | QList bu = res.values("xmlrpc"); 820 | setBlogsInfo(one_blog[0].toString(), bu[0].toString()); 821 | res["oneblog"] = 1; 822 | //setBlogsInfo(one_blog[1], QString burl) 823 | } 824 | } 825 | 826 | if(QObject* pObject = sender()) { 827 | QString name = pObject->objectName(); 828 | if ( !name.isEmpty() ) 829 | { 830 | QString methodName = "dataReady_" + name; 831 | const char *x = methodName.toStdString().c_str(); 832 | QMetaObject::invokeMethod(this, x, Qt::DirectConnection);//, Qt::DirectConnection); 833 | } else emit dataReady(ret); 834 | 835 | } else emit dataReady(ret); 836 | } 837 | 838 | /* no need to pass a qbytearray, model filled in the replyFinished */ 839 | bb::cascades::GroupDataModel * WPUtils::setModel(QByteArray a) 840 | { 841 | /***FIXME***/ 842 | return model; 843 | } 844 | 845 | QString WPUtils::sanitize(QString burl) 846 | { 847 | /* 848 | * check for the presence of http / https 849 | * check for the trailing / 850 | */ 851 | if ( !burl.isEmpty() ) { 852 | if ( !burl.toLower().startsWith("http://") && !burl.toLower().startsWith("https://") ) 853 | { 854 | burl = "http://" + burl; 855 | } 856 | if ( !burl.endsWith("/") ) 857 | burl.append("/"); 858 | 859 | 860 | return burl; 861 | } 862 | 863 | return burl; 864 | 865 | } 866 | 867 | QString WPUtils::searchEndPoint(QString url) // WP_FindEndPoint(QString url) 868 | { 869 | _url = sanitize(url); 870 | /* 871 | * not here , but somewhere esle TBD 872 | QUrl t(_url); 873 | if ( !t.isValid() ) 874 | { 875 | return ""; 876 | }*/ 877 | 878 | if ( _url.isEmpty() ) 879 | { 880 | _url = "https://wordpress.com/xmlrpc.php"; 881 | if ( validate(_url) ) 882 | return _endpoint; 883 | else return ""; 884 | 885 | 886 | } else { 887 | if ( _url.indexOf("xmlrpc.php") != - 1 ) 888 | { 889 | if ( validate(_url) ) 890 | return _endpoint; 891 | } 892 | else if ( _url.indexOf("/wp-admin/") != -1 ) 893 | { 894 | /* 895 | input contains /wp-admin/ 896 | remove it, and adding xmlrpc.php (WRN : check if there is also xmlrpc.php FIXME ) 897 | then validate 898 | */ 899 | _url.replace("/wp-admin/","/").append("xmlrpc.php"); 900 | if ( validate(_url) ) 901 | return _endpoint; 902 | } 903 | else if ( validate(_url.append("xmlrpc.php")) ) 904 | { 905 | return _endpoint; 906 | } else { 907 | /* 908 | unable to locate xmlrpc.php 909 | try to search in the HTML. href or pingback link 910 | */ 911 | QNetworkAccessManager *a = new QNetworkAccessManager(); 912 | QUrl url(_url);//.append("/")); 913 | QNetworkRequest request(_url); 914 | 915 | QNetworkReply *reply = a->get(request); 916 | //QEvent_loop _loop; 917 | QObject::connect(a, SIGNAL(finished(QNetworkReply*)), this, SLOT(checkForPingback(QNetworkReply*)) ); 918 | 919 | _loop.exec(); 920 | 921 | return _endpoint; 922 | /*if ( _endpoint.isEmpty() ) 923 | return 924 | */ 925 | 926 | 927 | } 928 | } 929 | 930 | if ( _endpoint.isEmpty() ) 931 | { 932 | _url = "https://wordpress.com/xmlrpc.php"; 933 | if ( validate(_url) ) 934 | return _endpoint; 935 | else return ""; 936 | 937 | 938 | } 939 | 940 | return ""; 941 | 942 | 943 | 944 | } 945 | 946 | bool WPUtils::validate(QString e) 947 | { 948 | QUrl u(e); 949 | QNetworkAccessManager *a = new QNetworkAccessManager(); 950 | 951 | QNetworkRequest request(u); 952 | int cmd = 0; 953 | request.setAttribute(QNetworkRequest::Attribute(QNetworkRequest::User + 1), QVariant((int) cmd)); 954 | request.setRawHeader("User-Agent", "wp-bb10/0.0.1"); 955 | request.setHeader(QNetworkRequest::ContentTypeHeader, "text/xml"); 956 | 957 | QNetworkReply *reply; 958 | 959 | reply = a->post(request, _xml); 960 | 961 | 962 | QObject::connect(a, SIGNAL(finished(QNetworkReply*)), this, SLOT(repFinished(QNetworkReply*)) ); 963 | _loop.exec(); 964 | 965 | if ( _endpoint.isEmpty() ) 966 | return false; 967 | else return true; 968 | } 969 | 970 | void WPUtils::repFinished(QNetworkReply *r) 971 | { 972 | QByteArray t = r->readAll(); 973 | QXmlStreamReader xr(t);//r->readAll()); 974 | 975 | _endpoint = ""; 976 | while(!xr.atEnd() && !xr.hasError()) 977 | { 978 | 979 | QXmlStreamReader::TokenType token = xr.readNext(); 980 | if(token == QXmlStreamReader::StartElement) 981 | { 982 | if ( xr.name() == "methodResponse") //all the correct call, contain a ; right? */ 983 | { 984 | _endpoint = _url; 985 | } 986 | 987 | 988 | } 989 | } 990 | xr.clear(); 991 | _loop.quit(); 992 | } 993 | void WPUtils::checkForPingback(QNetworkReply *r) 994 | { 995 | QRegExp trx("link rel=\"pingback\" href=\"([^\"]*)\"");//(.*)<\/a>) 996 | QString str = r->readAll();//"Offsets: 12 14 99 231 7"; 997 | 998 | int pos = trx.indexIn(str); 999 | if ( pos != -1 ) 1000 | { 1001 | QStringList list = trx.capturedTexts(); 1002 | if ( validate(list[1]) ) 1003 | qDebug() << "got it " << _endpoint;// return _endpoint; 1004 | else{ 1005 | /* 1006 | check on pingback href failed 1007 | check on EditURI href 1008 | */ 1009 | QRegExp erx("link rel=\"EditURI\" type=\"application/rsd\+[^*]*\" title=\"RSD\" href=\"([^\"]*)\"");//(.*)<\/a>) 1010 | int pos = erx.indexIn(str); 1011 | if ( pos != -1 ) 1012 | { 1013 | QStringList list = erx.capturedTexts(); 1014 | if (list[1].indexOf('xmlrpc') != -1 ) //double check we got the right url 1015 | { 1016 | /* 1017 | download the xml and parse it 1018 | check for apiLink url 1019 | */ 1020 | /****TODO****/ 1021 | } 1022 | if ( validate(list[1]) ) 1023 | qDebug() << "got on 2 = " << _endpoint; 1024 | else { 1025 | qDebug() << "nothing found"; 1026 | } 1027 | } 1028 | } 1029 | } 1030 | } 1031 | --------------------------------------------------------------------------------