| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file symbian.cpp |
| 5 | * |
| 6 | * Part of the OpenJazz project |
| 7 | * |
| 8 | * @section Licence |
| 9 | * OpenJazz is distributed under the terms of |
| 10 | * the GNU General Public License, version 2.0 |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #include "symbian.h" |
| 15 | |
| 16 | #ifdef __SYMBIAN32__ |
| 17 | |
| 18 | #include <eikenv.h> |
| 19 | #include <eikapp.h> |
| 20 | #include <eikappui.h> |
| 21 | #include <stdio.h> |
| 22 | |
| 23 | #include <eikapp.h> |
| 24 | #include <e32base.h> |
| 25 | #include <sdlapp.h> |
| 26 | #include <BAUTILS.H> |
| 27 | #include <e32math.h> |
| 28 | |
| 29 | #include "util.h" |
| 30 | #include "io/file.h" |
| 31 | |
| 32 | char KOpenJazzPath[256]; |
| 33 | FILE* mystdout = NULL; |
| 34 | FILE *mystderr = NULL; |
| 35 | |
| 36 | /// Symbian app |
| 37 | class COpenJazzApp: public CSDLApp { |
| 38 | public: |
| 39 | COpenJazzApp(); |
| 40 | ~COpenJazzApp(); |
| 41 | #ifdef UIQ3 |
| 42 | /** |
| 43 | * Returns the resource id to be used to declare the views supported by this UIQ3 app |
| 44 | * @return TInt, resource id |
| 45 | */ |
| 46 | TInt ViewResourceId(); |
| 47 | #endif |
| 48 | /** |
| 49 | * This has a default empty implementation. |
| 50 | * Is called just before SDL_Main is called to allow init of system vars |
| 51 | */ |
| 52 | virtual void PreInitializeAppL(); |
| 53 | |
| 54 | TUid AppDllUid() const; |
| 55 | |
| 56 | }; |
| 57 | |
| 58 | |
| 59 | CApaApplication* NewApplication() { |
| 60 | // Return pointer to newly created CQMApp |
| 61 | return new COpenJazzApp; |
| 62 | } |
| 63 | |
| 64 | #include <eikstart.h> |
| 65 | // E32Main() contains the program's start up code, the entry point for an EXE. |
| 66 | GLDEF_C TInt E32Main() { |
| 67 | return EikStart::RunApplication(NewApplication); |
| 68 | } |
| 69 | |
| 70 | |
| 71 | COpenJazzApp::COpenJazzApp() { |
| 72 | } |
| 73 | |
| 74 | COpenJazzApp::~COpenJazzApp() { |
| 75 | fflush(mystdout); |
| 76 | fflush(mystderr); |
| 77 | fflush(stdout); |
| 78 | fflush(stderr); |
| 79 | fclose(stdout); |
| 80 | fclose(stderr); |
| 81 | } |
| 82 | #ifdef UIQ3 |
| 83 | #include <OpenJazz.rsg> |
| 84 | /** |
| 85 | * Returns the resource id to be used to declare the views supported by this UIQ3 app |
| 86 | * @return TInt, resource id |
| 87 | */ |
| 88 | TInt COpenJazzApp::ViewResourceId() { |
| 89 | return R_SDL_VIEW_UI_CONFIGURATIONS; |
| 90 | } |
| 91 | #endif |
| 92 | |
| 93 | /** |
| 94 | * This has a default empty implementation. |
| 95 | * Is called just before SDL_Main is called to allow init of system vars |
| 96 | */ |
| 97 | void COpenJazzApp::PreInitializeAppL() |
| 98 | { |
| 99 | TFileName filename; |
| 100 | TPtr8 ptr((unsigned char*) KOpenJazzPath, 0, 255); |
| 101 | #ifdef UIQ3 |
| 102 | mystdout = fopen("c:\\shared\\openjazz\\stdout.txt","w+"); |
| 103 | mystderr = fopen("c:\\shared\\openjazz\\stderr.txt","w+"); |
| 104 | #else |
| 105 | mystdout = fopen("c:\\data\\openjazz\\stdout.txt","w+"); |
| 106 | mystderr = fopen("c:\\data\\openjazz\\stderr.txt","w+"); |
| 107 | #endif |
| 108 | *stderr = *mystdout; |
| 109 | *stdout = *mystderr; |
| 110 | filename = _L("C:\\openjazz\\"); |
| 111 | for(TInt i = 'D';i<'Z';i++) |
| 112 | { |
| 113 | filename[0] = i; |
| 114 | if(BaflUtils::PathExists(CEikonEnv::Static()->FsSession(), filename)) |
| 115 | { |
| 116 | ptr.Copy(filename); |
| 117 | ptr.ZeroTerminate(); |
| 118 | return; |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | #ifdef UIQ3 |
| 123 | ptr.Copy(_L8("c:\\shared\\openjazz\\")); |
| 124 | #else |
| 125 | ptr.Copy(_L8("c:\\data\\openjazz\\")); |
| 126 | #endif |
| 127 | ptr.ZeroTerminate(); |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Responsible for returning the unique UID of this application |
| 132 | * @return unique UID for this application in a TUid |
| 133 | **/ |
| 134 | TUid COpenJazzApp::AppDllUid() const { |
| 135 | return TUid::Uid(0xA000A005); |
| 136 | } |
| 137 | |
| 138 | float sinf(float value) |
| 139 | { |
| 140 | TReal ret; |
| 141 | Math::Sin(ret, value); |
| 142 | return ret; |
| 143 | } |
| 144 | |
| 145 | ///////////////////////////////////////////////////////////////////////////////////////////////// |
| 146 | |
| 147 | void SymbianPlatform::AddGamePaths() { |
| 148 | #ifdef UIQ3 |
| 149 | gamePaths.add(createString("c:\\shared\\openjazz\\"), PATH_TYPE_GAME|PATH_TYPE_CONFIG); |
| 150 | #else |
| 151 | gamePaths.add(createString("c:\\data\\openjazz\\"), PATH_TYPE_GAME|PATH_TYPE_CONFIG); |
| 152 | #endif |
| 153 | gamePaths.add(createString(KOpenJazzPath), PATH_TYPE_SYSTEM|PATH_TYPE_GAME); |
| 154 | } |
| 155 | |
| 156 | #endif |