/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004
FILE NAME
ftpc_handler.c
DESCRIPTION
Message handler source for the FTP Client library
*/
#include <bdaddr.h>
#include <message.h>
#include <stream.h>
#include <source.h>
#include <panic.h>
#include <print.h>
#include <string.h>
#include "ftpc.h"
#include "ftpc_private.h"
/* Static Strings */
/* UUID Target String for Obex_FTP */
static const uint8 ftp_targ[]={0xf9,0xec,0x7b,0xc4, 0x95,0x3c, 0x11,0xd2, 0x98,0x4e, 0x52,0x54,0x00,0xdc,0x9e,0x09};
/* Type string to use to browse a folders contents */
static const uint8 typeFolder[]="x-obex/folder-listing";
/* Error value conversion */
static ftpc_lib_status convert_error(goep_lib_status status);
/* Internal Message Handlers */
static void handleIntConnect(ftpcState *state, const FTPC_INT_CONNECT_T *msg);
static void handleIntDisconnect(ftpcState *state);
static void handleIntGotoRoot(ftpcState *state);
static void handleIntGotoParent(ftpcState *state);
static void handleIntGotoSubfolder(ftpcState *state, const FTPC_INT_GOTO_SUBFOLDER_T *msg);
static void handleIntBrowseFolder(ftpcState *state);
static void handleIntPushObject(ftpcState *state, const FTPC_INT_PUSH_OBJECT_T *msg);
static void handleIntPushNextPacket(ftpcState *state, const FTPC_INT_PUSH_NEXT_PACKET_T *msg);
static void handleIntPushObjectSrc(ftpcState *state, const FTPC_INT_PUSH_OBJECT_SRC_T *msg);
static void handleIntPushNextPacketSrc(ftpcState *state, const FTPC_INT_PUSH_NEXT_PACKET_SRC_T *msg);
static void handleIntPullObject(ftpcState *state, const FTPC_INT_PULL_OBJECT_T *msg);
static void handleIntPullNextPacket(ftpcState *state);
static void handleIntAbort(ftpcState *state);
static void handleIntDelete(ftpcState *state, const FTPC_INT_DELETE_T *msg);
/* GOEP Library Message Handlers */
static void handleGoepInitCfm(ftpcState *state, const GOEP_INIT_CFM_T *msg);
static void handleGoepChannelInd(ftpcState *state, const GOEP_CHANNEL_IND_T *msg);
static void handleGoepConnectCfm(ftpcState *state, const GOEP_CONNECT_CFM_T *msg);
static void handleGoepDisconnectInd(ftpcState *state, const GOEP_DISCONNECT_IND_T *msg);
static void handleGoepSetPathCfm(ftpcState *state, const GOEP_SET_PATH_CFM_T *msg);
static void handleGoepGetStartInd(ftpcState *state, const GOEP_LOCAL_GET_START_IND_T *msg);
static void handleGoepGetDataInd(ftpcState *state, const GOEP_LOCAL_GET_DATA_IND_T *msg);
static void handleGoepGetCompleteInd(ftpcState *state, const GOEP_LOCAL_GET_COMPLETE_IND_T *msg);
static void handleGoepPutCompleteInd(ftpcState *state, const GOEP_LOCAL_PUT_COMPLETE_IND_T *msg);
static void handleGoepPutMoreDateReq(ftpcState *state);
static void handleGoepDeleteCfm(ftpcState *state, const GOEP_DELETE_CFM_T *msg);
void ftpcHandler(Task task, MessageId id, Message message)
{
/* Get task control block */
ftpcState *state = (ftpcState*)task;
switch(id)
{
/* Internal FTP Client messages */
case FTPC_INT_CONNECT:
handleIntConnect(state, (FTPC_INT_CONNECT_T*)message);
break;
case FTPC_INT_DISCONNECT:
handleIntDisconnect(state);
break;
case FTPC_INT_GOTO_ROOT:
handleIntGotoRoot(state);
break;
case FTPC_INT_GOTO_PARENT:
handleIntGotoParent(state);
break;
case FTPC_INT_GOTO_SUBFOLDER:
handleIntGotoSubfolder(state, (FTPC_INT_GOTO_SUBFOLDER_T*)message);
break;
case FTPC_INT_BROWSE_FOLDER:
handleIntBrowseFolder(state);
break;
case FTPC_INT_PUSH_OBJECT:
handleIntPushObject(state, (FTPC_INT_PUSH_OBJECT_T*)message);
break;
case FTPC_INT_PUSH_NEXT_PACKET:
handleIntPushNextPacket(state, (FTPC_INT_PUSH_NEXT_PACKET_T*)message);
break;
case FTPC_INT_PUSH_OBJECT_SRC:
handleIntPushObjectSrc(state, (FTPC_INT_PUSH_OBJECT_SRC_T*)message);
break;
case FTPC_INT_PUSH_NEXT_PACKET_SRC:
handleIntPushNextPacketSrc(state, (FTPC_INT_PUSH_NEXT_PACKET_SRC_T*)message);
break;
case FTPC_INT_PULL_OBJECT:
handleIntPullObject(state, (FTPC_INT_PULL_OBJECT_T*)message);
break;
case FTPC_INT_PULL_NEXT_PACKET:
handleIntPullNextPacket(state);
break;
case FTPC_INT_ABORT:
handleIntAbort(state);
break;
case FTPC_INT_DELETE:
handleIntDelete(state, (FTPC_INT_DELETE_T*)message);
break;
/* Messages from the GOEP Library */
case GOEP_INIT_CFM:
handleGoepInitCfm(state, (GOEP_INIT_CFM_T*)message);
break;
case GOEP_CHANNEL_IND:
handleGoepChannelInd(state, (GOEP_CHANNEL_IND_T*)message);
break;
case GOEP_CONNECT_CFM:
handleGoepConnectCfm(state, (GOEP_CONNECT_CFM_T*)message);
break;
case GOEP_DISCONNECT_IND:
handleGoepDisconnectInd(state, (GOEP_DISCONNECT_IND_T*)message);
break;
case GOEP_SET_PATH_CFM:
handleGoepSetPathCfm(state, (GOEP_SET_PATH_CFM_T*)message);
break;
case GOEP_LOCAL_GET_START_IND:
handleGoepGetStartInd(state, (GOEP_LOCAL_GET_START_IND_T*)message);
break;
case GOEP_LOCAL_GET_DATA_IND:
handleGoepGetDataInd(state, (GOEP_LOCAL_GET_DATA_IND_T*)message);
break;
case GOEP_LOCAL_GET_COMPLETE_IND:
handleGoepGetCompleteInd(state, (GOEP_LOCAL_GET_COMPLETE_IND_T*)message);
break;
case GOEP_LOCAL_PUT_COMPLETE_IND:
handleGoepPutCompleteInd(state, (GOEP_LOCAL_PUT_COMPLETE_IND_T*)message);
break;
case GOEP_LOCAL_PUT_DATA_REQUEST_IND:
handleGoepPutMoreDateReq(state);
break;
case GOEP_DELETE_CFM:
handleGoepDeleteCfm(state, (GOEP_DELETE_CFM_T*)message);
break;
default:
PRINT(("FTPC Unhandled Message : %d , 0x%0X\n",id,id) );
break;
}
}
/* Internal Message Handlers */
static void handleIntConnect(ftpcState *state, const FTPC_INT_CONNECT_T *msg)
{
PRINT(("handleIntConnect\n"));
/* Store requested session parameters */
state->packetSize = msg->maxPacketSize;
state->bdAddr = msg->bdAddr;
state->currCom= ftpc_com_Connect;
if (state->handle)
{ /* Goep library already initialised for this client */
if (state->rfcChan == 0)
GoepGetChannel(state->handle);
else /* Already have a RFCOMM channel, send connect request */
GoepConnect(state->handle, &state->bdAddr, state->rfcChan, state->packetSize ,sizeof(ftp_targ), ftp_targ);
}
else
{
/* Initialise GOEP */
GoepInit(&state->task, goep_Client, goep_FTP);
}
}
static void handleIntDisconnect(ftpcState *state)
{
PRINT(("handleIntDisconnect\n"));
if (state->currCom!= ftpc_com_None)
{ /* Not idle, Send Error Message */
ftpcMsgSendDisConnectCfm(state, ftpc_not_idle);
}
else
{
/* Send disconnect */
GoepDisconnect(state->handle);
/* Set command to close session */
state->currCom= ftpc_com_Disconnect;
}
}
static void handleIntGotoRoot(ftpcState *state)
{
PRINT(("handleIntGotoRoot\n"));
if (state->currCom!= ftpc_com_None)
{ /* Not idle, Send Error Message */
MAKE_FTPC_MESSAGE(FTPC_GOTO_ROOT_CFM);
message->status= ftpc_not_idle;
message->session=(FTPC*)state;
MessageSend(state->theAppTask, FTPC_GOTO_ROOT_CFM, message);
}
else
{
/* Send Set Path */
GoepSetPath(state->handle, GOEP_PATH_NOCREATE, 0, NULL);
/* Set command to close session */
state->currCom= ftpc_com_GotoRoot;
}
}
static void handleIntGotoParent(ftpcState *state)
{
PRINT(("handleIntGotoParent\n"));
if (state->currCom!= ftpc_com_None)
{ /* Not idle, Send Error Message */
MAKE_FTPC_MESSAGE(FTPC_GOTO_PARENT_C
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
qualcomm蓝牙芯片 蓝牙实现ftp程序的客户端源代码.rar (17个子文件)
www.pudn.com.txt 218B
ftpc
ftpc_interface.c 11KB
ftpc_messages.c 3KB
ftpc_handler.c 22KB
ftpc_init.c 807B
VARIANTS 109B
ftpc.h 15KB
debug
ftpc_private.h 5KB
default
ftpc_init.o 23KB
ftpc_messages.o 35KB
ftpc_handler.o 90KB
depend
ftpc_interface 841B
ftpc_messages 740B
ftpc_init 793B
flags.compile 212B
ftpc_handler 1KB
ftpc_interface.o 47KB
共 17 条
- 1
周楷雯
- 粉丝: 78
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0