⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jpush_general.c

📁 java 1.1 gemini 08_16
💻 C
📖 第 1 页 / 共 5 页
字号:

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_J2ME_CHECK_PUSH_REGISTER_PORT);

    /* Find the entry to pass off the open file descriptor. */
    for (p = g_jpush_pushlist_ptr; p; p = p->next)
    {
        if (port == p->portNo)
        {
            cur_suite = jam_current_midletsuite_name();

        #ifdef MIDP_PUSH_DEBUG
            if (cur_suite)
            {
                sprintf(_kvmLogStr, "J2ME Debug: j2me_check_push_register_port commandstate: %s", cur_suite);
                Kprintf();
            }
            sprintf(_kvmLogStr, "J2ME Debug: j2me_check_push_register_port check: %s", p->storagename);
            Kprintf();
        #endif /* MIDP_PUSH_DEBUG */ 

            if (cur_suite && (strcmp(p->storagename, cur_suite) == 0))
            {
                /* The same midletsuite register the port. */
                result = PUSH_REGISTERED;
            }
            else
            {
                /* Already register by other midlet suite */
                result = PUSH_CONFLICT_REGISTERED;
            }

            break;
        }
    }

    return result;
}


/*****************************************************************************
 * FUNCTION
 *  push_process_recvd_sms_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  port        [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void *push_process_recvd_sms_ind(int port)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    pushentry_struct *p = NULL;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_J2ME_PUSH_PROCESS_RECVD_SMS_IND);

    kal_take_mutex(J2ME_push_mutex);

    for (p = g_jpush_pushlist_ptr; p; p = p->next)
    {
        if (port == p->portNo)
        {
            break;
        }
    }

    if (p == NULL)
    {
        sprintf(_kvmLogStr, "push_process_recvd_sms_ind, p = NULL\n");
        Kprintf();
    }
    else
    {
        sprintf(_kvmLogStr, "push_process_recvd_sms_ind, p = %x\n", (int)p);
        Kprintf();
    }

    kal_give_mutex(J2ME_push_mutex);

    return p;
}


/*****************************************************************************
 * FUNCTION
 *  jpush_push_add
 * DESCRIPTION
 *  Add one entry to the push registry.
 *  If the entry already exists return -1.
 *  On succesful registration, write a new copy of the file to disk.
 * PARAMETERS
 *  str     [?]     - push midletsuite storage name
 * RETURNS
 *  void
 *****************************************************************************/
int jpush_push_add(char *str)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    pushentry_struct *p;
    pushentry_struct *pe;
    kal_char *tmp_str;
    kal_int32 tmp_len = 0;
    game_type_enum game_type = jvm_get_current_game_type();

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_J2ME_ADDPUSHENTRY);

#ifdef MIDP_PUSH_DEBUG
    sprintf(_kvmLogStr, "J2ME Debug: addpushentry %s", str);
    Kprintf();
#endif /* MIDP_PUSH_DEBUG */ 

    kal_take_mutex(J2ME_push_mutex);

    tmp_str = jpush_push_getstoragename(str, 0, &tmp_len);

    /* Check if the entry already exists? */
    for (p = g_jpush_pushlist_ptr; p != NULL; p = p->next)
    {
        if (strncmp(tmp_str, p->connection, tmp_len) == 0)
        {
            kal_give_mutex(J2ME_push_mutex);
            return -1;
        }
    }

    if (g_push_length + g_timealarm_count >= MAX_PUSH_REGISTRY)
    {
        kal_give_mutex(J2ME_push_mutex);
        return -2;
    }

    /* Add the new entry. */
    if ((pe = (pushentry_struct*) get_ctrl_buffer(sizeof(pushentry_struct))) != NULL)
    {
        pe->next = g_jpush_pushlist_ptr;

        tmp_str = jpush_push_getstoragename(str, 0, &tmp_len);
        pe->connection = jvm_str_dup(tmp_str, tmp_len);

        tmp_str = jpush_push_getstoragename(str, 1, &tmp_len);
        pe->midlet = jvm_str_dup(tmp_str, tmp_len);

        tmp_str = jpush_push_getstoragename(str, 2, &tmp_len);
        pe->filter = jvm_str_dup(tmp_str, tmp_len);

        tmp_str = jpush_push_getstoragename(str, 3, &tmp_len);
        pe->storagename = jvm_str_dup(tmp_str, tmp_len);

        pe->push_game_type = game_type;
        pe->portNo = -1;
        pe->available = KAL_FALSE;
        pe->appid = NULL;
        if ((pe->connection == NULL) || (pe->midlet == NULL) || (pe->filter == NULL) || (pe->storagename == NULL))
        {
            if (pe->connection)
            {
                free_ctrl_buffer(pe->connection);
            }
            if (pe->midlet)
            {
                free_ctrl_buffer(pe->midlet);
            }
            if (pe->filter)
            {
                free_ctrl_buffer(pe->filter);
            }
            if (pe->storagename)
            {
                free_ctrl_buffer(pe->storagename);
            }
            free_ctrl_buffer(pe);
            kal_give_mutex(J2ME_push_mutex);
            return (-2);
        }
        else
        {
            if (strncmp(pe->connection, "mms://:", 7) == 0)
            {
                _jpush_process_appid(pe->connection, &(pe->appid));
            }
            else if (strncmp(pe->connection, "sms://:", 7) == 0)
            {
                _jpush_process_port(pe->connection, &(pe->portNo));
            }
            else
            {
                if (pe->connection)
                {
                    free_ctrl_buffer(pe->connection);
                }
                if (pe->midlet)
                {
                    free_ctrl_buffer(pe->midlet);
                }
                if (pe->filter)
                {
                    free_ctrl_buffer(pe->filter);
                }
                if (pe->storagename)
                {
                    free_ctrl_buffer(pe->storagename);
                }
                free_ctrl_buffer(pe);
                kal_give_mutex(J2ME_push_mutex);
                return (-2);

            }
            g_jpush_pushlist_ptr = pe;
            g_push_length++;
        }
    }

    if (pe != NULL)
    {
        if (jpush_push_save() == 0)
        {
            kal_give_mutex(J2ME_push_mutex);
            return 0;
        }
    }
    kal_give_mutex(J2ME_push_mutex);
    return -2;
}


/*****************************************************************************
 * FUNCTION
 *  jpush_push_remove
 * DESCRIPTION
 *  remove the push registeration correspounding to the Connection and storagename
 * PARAMETERS
 *  str         [?]   
 *  store       [?]   
 * RETURNS
 *  void
 *****************************************************************************/
int jpush_push_remove(char *str, char *store)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    pushentry_struct *p;
    pushentry_struct *lastp;
    kal_int32 ret = -1;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_J2ME_REMOVEPUSHENTRY);
#ifdef MIDP_PUSH_DEBUG
    sprintf(_kvmLogStr, "J2ME Debug: removepushEntry %s %s", str, store);
    Kprintf();
#endif /* MIDP_PUSH_DEBUG */ 

    kal_take_mutex(J2ME_push_mutex);

    lastp = g_jpush_pushlist_ptr;
    /* Find the entry to remove */
    for (p = g_jpush_pushlist_ptr; p; p = p->next)
    {
        if (strncmp(str, p->connection, strlen(str)) == 0)
        {
            /* Check if the connection belongs to another suite. */
            if (strcmp(store, p->storagename) != 0)
            {
                ret = -2;
                continue;
            }

            if (strncmp(str, "mms://", 6) == 0)
            {
                J2ME_mms_register(p->appid, 1, PUSH_REGISTRY);  /* 1 for unregister */
            }
            else
            {
                J2ME_sms_unregister(p->portNo, PUSH_REGISTRY);
            }

            /* Remove the registration entry. */
            if (p == g_jpush_pushlist_ptr)
            {
                /* Replace the top of the list. */
                g_jpush_pushlist_ptr = p->next;
            }
            else
            {
                lastp->next = p->next;
            }

            g_push_length--;

            if (p->connection != NULL)
            {
                free_ctrl_buffer(p->connection);
            }
            if (p->midlet != NULL)
            {
                free_ctrl_buffer(p->midlet);
            }
            if (p->filter != NULL)
            {
                free_ctrl_buffer(p->filter);
            }
            if (p->storagename != NULL)
            {
                free_ctrl_buffer(p->storagename);
            }
            if (p->appid != NULL)
            {
                free_ctrl_buffer(p->appid);
            }
            free_ctrl_buffer(p);

            if (jpush_push_save() == 0)
            {
                kal_give_mutex(J2ME_push_mutex);
                return 0;
            }
        }
        lastp = p;
    }
    kal_give_mutex(J2ME_push_mutex);
    return ret;
}


/*****************************************************************************
 * FUNCTION
 *  push_process_recvd_mms_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  application_id      [?]    
 * RETURNS
 *  void
 *****************************************************************************/
void *push_process_recvd_mms_ind(char *application_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    pushentry_struct *p = NULL;
    char *appid = application_id;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_J2ME_PUSH_PROCESS_RECVD_SMS_IND);

    for (p = g_jpush_pushlist_ptr; p; p = p->next)
    {
        if (p->appid != NULL)
            if (strcmp(p->appid, appid) == 0)
            {
                break;
            }
    }

    return p;
}


/*****************************************************************************
 * FUNCTION
 *  jpush_push_deletesuite
 * DESCRIPTION
 *  Delete all of connections for a suite, using the storage name
 * PARAMETERS
 *  store       [?]   
 * RETURNS
 *  void
 *****************************************************************************/
void jpush_push_deletesuite(char *store)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    pushentry_struct *pushp;
    pushentry_struct **pPrevNext = &g_jpush_pushlist_ptr;
    pushentry_struct *pushnext;

    alarmentry_struct *alarmp;
    alarmentry_struct **alarmpPrevNext = &g_jpush_alarmlist_ptr;
    alarmentry_struct *alarmnext;
    kal_int32 i;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_J2ME_PUSHDELETESUITE);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -