1 /*****************************************************************************
2 * messages.cpp : WinCE gui plugin for VLC
3 *****************************************************************************
4 * Copyright (C) 2000-2004 the VideoLAN team
7 * Authors: Marodon Cedric <cedric_marodon@yahoo.fr>
8 * Gildas Bazin <gbazin@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
32 #include <vlc_common.h>
33 #include <vlc_interface.h>
44 #define NMAXFILE 512 // at least 256
48 #define TEXTMAXBUF 512 // at least 500
51 /*****************************************************************************
53 *****************************************************************************/
55 Messages::Messages( intf_thread_t *p_intf, CBaseWindow *p_parent,
57 : CBaseWindow( p_intf, p_parent, h_inst )
62 hWnd = CreateWindow( _T("VLC WinCE"), _T("Messages"),
63 WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX,
64 0, 0, /*CW_USEDEFAULT*/300, /*CW_USEDEFAULT*/300,
65 p_parent->GetHandle(), NULL, h_inst, (void *)this );
68 /***********************************************************************
73 Processes messages sent to the main window.
74 ***********************************************************************/
75 LRESULT Messages::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
79 TCHAR psz_text[TEXTMAXBUF];
87 shidi.dwMask = SHIDIM_FLAGS;
88 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
89 SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
91 SHInitDialog( &shidi );
93 hListView = CreateWindow( WC_LISTVIEW, NULL,
94 WS_VISIBLE | WS_CHILD | LVS_REPORT |
95 LVS_SHOWSELALWAYS | WS_VSCROLL | WS_HSCROLL |
96 WS_BORDER | LVS_NOCOLUMNHEADER, 0, 0, 0, 0,
97 hwnd, NULL, hInst, NULL );
98 ListView_SetExtendedListViewStyle( hListView, LVS_EX_FULLROWSELECT );
102 lv.fmt = LVCFMT_LEFT ;
103 ListView_InsertColumn( hListView, 0, &lv );
105 SetTimer( hwnd, 1, 500 /*milliseconds*/, NULL );
108 case WM_WINDOWPOSCHANGED:
111 if( !GetClientRect( hwnd, &rect ) ) break;
112 SetWindowPos( hListView, 0, 0, 0,
113 rect.right - rect.left, rect.bottom - rect.top, 0 );
116 lv.cx = rect.right - rect.left;
117 lv.mask = LVCF_WIDTH;
118 ListView_SetColumn( hListView, 0, &lv );
123 SHSipPreference( hwnd, SIP_DOWN );
124 SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
143 ListView_DeleteAllItems( hListView );
147 memset( &(ofn), 0, sizeof(ofn) );
148 ofn.lStructSize = sizeof(ofn);
149 ofn.hwndOwner = hwnd;
150 ofn.lpstrFile = _T("");
151 ofn.nMaxFile = NMAXFILE;
152 ofn.lpstrFilter = _T("Text (*.txt)\0*.txt\0");
153 ofn.lpstrTitle = _T("Save File As");
154 ofn.Flags = OFN_HIDEREADONLY;
155 ofn.lpstrDefExt = _T("txt");
157 if( GetSaveFileName( (LPOPENFILENAME)&ofn ) )
159 fichier = CreateFile( ofn.lpstrFile, GENERIC_WRITE,
160 FILE_SHARE_READ|FILE_SHARE_WRITE,
162 FILE_ATTRIBUTE_NORMAL, NULL );
164 if( fichier != INVALID_HANDLE_VALUE )
168 //SetFilePointer( fichier, 0, NULL, FILE_END );
169 for( n = 0; n < ListView_GetItemCount( hListView ); n++ )
171 ListView_GetItemText( hListView, n, 0, psz_text,
173 string text_out = (string)_TOMB(psz_text) + "\n";
174 WriteFile( fichier, text_out.c_str(), text_out.size(),
175 (LPDWORD)&i_dummy, NULL );
177 FlushFileBuffers( fichier );
178 CloseHandle(fichier);
191 return DefWindowProc( hwnd, msg, wp, lp );
194 void Messages::UpdateLog()
196 msg_subscription_t *p_sub = p_intf->p_sys->p_sub;
200 vlc_mutex_lock( p_sub->p_lock );
201 i_stop = *p_sub->pi_stop;
202 vlc_mutex_unlock( p_sub->p_lock );
204 if( p_sub->i_start != i_stop )
206 for( i_start = p_sub->i_start; i_start != i_stop;
207 i_start = (i_start+1) % VLC_MSG_QSIZE )
209 switch( p_sub->p_msg[i_start].i_type )
213 if( p_intf->p_libvlc_global->i_verbose < 0 ) continue;
216 if( p_intf->p_libvlc_global->i_verbose < 1 ) continue;
219 if( p_intf->p_libvlc_global->i_verbose < 2 ) continue;
223 /* Append all messages to log window */
224 debug = p_sub->p_msg[i_start].psz_module;
226 switch( p_sub->p_msg[i_start].i_type )
228 case VLC_MSG_INFO: debug += ": "; break;
229 case VLC_MSG_ERR: debug += " error: "; break;
230 case VLC_MSG_WARN: debug += " warning: "; break;
231 default: debug += " debug: "; break;
235 debug += p_sub->p_msg[i_start].psz_msg;
239 lv.pszText = TEXT("");
242 lv.iItem = ListView_GetItemCount( hListView );
243 ListView_InsertItem( hListView, &lv );
244 ListView_SetItemText( hListView, lv.iItem, 0,
245 (TCHAR *)_FROMMB(debug.c_str()) );
248 vlc_mutex_lock( p_sub->p_lock );
249 p_sub->i_start = i_start;
250 vlc_mutex_unlock( p_sub->p_lock );