FTP on Pocket PC

FTP on Pocket PC

Postby franz1964 » Fri Apr 21, 2006 1:09 pm

I have translate my application with FWPPC. Thanks!. FWPPC is a really good application!. It only take somes hours and this is the first time that I use fivewin.
Now I have to ftp data from the smartphone (Vodafone v1640) to a ftp server. How I have to operate ?
On XP I use wininet.dll but I think this is not working on Win Mobile.
I await your idea.
Thanks a lot.
franz1964
 
Posts: 7
Joined: Tue Apr 18, 2006 12:54 pm

Re: FTP on Pocket PC

Postby Enrico Maria Giordano » Fri Apr 21, 2006 4:39 pm

This is a sample:

Code: Select all  Expand view
#include "Fwce.ch"


//
// File attributes
//

#define FILE_ATTRIBUTE_READONLY  1
#define FILE_ATTRIBUTE_HIDDEN    2
#define FILE_ATTRIBUTE_SYSTEM    4
#define FILE_ATTRIBUTE_DIRECTORY 16
#define FILE_ATTRIBUTE_ARCHIVE   32
#define FILE_ATTRIBUTE_NORMAL    128
#define FILE_ATTRIBUTE_TEMPORARY 256


//
// access types for InternetOpen()
//

#define INTERNET_OPEN_TYPE_PRECONFIG                    0   // use registry configuration
#define INTERNET_OPEN_TYPE_DIRECT                       1   // direct to net
#define INTERNET_OPEN_TYPE_PROXY                        3   // via named proxy
#define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY  4   // prevent using java/script/INS


//
// manifests
//

#define INTERNET_INVALID_PORT_NUMBER    0           // use the protocol-specific default

#define INTERNET_DEFAULT_FTP_PORT       21          // default for FTP servers
#define INTERNET_DEFAULT_GOPHER_PORT    70          //    "     " gopher "
#define INTERNET_DEFAULT_HTTP_PORT      80          //    "     " HTTP   "
#define INTERNET_DEFAULT_HTTPS_PORT     443         //    "     " HTTPS  "
#define INTERNET_DEFAULT_SOCKS_PORT     1080        // default for SOCKS firewall servers.


//
// service types for InternetConnect()
//

#define INTERNET_SERVICE_FTP     1
#define INTERNET_SERVICE_GOPHER  2
#define INTERNET_SERVICE_HTTP    3


//
// flags for FTP
//

#define INTERNET_FLAG_TRANSFER_ASCII  1
#define INTERNET_FLAG_TRANSFER_BINARY 2


FUNCTION MAIN()

    LOCAL hInternet, hConnect

    hInternet = INTERNETOPEN( "Anystring", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 )

    hConnect = INTERNETCONNECT( hInternet, "Your ftp address", INTERNET_INVALID_PORT_NUMBER, "userid", "password", INTERNET_SERVICE_FTP, 0, 0 )

//    ? FTPGETFILE( hConnect, "Your remote file", "Your local file", 0, FILE_ATTRIBUTE_ARCHIVE, 0, 0 )

    ? FTPPUTFILE( hConnect, "Your local file", "Your remote file", 0, 0 )

    INTERNETCLOSEHANDLE( hConnect )

    INTERNETCLOSEHANDLE( hInternet )

    RETURN NIL


#pragma BEGINDUMP

#include "windows.h"
#include "wininet.h"
#include "hbapi.h"


LPWSTR AnsiToWide( LPSTR );


HB_FUNC( INTERNETOPEN )
{
    LPWSTR cAgent = AnsiToWide( hb_parc( 1 ) );
    LPWSTR cProxyName = AnsiToWide( hb_parc( 3 ) );
    LPWSTR cProxyBypass = AnsiToWide( hb_parc( 4 ) );

    HINTERNET hInternet = InternetOpen( cAgent, hb_parnl( 2 ), cProxyName, cProxyBypass, hb_parnl( 5 ) );

    hb_xfree( cAgent );
    hb_xfree( cProxyName );
    hb_xfree( cProxyBypass );

    hb_retnl( ( LONG ) hInternet );
}


HB_FUNC( INTERNETCLOSEHANDLE )
{
    hb_retl( InternetCloseHandle( ( HINTERNET ) hb_parnl( 1 ) ) );
}


HB_FUNC( INTERNETCONNECT )
{
    LPWSTR cServerName = AnsiToWide( hb_parc( 2 ) );
    LPWSTR cUserName = AnsiToWide( hb_parc( 4 ) );
    LPWSTR cPassword = AnsiToWide( hb_parc( 5 ) );

    HINTERNET hInternet = InternetConnect( ( HINTERNET ) hb_parnl( 1 ), cServerName, ( INTERNET_PORT ) hb_parnl( 3 ), cUserName, cPassword, hb_parnl( 6 ), hb_parnl( 7 ), hb_parnl( 8 ) );

    hb_xfree( cServerName );
    hb_xfree( cUserName );
    hb_xfree( cPassword );

    hb_retnl( ( LONG ) hInternet );
}


HB_FUNC( FTPGETFILE )
{
    LPWSTR cRemoteFile = AnsiToWide( hb_parc( 2 ) );
    LPWSTR cNewFile = AnsiToWide( hb_parc( 3 ) );

    hb_retl( FtpGetFile( ( HINTERNET ) hb_parnl( 1 ), cRemoteFile, cNewFile, hb_parl( 4 ), hb_parnl( 5 ), hb_parnl( 6 ), hb_parnl( 7 ) ) );

    hb_xfree( cRemoteFile );
    hb_xfree( cNewFile );
}


HB_FUNC( FTPPUTFILE )
{
    LPWSTR cLocalFile = AnsiToWide( hb_parc( 2 ) );
    LPWSTR cNewRemoteFile = AnsiToWide( hb_parc( 3 ) );

    hb_retl( FtpPutFile( ( HINTERNET ) hb_parnl( 1 ), cLocalFile, cNewRemoteFile, hb_parnl( 4 ), hb_parnl( 5 ) ) );

    hb_xfree( cLocalFile );
    hb_xfree( cNewRemoteFile );
}

#pragma ENDDUMP
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Fri Apr 21, 2006 4:56 pm

Enrico,

Many thanks for your sample. We include it in FWPPC samples if you don't mind it :)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Grazie per l'aiuto ma ho un problema....

Postby franz1964 » Fri Apr 21, 2006 6:31 pm

ho inserito il tuo codice ma quando linko il programma ho questi errori:
---------------------------------------
menu.obj : error LNK2001: unresolved external symbol "void __cdecl
HB_FUN_FTPSETCURRENTDIRECTORY(void)" (?HB_FUN_FTPSETCURRENTDIRECTORY@@YAXXZ)
menu.obj : error LNK2001: unresolved external symbol "void __cdecl HB_FUN_INETCONNECT(void)" (?HB_FUN_INETCONNECT@@YAXXZ)
menu.obj : error LNK2001: unresolved external symbol "void __cdecl HB_FUN_INETOPEN(void)" (?HB_FUN_INETOPEN@@YAXXZ)
menu.obj : error LNK2019: unresolved external symbol InternetOpenW referenced in function "void __cdecl HB_FUN_INTERNETOPEN(void)" (?HB_FUN_INTERNETOPEN@@YAXXZ)
menu.obj : error LNK2019: unresolved external symbol InternetCloseHandle referenced in function "void __cdecl HB_FUN_INTERNETCLOSEHANDLE(void)" (?HB_FUN_INTERNETCLOSEHANDLE@@YAXXZ)
menu.obj : error LNK2019: unresolved external symbol InternetConnectW referenced in function "void __cdecl HB_FUN_INTERNETCONNECT(void)" (?HB_FUN_INTERNETCONNECT@@YAXXZ)
menu.obj : error LNK2019: unresolved external symbol FtpGetFileW referenced in function "void __cdecl HB_FUN_FTPGETFILE(void)" (?HB_FUN_FTPGETFILE@@YAXXZ)
menu.obj : error LNK2019: unresolved external symbol FtpPutFileW referenced in function "void __cdecl HB_FUN_FTPPUTFILE(void)" (?HB_FUN_FTPPUTFILE@@YAXXZ)
menu.exe : fatal error LNK1120: 8 unresolved externals
-----------------------------
Dove ho sbagliato ?
Grazie Ciao
franz1964
 
Posts: 7
Joined: Tue Apr 18, 2006 12:54 pm

Re: Grazie per l'aiuto ma ho un problema....

Postby Enrico Maria Giordano » Fri Apr 21, 2006 6:38 pm

menu.obj : error LNK2001: unresolved external symbol "void __cdecl
HB_FUN_FTPSETCURRENTDIRECTORY(void)"

The above (and other) is not from my sample.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Sorry. I mixed from 2 source

Postby franz1964 » Fri Apr 21, 2006 7:05 pm

this is the result with your code:
menu.obj : error LNK2019: unresolved external symbol InternetOpenW referenced in function "void __cdecl HB_FUN_INTERNETOPEN(void)" (?HB_FUN_INTERNETOPEN@@YAXXZ)
menu.obj : error LNK2019: unresolved external symbol InternetCloseHandle referenced in function "void __cdecl HB_FUN_INTERNETCLOSEHANDLE(void)" (?HB_FUN_INTERNETCLOSEHANDLE@@YAXXZ)
menu.obj : error LNK2019: unresolved external symbol InternetConnectW referenced in function "void __cdecl HB_FUN_INTERNETCONNECT(void)" (?HB_FUN_INTERNETCONNECT@@YAXXZ)
menu.obj : error LNK2019: unresolved external symbol FtpGetFileW referenced in function "void __cdecl HB_FUN_FTPGETFILE(void)" (?HB_FUN_FTPGETFILE@@YAXXZ)
menu.obj : error LNK2019: unresolved external symbol FtpPutFileW referenced in function "void __cdecl HB_FUN_FTPPUTFILE(void)" (?HB_FUN_FTPPUTFILE@@YAXXZ)
menu.exe : fatal error LNK1120: 5 unresolved externals
-------------------
Where I failed.
Thanks
Alfredo
franz1964
 
Posts: 7
Joined: Tue Apr 18, 2006 12:54 pm

Re: Sorry. I mixed from 2 source

Postby Enrico Maria Giordano » Fri Apr 21, 2006 7:31 pm

You have to link wininet.lib.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

missing wininet.lib in buildce.bat

Postby franz1964 » Fri Apr 21, 2006 7:34 pm

I found my error. no wininet.lib declared in buildce.bat.
Stop for this evening. link is ok tomorrow I will test to transfer data.
Ciao.
Alfredo
franz1964
 
Posts: 7
Joined: Tue Apr 18, 2006 12:54 pm

Postby Biel EA6DD » Thu Aug 17, 2006 4:01 pm

Hi,
starting from the sample of Enrico (many thanks), I have developed a function to send customer orders from PDA to PC via FTP, using GPRS connection.

All is runing ok when GPRS is conected (manually connected), I'm looking (and not finding for the moment) a way to automatic connect the GPRS, like do for example internet explorer .

Thanks in advance.
Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
User avatar
Biel EA6DD
 
Posts: 682
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca

Postby Enrico Maria Giordano » Thu Aug 17, 2006 4:08 pm

I'm not sure if it is applicable on GPRS connections but try adapting the following Win32 function:

Code: Select all  Expand view
#pragma BEGINDUMP

#include <WinTen.h>
#include <Windows.h>
#include <ras.h>
#include <HbApi.h>
#include <ClipApi.h>

HB_FUNC( RAS_DIAL ) // ( cEntryName, @nRetVal, @hRasCon ) -> NIL
{
    RASDIALPARAMS rdp;

    BOOL pwd;

    HRASCONN hRas = 0;

    DWORD res;

    rdp.dwSize = 1052;

    lstrcpy( rdp.szEntryName, hb_parc( 1 ) );

    rdp.szPhoneNumber[ 0 ] = 0;
    rdp.szCallbackNumber[ 0 ] = 0;
    rdp.szUserName[ 0 ] = 0;
    rdp.szPassword[ 0 ] = 0;
    rdp.szDomain[ 0 ] = 0;

    RasGetEntryDialParams( 0, &rdp, &pwd );

    res = RasDial( 0, 0, &rdp, 0, 0, &hRas );

    hb_stornl( res, 2 );
    hb_stornl( ( LONG ) hRas, 3 );
}

#pragma ENDDUMP


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby pawelu » Thu Aug 17, 2006 4:52 pm

Hello,

I use function like sample below.

Regards
Pawel

Code: Select all  Expand view
// Header file: <connmgr.h>
// Library linked: CellCore.Lib
// Pocket Pc: Properly create GPRS connection (My ISP) in Connections Settings
//            Connections Settings, Advanced Tab, Select Networks Button, set to My ISP

HB_FUNC (GPRSCONNECTION)
{
   HANDLE phWebConnection = NULL;
   DWORD pdwStatus = 0;

   ConnMgrConnectionStatus (phWebConnection, &pdwStatus);
   if (pdwStatus == CONNMGR_STATUS_CONNECTED)
   {
      hb_retl (TRUE);
   }
   else
   {
      CONNMGR_CONNECTIONINFO sConInfo;
      memset (&sConInfo,0, sizeof (CONNMGR_CONNECTIONINFO));
      sConInfo.cbSize = sizeof (CONNMGR_CONNECTIONINFO);
      sConInfo.dwParams = CONNMGR_PARAM_GUIDDESTNET;
      sConInfo.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;
      sConInfo.dwFlags = CONNMGR_FLAG_PROXY_HTTP;
      sConInfo.bExclusive = FALSE;
      sConInfo.bDisabled = FALSE;
      sConInfo.guidDestNet = IID_DestNetInternet;

      if (ConnMgrEstablishConnection (&sConInfo, &phWebConnection) == S_OK)
      {
         for (unsigned int k = 0; k < 8; k ++)
         {
            ConnMgrConnectionStatus(phWebConnection,&pdwStatus);
            if (pdwStatus == CONNMGR_STATUS_CONNECTED)
            {
               hb_retl (TRUE);
            }
            else
            {
               if (pdwStatus == CONNMGR_STATUS_CONNECTIONCANCELED || pdwStatus == CONNMGR_STATUS_WAITINGCONNECTIONABORT)
               {
                  hb_retl (FALSE);
               }
               Sleep (2500);
               ConnMgrConnectionStatus (phWebConnection, &pdwStatus);
               if (pdwStatus == CONNMGR_STATUS_WAITINGCONNECTION)
               {}
               if (pdwStatus == CONNMGR_STATUS_CONNECTIONCANCELED || pdwStatus == CONNMGR_STATUS_WAITINGCONNECTIONABORT)
               {
                  hb_retl (FALSE);
               }
            }
         }
         hb_retl (FALSE);
      }
      else
      {
         hb_retl (FALSE);
      }
   }
}
pawelu
 
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland

Postby Biel EA6DD » Mon Aug 21, 2006 8:33 am

Hi all,
many thanks Enrico and Pawel. I tryed the code provided by Pawel and it runs 100 %.

Many thanks again both.
Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
User avatar
Biel EA6DD
 
Posts: 682
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca

Postby Richard Chidiak » Fri Aug 25, 2006 7:43 pm

Biel EA6DD wrote:Hi all,
many thanks Enrico and Pawel. I tryed the code provided by Pawel and it runs 100 %.

Many thanks again both.


Biel

Where did you get the cellcore.lib from ?

Do you have a link for it ?

Can you share your gprs connexion program ?

Thanks

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Postby Biel EA6DD » Mon Aug 28, 2006 6:46 am

Hello Richard

The cellcore.lib is included in the VCE, you only need to add to your compilation script.

About the connection program, you can use the code posted by Pawel its run perfect. Remember to include "initguid.h" and "connmgr.h" headers.
Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
User avatar
Biel EA6DD
 
Posts: 682
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca

Next

Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 10 guests