Code/CFLite/CFNetwork: Difference between revisions

From kJams Wiki
Jump to navigation Jump to search
Sasho (talk | contribs)
No edit summary
 
(52 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Home of future project.
I hereby release everything here under the terms of the "[https://en.wikipedia.org/wiki/BSD_licenses#2-clause_license_.28.22Simplified_BSD_License.22_or_.22FreeBSD_License.22.29 FreeBSD License]".
==If you use QuickTime on Windows, or Parallels Desktop for debugging Windows==
Be very sure you [[CFLite#Cooperating_with_QuickTime|check this stuff out]], it's important.


Download the [http://kjams.com/cflite/downloads/cfnetwork.zip CFNetwork] framework.
==How to get started==
 
#if you're on Windows:
= OpenCFLite project and file changes =
##Install [http://support.apple.com/kb/DL999 Bonjour Print Services]. (you do not need to run the printer wizard nor set up a printer, this is just a service that CFTest makes use of)
* CFNetTest\CFTest\win_vs\pre_build.bat; Change VS vars path to call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat"
##install [http://downloads.activestate.com/ActivePython/releases/ Python 2.7] do NOT install python 3. Python is used for post-build steps / deployment
* CFTest.vcproj - change QuickTime libraries path in Linker to $(SolutionDir)..\..\kJams\External\QuickTime SDK\Libraries
## i installed [https://www.visualstudio.com/downloads/ Visual Studio Community Edition] (the free one). if you install something else, YMMV
* Add explicit direction __WIN32__ to PreprocessorDefinitions so that VS2008 properly reflects disabled code
## when [https://info.qt.io/download-qt-for-application-development installing Qt Open Source], be sure to install MSVC2015 32 and 64
* mDNSResponder support (dns-sd)
#download <googa>../../../cflite/downloads/CoreFoundation.zip|CoreFoundation|/downloads/CoreFoundationInstaller</googa> (which includes CFTest with CFLite and CFNetwork) and put it in your development tree
** Add mDNSResponder folder to the include path to OpenCFLite project;
# using Qt (tested on 5.9.1)
** Add lib file to linker configuration $(ProjectDir)..\..\mDNSResponder\lib\dnssd.lib
## on Windows: open CF/opencflite-476.17.2/Qt/CFLite/CFLite.pro.
 
## you SHOULD be able to use the .user file, cuz all paths are relative, so if it asks if you want to "take over" that file, even though it was created on another machine, go ahead
=== CFNetwork file references ===
## open CFTest/project/qt/CFTest/CFTest_win.pro (do the same thing, take over that file if it asks)
** CFNetwork\Host\CFHost.c
## your "Session" should look like this: (on Mac you will not see CFLite )<br>{{SERVER}}/cflite/screenshots/qt_session.png
** CFNetwork\HTTP\CFHTTPAuthentication.c
## on Windows:
** CFNetwork\HTTP\CFHTTPConnection.c
### set CFTest_win/mac to the active project, use the 64bit one
** CFNetwork\HTTP\CFHTTPFilter.c
### set it to depend on and sync with CFLite, like this:<br>{{SERVER}}/cflite/screenshots/qt_session_dependencies.png
** CFNetwork\HTTP\CFHTTPMessage.c
## below screen shots show 64bit debug as an example, (on mac they'll show "clang" instead of "MSVC2015") you can optionally set up 32bit debug, and also release of both 32 and 64. Note mac doesn't have 32bit.
** CFNetwork\HTTP\CFHTTPServer.c
## Windows: how CFLite build settings should look: (ignore run settings)<br>{{SERVER}}/cflite/screenshots/qt_build_cflite.png
** CFNetwork\HTTP\CFHTTPStream.c
## how CFTest build settings should look:<br>{{SERVER}}/cflite/screenshots/qt_build_cftest.png
** CFNetwork\SharedCode\CFNetConnection.c
## how CFTest run settings should look:<br>{{SERVER}}/cflite/screenshots/qt_run_cftest.png
** CFNetwork\NetServices\CFNetServiceBrowser.c
# if you're using Visual Studio
** CFNetwork\NetServices\CFNetServiceMonitor.c
## Open the file "CFNetwork/CFTest/win_vs/CFTest.sln".
** CFNetwork\NetServices\CFNetServices.c
## go to "Solution Explorer"
** CFNetwork\CFNetwork.c
## select "CFTest", right click it and pick "Properties"
** CFNetwork\CFNetworkInternal.h
## in the "Configuration:" menu, pick "All Configurations"
** CFNetwork\SharedCode\CFNetworkSchedule.c
## go to "configuration properties->debugging"
** CFNetwork\SharedCode\CFNetworkThreadSupport.c
## set "Command" to "$(SolutionDir)build\$(TargetName).app\Contents\Windows\$(TargetFileName)".
** CFNetwork\SharedCode\CFServer.c
## in VS2010 and later, actually you may need to just specify the full path (in step 4 above), as "$(TargetName)" does not seem to expand correctly for debug vs. release
** CFNetwork\Stream\CFSocketStream.c
** CFNetwork\Stream\CFSocketStreamImpl.h
** CFNetwork\Proxies\ProxySupport.c
** CFNetwork\HTTP\CFHTTPConnectionInternal.h
** CFNetwork\HTTP\CFHTTPInternal.h
** CFNetwork\HTTP\NTLM\ntlmBlobPriv.cpp
** CFNetwork\HTTP\NTLM\NtlmGenerator.cpp
** CFNetwork\NetDiagnostics\CFNetDiagnosticsInternal.h
** CFNetwork\NetDiagnostics\CFNetDiagnosticsProtocol.h
** CFNetwork\include\CFNetwork\CFHTTPConnectionPriv.h
** CFNetwork\include\CFNetwork\CFHTTPAuthentication.h
** CFNetwork\include\CFNetwork\CFHTTPMessage.h
** CFNetwork\include\CFNetwork\CFHTTPMessagePriv.h
** CFNetwork\include\CFNetwork\CFHTTPServerPriv.h
** CFNetwork\include\CFNetwork\CFHTTPStream.h
** CFNetwork\include\CFNetwork\CFHTTPStreamPriv.h
** CFNetwork\include\CFNetwork\CFNetDiagnostics.h
** CFNetwork\include\CFNetwork\CFNetDiagnosticsPriv.h
** CFNetwork\include\CFNetwork\cfnetservices.h
** CFNetwork\include\CFNetwork\CFNetServicesPriv.h
** CFNetwork\include\CFNetwork\CFNetwork.h
** CFNetwork\include\CFNetwork\CFNetworkDefs.h
** CFNetwork\include\CFNetwork\CFNetworkDefs.h
** CFNetwork\include\CFNetwork\CFNetworkPriv.h
** CFNetwork\include\CFNetwork\CFSocketStream.h
** CFNetwork\include\CFNetwork\CFSocketStreamPriv.h
 
=== File modifications ===
* CFBase.h - make typedef for Boolean type available to WINDOWS target
** Line added to CFBase.h - "typedef unsigned char Boolean;
* CFRuntime.c - Added two new functions for socket initialization (WinSock requires startup code)
** Added __CFSocketInitialize
** Added __CFSocketInitializeWinSock
* Socket initialization is added to __CFInitialize
** CFSocket ensures initialization on creation. However this is needed so that any other code could reference WinSock API (Ex: AddressLookup)
* CFSocketStream.c  - instead of the default need to use the code in CFNetwork (NOTE: This file needs to be references in includes)
* CFUrlAccess.c - merge in new functionality from _CFUrlAccess.c available in CFNetwork distribution
** Added _CFHTTPMessageSendRequest
** Added _CFURLCreateDataAndPropertiesFromResource
** Added _CFURLWriteDataAndPropertiesToResource
** Added _CFURLDestroyResource
* Add support for HTTP URL into the existing function CFURLCreateDataAndPropertiesFromResource
* ForFoundationOnly.h - added HTTP cleanup routines
 
= Porting CFNetwork to VS complier =
 
First import thing to note is compiler differences on difference platforms - Visual Studio 2008 supports C90 standard. A newer complier was used to develop CFNetwork. Hence the most important differences:
* All variable definitions must be placed at the beginning of each scope (otherwise it fails with "illegal type as an expression" errors)
* C90 allows structure initialization only by compile time constants (no pointers or even constants pointers to constant data)
* inline support - Visual studio uses keyword __inline (double underscore is required)
* Visual Studio compiler does not allow double class storage specifier such as "static static int var"

Latest revision as of 16:48, 10 August 2017

I hereby release everything here under the terms of the "FreeBSD License".

If you use QuickTime on Windows, or Parallels Desktop for debugging Windows

Be very sure you check this stuff out, it's important.

How to get started

  1. if you're on Windows:
    1. Install Bonjour Print Services. (you do not need to run the printer wizard nor set up a printer, this is just a service that CFTest makes use of)
    2. install Python 2.7 do NOT install python 3. Python is used for post-build steps / deployment
    3. i installed Visual Studio Community Edition (the free one). if you install something else, YMMV
    4. when installing Qt Open Source, be sure to install MSVC2015 32 and 64
  2. download CoreFoundation (which includes CFTest with CFLite and CFNetwork) and put it in your development tree
  3. using Qt (tested on 5.9.1)
    1. on Windows: open CF/opencflite-476.17.2/Qt/CFLite/CFLite.pro.
    2. you SHOULD be able to use the .user file, cuz all paths are relative, so if it asks if you want to "take over" that file, even though it was created on another machine, go ahead
    3. open CFTest/project/qt/CFTest/CFTest_win.pro (do the same thing, take over that file if it asks)
    4. your "Session" should look like this: (on Mac you will not see CFLite )
      qt_session.png
    5. on Windows:
      1. set CFTest_win/mac to the active project, use the 64bit one
      2. set it to depend on and sync with CFLite, like this:
        qt_session_dependencies.png
    6. below screen shots show 64bit debug as an example, (on mac they'll show "clang" instead of "MSVC2015") you can optionally set up 32bit debug, and also release of both 32 and 64. Note mac doesn't have 32bit.
    7. Windows: how CFLite build settings should look: (ignore run settings)
      qt_build_cflite.png
    8. how CFTest build settings should look:
      qt_build_cftest.png
    9. how CFTest run settings should look:
      qt_run_cftest.png
  4. if you're using Visual Studio
    1. Open the file "CFNetwork/CFTest/win_vs/CFTest.sln".
    2. go to "Solution Explorer"
    3. select "CFTest", right click it and pick "Properties"
    4. in the "Configuration:" menu, pick "All Configurations"
    5. go to "configuration properties->debugging"
    6. set "Command" to "$(SolutionDir)build\$(TargetName).app\Contents\Windows\$(TargetFileName)".
    7. in VS2010 and later, actually you may need to just specify the full path (in step 4 above), as "$(TargetName)" does not seem to expand correctly for debug vs. release