1
/* $Id: os_info_symbian.cpp 3437 2011-03-08 06:30:34Z nanang $ */
3
* Copyright (C) 2011 Teluu Inc. (http://www.teluu.com)
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
#if !defined(PJ_SYMBIAN) || PJ_SYMBIAN == 0
20
# error This file is only for Symbian platform
24
#include <pj/string.h>
26
#include <f32file.h> /* link against efsrv.lib */
27
#include <hal.h> /* link against hal.lib */
28
#include <utf.h> /* link against charconv.lib */
32
unsigned pj_symbianos_get_model_info(char *buf, unsigned buf_size);
33
unsigned pj_symbianos_get_platform_info(char *buf, unsigned buf_size);
34
void pj_symbianos_get_sdk_info(pj_str_t *name, pj_uint32_t *ver);
38
/* Get Symbian phone model info, returning length of model info */
39
unsigned pj_symbianos_get_model_info(char *buf, unsigned buf_size)
45
HAL::Get(HAL::EMachineUid, hal_val);
46
pj_ansi_snprintf(buf, buf_size, "0x%08X", hal_val);
47
pj_strset2(&model_name, buf);
50
const pj_str_t st_copyright = {"(C)", 3};
51
const pj_str_t st_nokia = {"Nokia", 5};
55
_LIT(KModelFilename,"Z:\\resource\\versions\\model.txt");
61
err = file.Open(fs, KModelFilename, EFileRead);
62
if (err == KErrNone) {
65
TBuf16<64> ModelName16;
66
err = text.Read(ModelName16);
67
if (err == KErrNone) {
68
TPtr8 ptr8((TUint8*)tmp_buf, sizeof(tmp_buf));
69
ptr8.Copy(ModelName16);
70
pj_strset(&tmp_str, tmp_buf, ptr8.Length());
79
/* The retrieved model name is usually in long format, e.g:
80
* "� Nokia N95 (01.01)", "(C) Nokia E52". As we need only
81
* the short version, let's clean it up.
84
/* Remove preceding non-ASCII chars, e.g: "�" */
85
char *p = tmp_str.ptr;
86
while (!pj_isascii(*p)) { p++; }
87
pj_strset(&tmp_str, p, tmp_str.slen - (p - tmp_str.ptr));
90
p = pj_stristr(&tmp_str, &st_copyright);
92
p += st_copyright.slen;
93
pj_strset(&tmp_str, p, tmp_str.slen - (p - tmp_str.ptr));
97
p = pj_stristr(&tmp_str, &st_nokia);
100
pj_strset(&tmp_str, p, tmp_str.slen - (p - tmp_str.ptr));
103
/* Remove language version, e.g: "(01.01)" */
104
p = pj_strchr(&tmp_str, '(');
106
tmp_str.slen = p - tmp_str.ptr;
109
pj_strtrim(&tmp_str);
111
if (tmp_str.slen == 0)
114
if ((unsigned)tmp_str.slen > buf_size - model_name.slen - 3)
115
tmp_str.slen = buf_size - model_name.slen - 3;
117
pj_strcat2(&model_name, "(");
118
pj_strcat(&model_name, &tmp_str);
119
pj_strcat2(&model_name, ")");
122
buf[model_name.slen] = '\0';
125
return model_name.slen;
129
/* Get platform info, returned format will be "Series60vX.X" */
130
unsigned pj_symbianos_get_platform_info(char *buf, unsigned buf_size)
133
_LIT(KS60ProductIDFile, "Series60v*.sis");
134
_LIT(KROMInstallDir, "z:\\system\\install\\");
139
pj_str_t plat_info = {NULL, 0};
143
err = ff.FindWildByDir(KS60ProductIDFile, KROMInstallDir, result);
144
if (err == KErrNone) {
145
err = result->Sort(ESortByName|EDescending);
146
if (err == KErrNone) {
147
TPtr8 tmp_ptr8((TUint8*)buf, buf_size);
148
const pj_str_t tmp_ext = {".sis", 4};
151
tmp_ptr8.Copy((*result)[0].iName);
152
pj_strset(&plat_info, buf, (pj_size_t)tmp_ptr8.Length());
153
p = pj_stristr(&plat_info, &tmp_ext);
155
plat_info.slen -= (p - plat_info.ptr);
160
buf[plat_info.slen] = '\0';
162
return plat_info.slen;
167
void pj_symbianos_get_sdk_info(pj_str_t *name, pj_uint32_t *ver)
169
const pj_str_t S60 = {"S60", 3};
170
#if defined(__SERIES60_30__)
173
#elif defined(__SERIES60_31__)
175
*ver = (3 << 24) | (1 << 16);
176
#elif defined(__S60_32__)
178
*ver = (3 << 24) | (2 << 16);
179
#elif defined(__S60_50__)
182
#elif defined(__NOKIA_N97__)
183
*name = pj_str("N97");
186
*name = pj_str("Unknown");