Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (日本語) » Mobile Link - サーバ起動同期 » Palm デバイス用 Mobile Link Listener C API

 

PalmLsnSpecialLaunch メソッド

デバイス依存の起動コードに応答します。

構文
Err PalmLsnSpecialLaunch(
    UInt16   cmd,
    MemPtr   cmdPBP,
    UInt16  launchFlags
)
パラメータ
  • cmd   Palm OS アプリケーションの起動コード。

  • cmdPBP   起動コード・パラメータが格納された構造体へのポインタ。起動コマンド固有のパラメータを持たないアプリケーションの場合は NULL。

  • launchFlags   アプリケーションのステータス情報を示すフラグ。

戻り値

Palm OS のエラー・コード。errNone は正常終了を表します。

備考

このメソッドは、sysAppLaunchCmdNormalLaunch として定義されていない、デバイス依存または標準の起動コードに応答します。

次の例は、Treo 650 smartphone の実装での使用例です。PalmLsnSpecialLaunch を使用して Listener イベントを処理しています。

Err PalmLsnSpecialLaunch( UInt16 cmd, MemPtr cmdPBP, UInt16 /*launchFlags*/ ) {
    switch(cmd) {
        case sysAppLaunchCmdSystemReset:
            // Fall through
        case sysAppLaunchCmdSyncNotify:
            // Fall through
        case phnLibLaunchCmdRegister:
            return registerListener();
        case phnLibLaunchCmdEvent: {
            if (!IsFeatureOn(PalmLsnGetFeature(), Listening)) {
                return(errNone);
            }
            PhnEventPtr phoneEventP = (PhnEventPtr) cmdPBP;
            if (phoneEventP->eventType == phnEvtMessageInd) {
                return(handleMessage(phoneEventP->data.params.id, &phoneEventP->acknowledge));
            }
        }
        default:
            break;
    }
    return(errNone);
}

メッセージが検出されたら、handleMessage を使用してメッセージを処理し、適切なアクションを実行します。

static Err handleMessage( PhnDatabaseID id, Boolean * handled )
/*************************************************************/
// This routine will construct a_palm_msg and then call
// PalmLsnProcess to process it.
{
    a_palm_msg *     ulMsg;
    Err              ret;
    Boolean          newlyLoaded;
    PhnAddressList   addrList;
    PhnAddressHandle addrH;
    MemHandle        msgBodyH;
    Char *           msgSender;
    Char *           msgBody;
    UInt32           msgTime;
    Char             configDb[ dmDBNameLength ];
    UInt16           libRef = 0;

    // CDMA workaround recommended by Handspring
    DmOpenRef        openRef = 0;

    *handled = false;

    // Allocate a message structure for passing over
    // to PalmLsnProcess later
    ulMsg = PalmLsnAllocate();
    if (ulMsg == NULL) {
        return(sysErrNoFreeRAM);
    }

    // Load the phone library   
    ret = findOrLoadPhoneLibrary(&libRef, &newlyLoaded);
    if (ret != errNone) {
        goto done;
    }
    openRef = PhnLibGetDBRef(libRef);

    // Retrieve sender of the message    
    ret = PhnLibGetAddresses(libRef, id, &addrList);
    if (ret != errNone) {
        goto done;
    }
    ret = PhnLibGetNth(libRef, addrList, 1, &addrH);
    if (ret != errNone) {
        PhnLibDisposeAddressList(libRef, addrList);
        goto done;
    }
 
    msgSender = PhnLibGetField(libRef, addrH, phnAddrFldPhone);
    if (msgSender != NULL) {
        ret = PalmLsnDupSender(ulMsg, msgSender);
        MemPtrFree(msgSender);
    }
    PhnLibDisposeAddressList( libRef, addrList );
    if (ret != errNone) {
        goto done;
    }
 
    // Retrieve message time    
    ret = PhnLibGetDate(libRef, id, &msgTime);
    if (ret != errNone) {
        goto done;
    }
    ret = PalmLsnDupTime(ulMsg, msgTime);
    if (ret != errNone) {
        goto done;
    }

    // Retrieve the entire message body  
    ret = PhnLibGetText(libRef, id, &msgBodyH);
    if (ret != errNone) {
        goto done;  
    }
    msgBody = (Char *) MemHandleLock(msgBodyH);
    ret = PalmLsnDupMessage(ulMsg, msgBody);
 
    // msgBodyH must be disposed of by the caller
    MemHandleUnlock(msgBodyH);
    MemHandleFree(msgBodyH);
    if (ret != errNone) {
        goto done;
    }

    // Get the configuration database name
    PalmLsnGetConfigFileName(configDb);

    // Call PalmLsnProcess to process the message
    ret = PalmLsnProcess(ulMsg, configDb, NULL, handled);

done:
    if (ulMsg != NULL) {
        PalmLsnFree(ulMsg);
    }
    PhnLibReleaseDBRef(libRef, openRef);

    // Unload the phone library before any possible application switch  
    if (newlyLoaded) {
        unloadPhoneLibrary(libRef);
        newlyLoaded = false;
    }
    return(ret);
}