void playlist_act(u32 act_type) { u32 idx, count; char entry[MAX_PATH]; const char *url; /*reset all*/ if (act_type == 3) { count = gf_cfg_get_key_count(cfg, "Playlist"); while (count) { url = gf_cfg_get_key_name(cfg, "Playlist", 0); gf_cfg_set_key(cfg, "Playlist", url, NULL); count--; } refresh_playlist(); return; } count = SendMessage(hList, LB_GETSELCOUNT, 0, 0); if (!count) return; idx = SendMessage(hList, LB_GETCURSEL, 0, 0); if ((act_type==1) && !idx) return; else if ((act_type==2) && (idx+1==count)) return; url = gf_cfg_get_key_name(cfg, "Playlist", idx); if (!url) return; strcpy(entry, url); /*remove from playlist*/ gf_cfg_set_key(cfg, "Playlist", url, NULL); switch (act_type) { /*remove*/ case 0: if (idx+1==count) idx--; break; /*up*/ case 1: gf_cfg_insert_key(cfg, "Playlist", entry, "", idx-1); idx--; break; /*down*/ case 2: gf_cfg_insert_key(cfg, "Playlist", entry, "", idx+1); idx++; break; } refresh_playlist(); SendMessage(hList, LB_SETCURSEL, idx, 0); SetFocus(hList); }
void switch_playlist(Bool play_prev) { char szPLE[20]; u32 idx = 0; u32 count; const char *ple = gf_cfg_get_key(user.config, "General", "PLEntry"); if (ple) idx = atoi(ple); count = gf_cfg_get_key_count(user.config, "Playlist"); if (!count) return; /*not the first launch*/ if (strlen(the_url)) { if (!idx && play_prev) return; if (play_prev) idx--; else idx++; if (idx>=count) return; } else { if (idx>=count) idx=0; } ple = gf_cfg_get_key_name(user.config, "Playlist", idx); if (!ple) return; sprintf(szPLE, "%d", idx); gf_cfg_set_key(user.config, "General", "PLEntry", szPLE); strcpy(the_url, ple); do_open_file(); }
void refresh_recent_files() { #ifdef _WIN32_WCE u32 count = gf_cfg_get_key_count(user.config, "RecentFiles"); HMENU hMenu = (HMENU)SendMessage(g_hwnd_menu, SHCMBM_GETSUBMENU, 0, ID_MENU_FILE); /*pos is hardcoded*/ hMenu = GetSubMenu(hMenu, 2); while (RemoveMenu(hMenu, 0, MF_BYPOSITION)) {} for (u32 i=0; i<count; i++) { TCHAR txt[100]; char *name; const char *sOpt = gf_cfg_get_key_name(user.config, "RecentFiles", i); name = strrchr(sOpt, '\\'); if (!name) name = strrchr(sOpt, '/'); if (!name) name = (char *) sOpt; else name += 1; CE_CharToWide(name, (u16 *) txt); AppendMenu(hMenu, MF_STRING, IDM_OPEN_FILE1+i, txt); } #endif }
void open_file(HWND hwnd) { Bool res; char ext_list[4096]; strcpy(ext_list, ""); gf_freeze_display(1); u32 count = gf_cfg_get_key_count(user.config, "MimeTypes"); for (u32 i=0; i<count; i++) { char szKeyList[1000], *sKey; const char *sMime = gf_cfg_get_key_name(user.config, "MimeTypes", i); const char *opt = gf_cfg_get_key(user.config, "MimeTypes", sMime); strcpy(szKeyList, opt+1); sKey = strrchr(szKeyList, '\"'); if (!sKey) continue; sKey[0] = 0; strcat(ext_list, szKeyList); strcat(ext_list, " "); } #ifdef _WIN32_WCE res = gf_file_dialog(g_hinst, hwnd, the_url, ext_list, user.config); #else res = 0; #endif gf_freeze_display(0); /*let's go*/ if (res) do_open_file(); }
void OpenDlg::OnOK() { CString URL; char szUrl[5000]; int sel = m_URLs.GetCurSel(); if (sel == CB_ERR) { m_URLs.GetWindowText(URL); } else { m_URLs.GetLBText(sel, URL); } if (!URL.GetLength()) { EndDialog(IDCANCEL); return; } COsmo4 *app = GetApp(); u32 nb_entries; app->m_filename = URL; CE_WideToChar((unsigned short *) (LPCTSTR) URL, szUrl); gf_cfg_set_key(app->m_user.config, "RecentFiles", szUrl, NULL); gf_cfg_insert_key(app->m_user.config, "RecentFiles", szUrl, "", 0); /*remove last entry if needed*/ nb_entries = gf_cfg_get_key_count(app->m_user.config, "RecentFiles"); if (nb_entries>20) { gf_cfg_set_key(app->m_user.config, "RecentFiles", gf_cfg_get_key_name(app->m_user.config, "RecentFiles", nb_entries-1), NULL); } EndDialog(IDOK); }
void load_recent_file(u32 idx) { const char *sOpt = gf_cfg_get_key_name(user.config, "RecentFiles", idx); if (sOpt) { strcpy(the_url, sOpt); do_open_file(); } }
void process_list_change(HWND hWnd, Bool add_to_pl) { TCHAR sTxt[GF_MAX_PATH]; if (!SendMessage(hList, LB_GETSELCOUNT, 0, 0)) return; u32 idx = SendMessage(hList, LB_GETCURSEL, 0, 0); SendMessage(hList, LB_GETTEXT, idx, (LPARAM)(LPCTSTR) sTxt); DWORD param = SendMessage(hList, LB_GETITEMDATA, idx, 0); if (param==1) { if (!wcscmp(sTxt, _T("+ ..") ) ) { if (add_to_pl) return; current_dir[strlen((const char *) current_dir)-1] = 0; char *b = strrchr((const char *) current_dir, '\\'); if (b) b[1] = 0; else b[0] = '\\'; CE_CharToWide((char *) current_dir, (u16 *) w_current_dir); set_directory(w_current_dir); } else { if (add_to_pl) { char dir[MAX_PATH]; TCHAR wdir[MAX_PATH]; wcscpy(wdir, w_current_dir); wcscat(wdir, sTxt+2); wcscat(wdir, _T("\\")); CE_WideToChar((u16 *) wdir, (char *) dir); gf_enum_directory(dir, GF_FALSE, add_files, NULL, NULL); } else { wcscat(w_current_dir, sTxt+2); wcscat(w_current_dir, _T("\\")); CE_WideToChar((u16 *) w_current_dir, (char *) current_dir); set_directory(w_current_dir); } } } else { char szTxt[1024]; CE_WideToChar((u16 *) sTxt, (char *) szTxt); strcpy((char *) out_url, (const char *) current_dir); strcat(out_url, szTxt); if (add_to_pl) { gf_cfg_set_key(cfg, "Playlist", out_url, ""); strcpy(out_url, ""); } else { if (playlist_mode) { const char *file; char szPLE[20]; sprintf(szPLE, "%d", idx); gf_cfg_set_key(cfg, "General", "PLEntry", szPLE); file = gf_cfg_get_key_name(cfg, "Playlist", idx); strcpy(out_url, file); } gf_cfg_set_key(cfg, "General", "LastWorkingDir", (const char *) current_dir); EndDialog(hWnd, 1); } } }
void UpdateLastFiles(GF_Config *cfg, const char *URL) { u32 nb_entries; gf_cfg_set_key(cfg, "RecentFiles", URL, NULL); gf_cfg_insert_key(cfg, "RecentFiles", URL, "", 0); /*remove last entry if needed*/ nb_entries = gf_cfg_get_key_count(cfg, "RecentFiles"); if (nb_entries>MAX_LAST_FILES) { gf_cfg_set_key(cfg, "RecentFiles", gf_cfg_get_key_name(cfg, "RecentFiles", nb_entries-1), NULL); } }
void do_open_file() { gf_cfg_set_key(user.config, "RecentFiles", the_url, NULL); gf_cfg_insert_key(user.config, "RecentFiles", the_url, "", 0); u32 count = gf_cfg_get_key_count(user.config, "RecentFiles"); if (count > 10) gf_cfg_set_key(user.config, "RecentFiles", gf_cfg_get_key_name(user.config, "RecentFiles", count-1), NULL); setup_logs(); gf_term_connect(term, the_url); }
void CPlaylist::ConstructL(const TRect& aRect, GF_User *user) { CreateWindowL(); #ifdef USE_SKIN iListBox = new (ELeave) CAknSingleStyleListBox(); #else iListBox = new (ELeave) CEikTextListBox(); #endif iListBox->ConstructL(this); iListBox->SetContainerWindowL(*this); iListBox->SetListBoxObserver(this); CDesCArray* textArray = new (ELeave) CDesCArrayFlat(16); iListBox->Model()->SetItemTextArray( textArray ); iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); // Creates scrollbar. iListBox->CreateScrollBarFrameL( ETrue ); iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto, CEikScrollBarFrame::EAuto); //iListBox->ActivateL(); iListBox->SetFocus(ETrue); SetRect(aRect); ActivateL(); MakeVisible(EFalse); strcpy(szCurrentDir, ""); #ifndef GPAC_GUI_ONLY m_user = user; strcpy(ext_list, ""); u32 count = gf_cfg_get_key_count(user->config, "MimeTypes"); for (u32 i=0; i<count; i++) { char szKeyList[1000], *sKey; const char *sMime = gf_cfg_get_key_name(user->config, "MimeTypes", i); const char *opt = gf_cfg_get_key(user->config, "MimeTypes", sMime); strcpy(szKeyList, opt+1); sKey = strrchr(szKeyList, '\"'); if (!sKey) continue; sKey[0] = 0; strcat(ext_list, szKeyList); strcat(ext_list, " "); } const char *opt = gf_cfg_get_key(m_user->config, "General", "LastWorkingDir"); if (opt) strcpy(szCurrentDir, opt); #endif }
void AddressBar::ReloadURLs() { WinGPAC *gpac = GetApp(); u32 i=0; while (m_Address.GetCount()) m_Address.DeleteString(0); while (1) { const char *sOpt = gf_cfg_get_key_name(gpac->m_user.config, "RecentFiles", i); if (!sOpt) return; m_Address.AddString(sOpt); i++; } }
void COsmo4AppView::Connect(const char *url) { #ifndef GPAC_GUI_ONLY char the_url[1024]; /*copy before removing from recent files*/ strcpy(the_url, url); gf_cfg_set_key(m_user.config, "RecentFiles", the_url, NULL); gf_cfg_insert_key(m_user.config, "RecentFiles", the_url, "", 0); u32 count = gf_cfg_get_key_count(m_user.config, "RecentFiles"); if (count > 10) gf_cfg_set_key(m_user.config, "RecentFiles", gf_cfg_get_key_name(m_user.config, "RecentFiles", count-1), NULL); if (m_term) gf_term_connect(m_term, the_url); #endif }
BOOL COpenUrl::OnInitDialog() { CDialog::OnInitDialog(); Osmo4 *gpac = GetApp(); u32 i=0; while (m_URLs.GetCount()) m_URLs.DeleteString(0); while (1) { const char *sOpt = gf_cfg_get_key_name(gpac->m_user.config, "RecentFiles", i); if (!sOpt) break; m_URLs.AddString(CString(sOpt)); i++; } return TRUE; }
/*refresh modules - note we don't check for deleted modules but since we've open them the OS should forbid delete*/ GF_EXPORT u32 gf_modules_refresh(GF_ModuleManager *pm) { if (!pm) return 0; //!! symbian 9.1 doesn't allow for DLL browsing in /sys/bin, and can only load DLLs in /sys/bin !! #if 0 gf_enum_directory((char*)pm->dir, 0, enum_modules, pm, ".dll"); #else u32 i, mod_count; mod_count = gf_cfg_get_key_count(pm->cfg, "SymbianDLLs"); for (i=0; i<mod_count; i++) { const char *mod = gf_cfg_get_key_name(pm->cfg, "SymbianDLLs", i); if (stricmp(gf_cfg_get_key(pm->cfg, "SymbianDLLs", mod), "yes")) continue; enum_modules(pm, (char*)mod, NULL); } #endif return gf_list_count(pm->plug_list); }
BOOL OpenDlg::OnInitDialog() { TCHAR w_str[5000]; CDialog::OnInitDialog(); COsmo4 *app = GetApp(); const char *sOpt; u32 i=0; while (m_URLs.GetCount()) m_URLs.DeleteString(0); while (1) { sOpt = gf_cfg_get_key_name(app->m_user.config, "RecentFiles", i); if (!sOpt) break; CE_CharToWide((char *) sOpt, (u16 *)w_str); m_URLs.AddString(w_str); i++; } SetFocus(); return TRUE; }
void CPlaylist::RefreshPlaylist() { if (playlist_mode) { u32 count = gf_cfg_get_key_count(m_user->config, "Playlist"); ResetView(); for (u32 i=0; i<count; i++) { const char *opt = gf_cfg_get_key_name(m_user->config, "Playlist", i); const char *sep = strrchr(opt, '\\'); if (!sep) sep = strrchr(opt, '/'); AddItem(sep ? (sep+1) : opt, 0); } if (!count) AddItem("[empty]", 0); FlushItemList(); ((COsmo4AppUi *) CEikonEnv::Static()->AppUi())->SetTitle("Playlist", 0); } else { ScanDirectory(szCurrentDir); } }
void CPlaylist::HandleSelection() { char szName[100]; GetSelectionName(szName); /*sub-directory*/ if ((szName[0] == '+') && (szName[1] == ' ')) { /*browse up*/ if ((szName[2] == '.') && (szName[3] == '.')) { char *prev = strrchr(szCurrentDir, '\\'); if (prev) { prev[0] = 0; ScanDirectory(szCurrentDir); } else { ScanDirectory(NULL); } } else { strcat(szCurrentDir, "\\"); strcat(szCurrentDir, szName+2); ScanDirectory(szCurrentDir); } } else if (szName[1] == ':') { ScanDirectory(szName); } else { char szURL[1024]; COsmo4AppUi *app = (COsmo4AppUi *) CEikonEnv::Static()->AppUi(); if (playlist_mode) { TInt idx = iListBox->CurrentItemIndex(); #ifndef GPAC_GUI_ONLY const char *url = gf_cfg_get_key_name(m_user->config, "Playlist", idx); if (url) app->PlayURL(url); #endif } else { gf_cfg_set_key(m_user->config, "General", "LastWorkingDir", (const char *) szCurrentDir); sprintf(szURL, "%s\\%s", szCurrentDir, szName); app->PlayURL(szURL); } } }
void refresh_playlist() { TCHAR w_name[GF_MAX_PATH]; u32 count, i; SetWindowText(hDirTxt, _T("Playlist")); SendMessage(hList, LB_RESETCONTENT, 0, 0); count = gf_cfg_get_key_count(cfg, "Playlist"); for (i=0; i<count; i++) { const char *file = gf_cfg_get_key_name(cfg, "Playlist", i); char *name = strrchr(file, '\\'); if (!name) name = strrchr(file, '/'); CE_CharToWide(name ? name+1 : (char *) file, (u16 *) w_name); SendMessage(hList, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR) w_name); } i = 0; const char *ple = gf_cfg_get_key(cfg, "General", "PLEntry"); i = ple ? atoi(ple) : 0; if (i>=count) i=0; SendMessage(hList, LB_SETCURSEL, i, 0); SetFocus(hList); }
void COsmo4AppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) { CEikMenuPaneItem::SData item; if (aResourceId==R_OSMO4_MENU) { aMenuPane->Reset(); if (view_mode==1) { #ifndef GPAC_GUI_ONLY Bool is_file = iPlaylist->SelectionIsFile(); Bool in_pl = (is_file && iPlaylist->IsInPlaylist()) ? 1 : 0; if (iPlaylist->PlaylistMode()) { DECLARE_MENU_ITEM(_L("Up"), EOsmo4PlayListMoveUp, 0, 0, 0); DECLARE_MENU_ITEM(_L("Down"), EOsmo4PlayListMoveDown, 0, 0, 0); DECLARE_MENU_ITEM(_L("Remove"), EOsmo4PlayListRem, 0, 0, 0); DECLARE_MENU_ITEM(_L("Clear"), EOsmo4PlayListClear, 0, 0, 1); } else if (!in_pl) { DECLARE_MENU_ITEM(_L("Add to PlayList"), EOsmo4PlayListAdd, 0, 0, 1); } else if (is_file) { DECLARE_MENU_ITEM(_L("Remove from Playlist"), EOsmo4PlayListRem, 0, 0, 1); } if (! iPlaylist->PlaylistMode()) { DECLARE_MENU_ITEM(iPlaylist->ViewAllFiles() ? _L("View known files") : _L("View all files"), EOsmo4PlayListAllFiles, 0, 0, 1); } else { DECLARE_MENU_ITEM(_L("Sort"), 0, 0, R_OSMO4_SM1, 1); } DECLARE_MENU_ITEM(iPlaylist->PlaylistMode() ? _L("Browse") : _L("Playlist"), EOsmo4PlayListMode, 0, 0, 0); #endif } else { /*open*/ DECLARE_MENU_ITEM(_L("File"), 0, 0, R_OSMO4_SM1, 0); DECLARE_MENU_ITEM(_L("View"), 0, 0, R_OSMO4_SM2, 0); DECLARE_MENU_ITEM(_L("Options"), 0, 0, R_OSMO4_SM3, 0); //DECLARE_MENU_ITEM(_L("Exit"), EEikCmdExit, 0, 0, 0); } smenu_id = 0; return; } else if (aResourceId==R_OSMO4_SM1) { aMenuPane->Reset(); /*sort menu*/ if (view_mode==1) { } /*file menu*/ else { DECLARE_MENU_ITEM(_L("Open local"), EOsmo4PlayListView, 0, 0, 0); DECLARE_MENU_ITEM(_L("Open URL"), EOsmo4OpenURL, 0, 0, 1); #ifndef GPAC_GUI_ONLY if (gf_cfg_get_key_name(iAppView->m_user.config, "RecentFiles", 0) != NULL) { DECLARE_MENU_ITEM(_L("Recent"), 0, 0, R_OSMO4_SSM1, 0); } #endif } smenu_id = 1; return; } /*not used*/ if (view_mode==1) return; /*View menu*/ if (aResourceId==R_OSMO4_SM2) { aMenuPane->Reset(); #ifndef GPAC_GUI_ONLY /*content view menu*/ if (gf_term_get_option(iAppView->m_term, GF_OPT_NAVIGATION_TYPE) != GF_NAVIGATE_TYPE_NONE) { DECLARE_MENU_ITEM(_L("Navigate"), 0, 0, R_OSMO4_SSM1, 1); } #endif DECLARE_MENU_ITEM(_L("Fullscreen"), EOsmo4Fullscreen, 0, 0, 0); /*don't allow content AR modification by user*/ //DECLARE_MENU_ITEM(_L("Aspect Ratio"), 0, 0, R_OSMO4_SSM2, 1); DECLARE_MENU_ITEM(_L("Maximize size"), EOsmo4ViewMaxSize, (StatusPane()->IsVisible() ? 0 : 1), 0, 1); DECLARE_MENU_ITEM(_L("CPU Usage"), EOsmo4ViewRTI, iAppView->show_rti, 0, 0); smenu_id = 2; return; } /*Option menu*/ if (aResourceId==R_OSMO4_SM3) { #ifndef GPAC_GUI_ONLY const char *opt = gf_cfg_get_key(iAppView->m_user.config, "Compositor", "ForceOpenGL"); DECLARE_MENU_ITEM(_L("Use 2D OpenGL"), EOsmo4OptOpenGL, (opt && !strcmp(opt, "yes")) ? 1 : 0, 0, 0); opt = gf_cfg_get_key(iAppView->m_user.config, "Compositor", "DirectDraw"); DECLARE_MENU_ITEM(_L("Direct Draw"), EOsmo4OptDirectDraw, (opt && !strcmp(opt, "yes")) ? 1 : 0, 0, 0); opt = gf_cfg_get_key(iAppView->m_user.config, "SAXLoader", "Progressive"); DECLARE_MENU_ITEM(_L("Progressive XML"), EOsmo4OptXMLProgressive, (opt && !strcmp(opt, "yes")) ? 1 : 0, 0, 0); #endif DECLARE_MENU_ITEM(_L("Enable Logs"), EOsmo4OptEnableLogs, iAppView->do_log, 0, 0); return; } if (aResourceId==R_OSMO4_SSM1) { aMenuPane->Reset(); if (smenu_id == 1) { u32 i = 0; #ifndef GPAC_GUI_ONLY while (1) { const char *opt = gf_cfg_get_key_name(iAppView->m_user.config, "RecentFiles", i); if (!opt) break; const char *sep = strrchr(opt, '\\'); if (!sep) sep = strrchr(opt, '/'); if (!sep) sep = opt; else sep += 1; item.iText.Copy( TPtrC8(( TText8* ) sep) ); item.iCommandId = EOsmo4OpenRecentFirst + i; item.iFlags = 0; item.iCascadeId = 0; aMenuPane->AddMenuItemL(item); i++; if (i>=10) break; } if (!i) { DECLARE_MENU_ITEM(_L("_"), 0, 0, 0, 0); } #endif } else if (smenu_id == 2) { DECLARE_MENU_ITEM(_L("Reset"), EOsmo4NavReset, 0, 0, 1); DECLARE_MENU_ITEM(_L("None"), EOsmo4NavNone, 0, 0, 0); DECLARE_MENU_ITEM(_L("Slide"), EOsmo4NavSlide, 0, 0, 0); #ifndef GPAC_GUI_ONLY if (gf_term_get_option(iAppView->m_term, GF_OPT_NAVIGATION_TYPE) == GF_NAVIGATE_TYPE_3D) { DECLARE_MENU_ITEM(_L("Walk"), EOsmo4NavWalk, 0, 0, 0); DECLARE_MENU_ITEM(_L("Fly"), EOsmo4NavFly, 0, 0, 0); DECLARE_MENU_ITEM(_L("Examine"), EOsmo4NavExamine, 0, 0, 1); DECLARE_MENU_ITEM(_L("Headlight"), EOsmo4NavHeadlight, 0, 0, 0); DECLARE_MENU_ITEM(_L("Gravity"), EOsmo4NavGravity, 0, 0, 0); } #endif } return; } if (aResourceId==R_OSMO4_SSM2) { aMenuPane->Reset(); DECLARE_MENU_ITEM(_L("Keep Original"), EOsmo4AROriginal, 0, 0, 0); DECLARE_MENU_ITEM(_L("Fill Screen"), EOsmo4ARFillScreen, 0, 0, 0); DECLARE_MENU_ITEM(_L("Ratio 4-3"), EOsmo4AR4_3, 0, 0, 0); DECLARE_MENU_ITEM(_L("Ratio 16-9"), EOsmo4AR16_9, 0, 0, 0); return; } }
void CPlaylist::PlaylistAct(Osmo4_PLActions act) { char szURL[1024]; char szName[100]; CDesCArray*array; TInt idx; TInt count; if (act==Osmo4PLClear) { while (1) { #ifndef GPAC_GUI_ONLY const char *opt = gf_cfg_get_key_name(m_user->config, "Playlist", 0); if (!opt) break; gf_cfg_set_key(m_user->config, "Playlist", opt, NULL); #endif } RefreshPlaylist(); return; } else if (act == Osmo4PLToggleMode) { playlist_mode = !playlist_mode; RefreshPlaylist(); return; } else if (act == Osmo4PLToggleAllFiles) { view_all_files = !view_all_files; RefreshPlaylist(); return; } else if (act == Osmo4PLAdd) { #ifndef GPAC_GUI_ONLY GetSelectionName(szName); if ((szName[0] == '+') && (szName[1] == ' ')) { if ((szName[2] != '.') && (szName[3] != '.')) { sprintf(szURL, "%s\\%s", szCurrentDir, szName+2); gf_enum_directory(szURL, 0, dir_add_files, this, view_all_files ? NULL : ext_list); } } else if (szName[1] == ':') { gf_enum_directory(szName, 0, dir_add_files, this, view_all_files ? NULL : ext_list); } else { sprintf(szURL, "%s\\%s", szCurrentDir, szName); gf_cfg_set_key(m_user->config, "Playlist", szURL, ""); } #endif return; } GetSelectionName(szName); if ((szName[0] == '+') && (szName[1] == ' ')) return; else if (szName[1] == ':') return; switch (act) { /*remove from playlist*/ case Osmo4PLRem: #ifndef GPAC_GUI_ONLY sprintf(szURL, "%s\\%s", szCurrentDir, szName); gf_cfg_set_key(m_user->config, "Playlist", szURL, NULL); #endif RefreshPlaylist(); break; /*move up*/ case Osmo4PLMoveUp: array = static_cast<CDesCArray*>(iListBox->Model()->ItemTextArray()); count = array->Count(); idx = iListBox->CurrentItemIndex(); sprintf(szURL, "%s\\%s", szCurrentDir, szName); #ifndef GPAC_GUI_ONLY gf_cfg_set_key(m_user->config, "Playlist", szURL, NULL); gf_cfg_insert_key(m_user->config, "Playlist", szURL, "", idx-1); #endif RefreshPlaylist(); if (idx>1) iListBox->SetCurrentItemIndexAndDraw(idx-1); break; /*move down*/ case Osmo4PLMoveDown: array = static_cast<CDesCArray*>(iListBox->Model()->ItemTextArray()); count = array->Count(); idx = iListBox->CurrentItemIndex(); sprintf(szURL, "%s\\%s", szCurrentDir, szName); #ifndef GPAC_GUI_ONLY gf_cfg_set_key(m_user->config, "Playlist", szURL, NULL); gf_cfg_insert_key(m_user->config, "Playlist", szURL, "", idx+1); #endif RefreshPlaylist(); if (idx<count-1) iListBox->SetCurrentItemIndexAndDraw(idx+1); break; default: break; } }
static void ft_rescan_fonts(GF_FontReader *dr) { char *font_dir, *font_default; u32 i, count; GF_Config *cfg = gf_modules_get_config((GF_BaseInterface *)dr); FTBuilder *ftpriv = (FTBuilder *)dr->udta; GF_LOG(GF_LOG_INFO, GF_LOG_PARSER, ("[FreeType] Rescaning font directory %s\n", ftpriv->font_dir)); count = gf_cfg_get_key_count(cfg, "FontEngine"); for (i=0; i<count; i++) { const char *key = gf_cfg_get_key_name(cfg, "FontEngine", i); if (!strcmp(key, "FontReader")) continue; if (!strcmp(key, "FontDirectory")) continue; if (!strcmp(key, "RescanFonts")) continue; /*any other persistent options should go here*/ gf_cfg_set_key(cfg, "FontEngine", key, NULL); count--; i--; } gf_modules_set_option((GF_BaseInterface *)dr, "FontEngine", "RescanFonts", "no"); ftpriv->font_serif = NULL; ftpriv->font_sans = NULL; ftpriv->font_fixed = NULL; font_dir = ftpriv->font_dir; ftpriv->font_dir = NULL; gf_enum_directory(font_dir, 0, ft_enum_fonts, dr, "ttf;ttc"); gf_enum_directory(font_dir, 1, ft_enum_fonts_dir, dr, NULL); font_default = ftpriv->font_dir; ftpriv->font_dir = font_dir; if (ftpriv->font_fixed) gf_free(ftpriv->font_fixed); ftpriv->font_fixed = NULL; if (ftpriv->font_sans) gf_free(ftpriv->font_sans); ftpriv->font_sans = NULL; if (ftpriv->font_serif) gf_free(ftpriv->font_serif); ftpriv->font_serif = NULL; /* let's check we have fonts that match our default Bol/Italic/BoldItalic conventions*/ count = gf_cfg_get_key_count(cfg, "FontEngine"); for (i=0; i<count; i++) { const char *opt; char fkey[GF_MAX_PATH]; const char *key = gf_cfg_get_key_name(cfg, "FontEngine", i); opt = gf_cfg_get_key(cfg, "FontEngine", key); if (!strchr(opt, '/') && !strchr(opt, '\\')) continue; if (!strcmp(key, "FontDirectory")) continue; if (strstr(key, "Bold")) continue; if (strstr(key, "Italic")) continue; strcpy(fkey, key); strcat(fkey, " Italic"); opt = gf_cfg_get_key(cfg, "FontEngine", fkey); if (!opt) continue; strcpy(fkey, key); strcat(fkey, " Bold"); opt = gf_cfg_get_key(cfg, "FontEngine", fkey); if (!opt) continue; strcpy(fkey, key); strcat(fkey, " Bold Italic"); opt = gf_cfg_get_key(cfg, "FontEngine", fkey); if (!opt) continue; strcpy(fkey, key); strlwr(fkey); /*this font is suited for our case*/ if (isBestFontFor(BEST_FIXED_FONTS, ftpriv->font_fixed, key) || (!ftpriv->font_fixed && (strstr(fkey, "fixed") || strstr(fkey, "mono")) ) ) { if (ftpriv->font_fixed) gf_free(ftpriv->font_fixed); ftpriv->font_fixed = gf_strdup(key); } if (isBestFontFor(BEST_SANS_FONTS, ftpriv->font_sans, key) || (!ftpriv->font_sans && strstr(fkey, "sans")) ) { if (ftpriv->font_sans) gf_free(ftpriv->font_sans); ftpriv->font_sans = gf_strdup(key); } if (isBestFontFor(BEST_SERIF_FONTS, ftpriv->font_serif, key) || (!ftpriv->font_serif && strstr(fkey, "serif")) ) { if (ftpriv->font_serif) gf_free(ftpriv->font_serif); ftpriv->font_serif = gf_strdup(key); } } if (!ftpriv->font_serif) ftpriv->font_serif = gf_strdup(font_default ? font_default : ""); if (!ftpriv->font_sans) ftpriv->font_sans = gf_strdup(font_default ? font_default : ""); if (!ftpriv->font_fixed) ftpriv->font_fixed = gf_strdup(font_default ? font_default : ""); if (font_default) gf_free(font_default); gf_modules_set_option((GF_BaseInterface *)dr, "FontEngine", "FontFixed", ftpriv->font_fixed); gf_modules_set_option((GF_BaseInterface *)dr, "FontEngine", "FontSerif", ftpriv->font_serif); gf_modules_set_option((GF_BaseInterface *)dr, "FontEngine", "FontSans", ftpriv->font_sans); GF_LOG(GF_LOG_INFO, GF_LOG_PARSER, ("[FreeType] Font directory scanned\n", ftpriv->font_dir)); }
static GF_InputService *gf_term_can_handle_service(GF_Terminal *term, const char *url, const char *parent_url, Bool no_mime_check, char **out_url, GF_Err *ret_code, GF_DownloadSession **the_session) { u32 i; GF_Err e; char *sURL, *qm, *frag, *ext, *mime_type, *url_res; char szExt[50]; const char *force_module = NULL; GF_InputService *ifce; Bool skip_mime = 0; memset(szExt, 0, sizeof(szExt)); (*ret_code) = GF_OK; ifce = NULL; mime_type = NULL; GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] Looking for plugin for URL %s\n", url)); *out_url = NULL; sURL = NULL; if (!url || !strncmp(url, "\\\\", 2) ) { (*ret_code) = GF_URL_ERROR; goto exit; } if (!strnicmp(url, "libplayer://", 12)) { force_module = "LibPlayer"; } /*used by GUIs scripts to skip URL concatenation*/ if (!strncmp(url, "gpac://", 7)) sURL = gf_strdup(url+7); /*opera-style localhost URLs*/ else if (!strncmp(url, "file://localhost", 16)) sURL = gf_strdup(url+16); else if (parent_url) sURL = gf_url_concatenate(parent_url, url); /*path absolute*/ if (!sURL) sURL = gf_strdup(url); if (gf_url_is_local(sURL)) gf_url_to_fs_path(sURL); if (the_session) *the_session = NULL; if (no_mime_check) { mime_type = NULL; } else { /*fetch a mime type if any. If error don't even attempt to open the service TRYTOFIXME: it would be nice to reuse the downloader created while fetching the mime type, however we don't know if the plugin will want it threaded or not.... */ mime_type = get_mime_type(term, sURL, &e, the_session); if (e) { (*ret_code) = e; goto exit; } } if (mime_type && (!stricmp(mime_type, "text/plain") || !stricmp(mime_type, "video/quicktime") || !stricmp(mime_type, "application/octet-stream") ) ) { skip_mime = 1; } ifce = NULL; /*load from mime type*/ if (mime_type && !skip_mime) { const char *sPlug = gf_cfg_get_key(term->user->config, "MimeTypes", mime_type); GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] Mime type found: %s\n", mime_type)); if (!sPlug) { gf_free(mime_type); mime_type=NULL; } if (sPlug) sPlug = strrchr(sPlug, '"'); if (sPlug) { sPlug += 2; GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("%s:%d FOUND matching module %s\n", __FILE__, __LINE__, sPlug)); ifce = (GF_InputService *) gf_modules_load_interface_by_name(term->user->modules, sPlug, GF_NET_CLIENT_INTERFACE); if (force_module && ifce && !strstr(ifce->module_name, force_module)) { gf_modules_close_interface((GF_BaseInterface *) ifce); ifce = NULL; } if (ifce && !net_check_interface(ifce) ) { gf_modules_close_interface((GF_BaseInterface *) ifce); ifce = NULL; } } } /* The file extension, if any, is before '?' if any or before '#' if any.*/ url_res = strrchr(sURL, '/'); if (!url_res) url_res = strrchr(sURL, '\\'); if (!url_res) url_res = sURL; qm = strchr(url_res, '?'); if (qm) { qm[0] = 0; ext = strrchr(url_res, '.'); qm[0] = '?'; } else { frag = strchr(url_res, '#'); if (frag) { frag[0] = 0; ext = strrchr(url_res, '.'); frag[0] = '#'; } else { ext = strrchr(url_res, '.'); } } if (ext && !stricmp(ext, ".gz")) { char *anext; ext[0] = 0; anext = strrchr(sURL, '.'); ext[0] = '.'; ext = anext; } /*no mime type: either local or streaming. If streaming discard extension checking*/ if (!ifce && !mime_type && strstr(sURL, "://") && strnicmp(sURL, "file://", 7)) ext = NULL; /*browse extensions for prefered module*/ if (!ifce && ext) { u32 keyCount; strncpy(szExt, &ext[1], 49); ext = strrchr(szExt, '?'); if (ext) ext[0] = 0; ext = strrchr(szExt, '#'); if (ext) ext[0] = 0; GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] No mime type found - checking by extension %s\n", szExt)); assert( term && term->user && term->user->modules); keyCount = gf_cfg_get_key_count(term->user->config, "MimeTypes"); for (i=0; i<keyCount; i++) { char *sPlug; const char *sKey; const char *sMime; sMime = gf_cfg_get_key_name(term->user->config, "MimeTypes", i); if (!sMime) continue; sKey = gf_cfg_get_key(term->user->config, "MimeTypes", sMime); if (!sKey) continue; if (!check_extension(sKey, szExt)) continue; sPlug = strrchr(sKey, '"'); if (!sPlug) continue; /*bad format entry*/ sPlug += 2; GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] Trying module[%i]=%s, mime=%s\n", i, sPlug, sMime)); ifce = (GF_InputService *) gf_modules_load_interface_by_name(term->user->modules, sPlug, GF_NET_CLIENT_INTERFACE); if (!ifce){ GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] module[%i]=%s, mime=%s, cannot be loaded for GF_NET_CLIENT_INTERFACE.\n", i, sPlug, sMime)); continue; } if (force_module && ifce && !strstr(ifce->module_name, force_module)) { gf_modules_close_interface((GF_BaseInterface *) ifce); ifce = NULL; continue; } if (ifce && !net_check_interface(ifce)) { gf_modules_close_interface((GF_BaseInterface *) ifce); ifce = NULL; continue; } break; } } /*browse all modules*/ if (!ifce) { GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] Not found any interface, trying browsing all modules...\n")); for (i=0; i< gf_modules_get_count(term->user->modules); i++) { ifce = (GF_InputService *) gf_modules_load_interface(term->user->modules, i, GF_NET_CLIENT_INTERFACE); if (!ifce) continue; GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] Checking if module %s supports URL %s\n", ifce->module_name, sURL)); if (force_module && ifce && !strstr(ifce->module_name, force_module)) { } else if (net_check_interface(ifce) && ifce->CanHandleURL(ifce, sURL)) { break; } gf_modules_close_interface((GF_BaseInterface *) ifce); ifce = NULL; } } exit: if (!ifce){ GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[Terminal] Did not find any input plugin for URL %s (%s)\n", sURL ? sURL : url, mime_type ? mime_type : "no mime type")); if (sURL) gf_free(sURL); if ( (*ret_code) == GF_OK) (*ret_code) = GF_NOT_SUPPORTED; *out_url = NULL; if (the_session && *the_session) { gf_dm_sess_del(*the_session); } } else { *out_url = sURL; GF_LOG(GF_LOG_INFO, GF_LOG_MEDIA, ("[Terminal] Found input plugin %s for URL %s (%s)\n", ifce->module_name, sURL, mime_type ? mime_type : "no mime type")); } if (mime_type) gf_free(mime_type); mime_type = NULL; return ifce; }
// ----------------------------------------------------------------------------- // COsmo4AppUi::HandleCommandL() // Takes care of command handling. // ----------------------------------------------------------------------------- // void COsmo4AppUi::HandleCommandL( TInt aCommand ) { GF_Err e; #ifndef GPAC_GUI_ONLY switch( aCommand ) { case EAknSoftkeyBack: if (view_mode==1) TogglePlaylist(); break; case EEikCmdExit: case EAknSoftkeyExit: iAppView->Shutdown(); Exit(); break; /*PLAYLIST commands*/ case EOsmo4PlayListAdd: iPlaylist->PlaylistAct(Osmo4PLAdd); break; case EOsmo4PlayListRem: iPlaylist->PlaylistAct(Osmo4PLRem); break; case EOsmo4PlayListMoveUp: iPlaylist->PlaylistAct(Osmo4PLMoveUp); break; case EOsmo4PlayListMoveDown: iPlaylist->PlaylistAct(Osmo4PLMoveDown); break; case EOsmo4PlayListClear: iPlaylist->PlaylistAct(Osmo4PLClear); break; case EOsmo4PlayListMode: iPlaylist->PlaylistAct(Osmo4PLToggleMode); break; case EOsmo4PlayListAllFiles: iPlaylist->PlaylistAct(Osmo4PLToggleAllFiles); break; /*FILE menu command*/ case EOsmo4PlayListView: TogglePlaylist(); break; case EOsmo4OpenURL: break; case EOsmo4Fullscreen: break; case EOsmo4ViewMaxSize: { CEikStatusPane* statusPane = StatusPane(); if (statusPane->IsVisible()) statusPane->MakeVisible(EFalse); else statusPane->MakeVisible(ETrue); } break; case EOsmo4AROriginal: gf_term_set_option(iAppView->m_term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_KEEP); break; case EOsmo4ARFillScreen: gf_term_set_option(iAppView->m_term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN); break; case EOsmo4AR4_3: gf_term_set_option(iAppView->m_term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_4_3); break; case EOsmo4AR16_9: gf_term_set_option(iAppView->m_term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_16_9); break; case EOsmo4NavReset: gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION_TYPE, 0); break; case EOsmo4NavNone: gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION, GF_NAVIGATE_NONE); break; case EOsmo4NavSlide: e = gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION, GF_NAVIGATE_SLIDE); if (e) { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("Cannot set navigation: %s", gf_error_to_string(e) )); } break; case EOsmo4NavWalk: gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION, GF_NAVIGATE_WALK); break; case EOsmo4NavFly: gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION, GF_NAVIGATE_FLY); break; case EOsmo4NavExamine: gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION, GF_NAVIGATE_EXAMINE); break; case EOsmo4NavHeadlight: gf_term_set_option(iAppView->m_term, GF_OPT_HEADLIGHT, !gf_term_get_option(iAppView->m_term, GF_OPT_HEADLIGHT) ); break; case EOsmo4CollideNone: gf_term_set_option(iAppView->m_term, GF_OPT_COLLISION, GF_COLLISION_NONE); break; case EOsmo4CollideSimple: gf_term_set_option(iAppView->m_term, GF_OPT_COLLISION, GF_COLLISION_NORMAL); break; case EOsmo4CollideDisp: gf_term_set_option(iAppView->m_term, GF_OPT_COLLISION, GF_COLLISION_DISPLACEMENT); break; case EOsmo4NavGravity: gf_term_set_option(iAppView->m_term, GF_OPT_GRAVITY, !gf_term_get_option(iAppView->m_term, GF_OPT_GRAVITY)); break; case EOsmo4ViewRTI: iAppView->show_rti = !iAppView->show_rti; break; case EOsmo4OptEnableLogs: { const char *opt = gf_cfg_get_key(iAppView->m_user.config, "General", "Logs"); if (opt && !stricmp(opt, "@debug")) { gf_cfg_set_key(iAppView->m_user.config, "General", "Logs", "all@error"); } else { gf_cfg_set_key(iAppView->m_user.config, "General", "Logs", "all@debug"); } iAppView->SetupLogs(); } break; case EOsmo4OptOpenGL: { const char *opt = gf_cfg_get_key(iAppView->m_user.config, "Compositor", "ForceOpenGL"); Bool use_gl = (opt && !strcmp(opt, "yes")) ? 1 : 0; gf_cfg_set_key(iAppView->m_user.config, "Compositor", "ForceOpenGL", use_gl ? "no" : "yes"); gf_term_set_option(iAppView->m_term, GF_OPT_USE_OPENGL, !use_gl); } break; case EOsmo4OptDirectDraw: { const char *opt = gf_cfg_get_key(iAppView->m_user.config, "Compositor", "DirectDraw"); Bool use_dd = (opt && !strcmp(opt, "yes")) ? 1 : 0; gf_cfg_set_key(iAppView->m_user.config, "Compositor", "DirectDraw", use_dd ? "no" : "yes"); gf_term_set_option(iAppView->m_term, GF_OPT_DIRECT_DRAW, !use_dd); } break; case EOsmo4OptXMLProgressive: { const char *opt = gf_cfg_get_key(iAppView->m_user.config, "SAXLoader", "Progressive"); Bool use_prog = (opt && !strcmp(opt, "yes")) ? 1 : 0; gf_cfg_set_key(iAppView->m_user.config, "SAXLoader", "Progressive", use_prog ? "no" : "yes"); gf_cfg_set_key(iAppView->m_user.config, "SAXLoader", "MaxDuration", "100"); } break; default: if ((aCommand>=EOsmo4OpenRecentFirst) && (aCommand<=EOsmo4OpenRecentLast)) { const char *sOpt = gf_cfg_get_key_name(iAppView->m_user.config, "RecentFiles", aCommand - EOsmo4OpenRecentFirst); if (sOpt) iAppView->Connect(sOpt); } else { iAppView->MessageBox("Unandled command - panic", "Osmo4"); Panic( EOsmo4Ui ); } break; } #endif }