Esempio n. 1
0
void Control::sendActionsForControlEvents(EventType controlEvents)
{
    // For each control events
    for (int i = 0; i < kControlEventTotalNumber; i++)
    {
        // If the given controlEvents bitmask contains the curent event
        if (((int)controlEvents & (1 << i)))
        {
            // Call invocations
            // <Invocation*>
            Array* invocationList = this->dispatchListforControlEvent((Control::EventType)(1<<i));
            Object* pObj = NULL;
            CCARRAY_FOREACH(invocationList, pObj)
            {
                Invocation* invocation = static_cast<Invocation*>(pObj);
                invocation->invoke(this);
            }
            //Call ScriptFunc
            if (kScriptTypeLua == _scriptType)
            {
                cocos2d::BasicScriptData data(this,(void*)&controlEvents);
                cocos2d::ScriptEvent event(cocos2d::kControlEvent,(void*)&data);
                cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
            }
        }
    void ActionInvokePhone::execute(ExecutionState* state)
    {
        DataModelLogger* RUNLOG = state->getLogger();

        // Retrieve desired action
        std::string action = getParameter("ACTION", state);

        // Determine parameters
        std::string targetId = "";
        std::string invokeAction = "";
        std::string mimeType = "";
        std::string uri = "";
        QByteArray data = "";
        if (action == "") {
            RUNLOG->error("Select an action to perform");
            return;
        } else if (action == "OPEN_CALL_LOGS") {
            invokeAction = "bb.action.OPEN";
            mimeType = "application/vnd.blackberry.calllog.id";
        } else if (action == "CALL_NUMBER") {
            invokeAction = "bb.action.DIAL";
            mimeType = "application/vnd.blackberry.phone.startcall";
            QVariantMap map;
            map.insert("number", QString::fromStdString(getParameter("NUMBER", state)));
            data = bb::PpsObject::encode(map, NULL);
        } else if (action == "CALL_EMERGENCY") {
            invokeAction = "bb.action.EMERGENCY_CALL";
            mimeType = "application/vnd.blackberry.phone.startcall";
        } else {
            LOG->error(SSTR("Error invoking, unknown desired action: " << action));
        }

        Invocation* invocation = new Invocation();
        bb::system::InvokeTargetReply* reply = invocation->invoke(targetId, invokeAction, mimeType,
                uri, data);
        if (!reply->isFinished()) {
            RUNLOG->error("Timed out invoking target");
            return;
        } else if (reply->error() != bb::system::InvokeReplyError::None) {
            RUNLOG->error(
                    "Target invoke failed: " + Invocation::errorMessageToString(reply->error()));
            return;
        }
    }
    void ActionInvokeBbm::execute(ExecutionState* state)
    {
        DataModelLogger* RUNLOG = state->getLogger();

        // Retrieve desired action
        std::string action = getParameter("ACTION", state);

        // Determine parameters
        std::string targetId = "";
        std::string invokeAction = "";
        std::string mimeType = "";
        std::string uri = "";
        std::string data = "";
        if (action == "") {
            RUNLOG->error("Select an action to perform");
            return;
        } else if (action == "SHARE_TEXT_TO_PIN") {
            targetId = "sys.bbm.sharehandler";
            invokeAction = "bb.action.SHARE";
            mimeType = "text/plain";
            data = getParameter("TEXT", state);
        } else if (action == "SHARE_FILE_TO_PIN") {
            targetId = "sys.bbm.sharehandler";
            invokeAction = "bb.action.SHARE";
            uri = getParameter("FILE", state);
        } else if (action == "SHARE_TEXT_TO_GROUP") {
            targetId = "sys.bbgroups.sharehandler";
            invokeAction = "bb.action.SHARE";
            mimeType = "text/plain";
            data = getParameter("TEXT", state);
        } else if (action == "SHARE_FILE_TO_GROUP") {
            targetId = "sys.bbgroups.sharehandler";
            invokeAction = "bb.action.SHARE";
            uri = getParameter("FILE", state);
        } else if (action == "SHARE_TEXT_TO_CHANNEL") {
            targetId = "sys.channels.sharehandler";
            invokeAction = "bb.action.SHARE";
            mimeType = "text/plain";
            data = getParameter("TEXT", state);
        } else if (action == "SHARE_FILE_TO_CHANNEL") {
            targetId = "sys.channels.sharehandler";
            invokeAction = "bb.action.SHARE";
            uri = getParameter("FILE", state);
        } else if (action == "OPEN_BBM") {
            targetId = "sys.bbm";
            invokeAction = "bb.action.OPEN";
        } else if (action == "SET_DISPLAY_PIC") {
            targetId = "sys.bbm.imagehandler";
            invokeAction = "bb.action.SET";
            uri = getParameter("PICTURE_FILE", state);
        } else if (action == "OPEN_OR_INVITE") {
            targetId = "sys.bbm.sharehandler";
            invokeAction = "bb.action.BBMCHAT";
            uri = SSTR("pin:" << getParameter("PIN", state));
        } else if (action == "AUDIO_CALL") {
            targetId = "sys.service.videochat";
            invokeAction = "bb.action.OPEN";
            data = SSTR("dest=" << getParameter("PIN", state) << "&video=0");
        } else if (action == "VIDEO_CALL") {
            targetId = "sys.service.videochat";
            invokeAction = "bb.action.OPEN";
            data = SSTR("dest=" << getParameter("PIN", state) << "&video=1");
        } else if (action == "OPEN_CHANNEL") {
            targetId = "sys.bbm.channels.card.previewer";
            invokeAction = "bb.action.OPENBBMCHANNEL";
            uri = SSTR("bbmc:" << getParameter("PIN", state));
        } else {
            LOG->error(SSTR("Error invoking, unknown desired action: " << action));
        }

        Invocation* invocation = new Invocation();
        bb::system::InvokeTargetReply* reply = invocation->invoke(targetId, invokeAction, mimeType,
                uri, data);
        if (!reply->isFinished()) {
            RUNLOG->error("Timed out invoking target");
            return;
        } else if (reply->error() != bb::system::InvokeReplyError::None) {
            RUNLOG->error(
                    "Target invoke failed: " + Invocation::errorMessageToString(reply->error()));
            return;
        }
    }