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 *****************************************************************************/
29 #include <vlc_interface.h>
40 #define NMAXFILE 512 // at least 256
44 #define TEXTMAXBUF 512 // at least 500
47 /*****************************************************************************
49 *****************************************************************************/
51 Messages::Messages( intf_thread_t *p_intf, CBaseWindow *p_parent,
53 : CBaseWindow( p_intf, p_parent, h_inst )
58 hWnd = CreateWindow( _T("VLC WinCE"), _T("Messages"),
59 WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX,
60 0, 0, /*CW_USEDEFAULT*/300, /*CW_USEDEFAULT*/300,
61 p_parent->GetHandle(), NULL, h_inst, (void *)this );
64 /***********************************************************************
69 Processes messages sent to the main window.
70 ***********************************************************************/
71 LRESULT Messages::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
75 TCHAR psz_text[TEXTMAXBUF];
83 shidi.dwMask = SHIDIM_FLAGS;
84 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
85 SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
87 SHInitDialog( &shidi );
89 hListView = CreateWindow( WC_LISTVIEW, NULL,
90 WS_VISIBLE | WS_CHILD | LVS_REPORT |
91 LVS_SHOWSELALWAYS | WS_VSCROLL | WS_HSCROLL |
92 WS_BORDER | LVS_NOCOLUMNHEADER, 0, 0, 0, 0,
93 hwnd, NULL, hInst, NULL );
94 ListView_SetExtendedListViewStyle( hListView, LVS_EX_FULLROWSELECT );
98 lv.fmt = LVCFMT_LEFT ;
99 ListView_InsertColumn( hListView, 0, &lv );
101 SetTimer( hwnd, 1, 500 /*milliseconds*/, NULL );
104 case WM_WINDOWPOSCHANGED:
107 if( !GetClientRect( hwnd, &rect ) ) break;
108 SetWindowPos( hListView, 0, 0, 0,
109 rect.right - rect.left, rect.bottom - rect.top, 0 );
112 lv.cx = rect.right - rect.left;
113 lv.mask = LVCF_WIDTH;
114 ListView_SetColumn( hListView, 0, &lv );
119 SHSipPreference( hwnd, SIP_DOWN );
120 SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
139 ListView_DeleteAllItems( hListView );
143 memset( &(ofn), 0, sizeof(ofn) );
144 ofn.lStructSize = sizeof(ofn);
145 ofn.hwndOwner = hwnd;
146 ofn.lpstrFile = _T("");
147 ofn.nMaxFile = NMAXFILE;
148 ofn.lpstrFilter = _T("Text (*.txt)\0*.txt\0");
149 ofn.lpstrTitle = _T("Save File As");
150 ofn.Flags = OFN_HIDEREADONLY;
151 ofn.lpstrDefExt = _T("txt");
153 if( GetSaveFileName( (LPOPENFILENAME)&ofn ) )
155 fichier = CreateFile( ofn.lpstrFile, GENERIC_WRITE,
156 FILE_SHARE_READ|FILE_SHARE_WRITE,
158 FILE_ATTRIBUTE_NORMAL, NULL );
160 if( fichier != INVALID_HANDLE_VALUE )
164 //SetFilePointer( fichier, 0, NULL, FILE_END );
165 for( n = 0; n < ListView_GetItemCount( hListView ); n++ )
167 ListView_GetItemText( hListView, n, 0, psz_text,
169 string text_out = (string)_TOMB(psz_text) + "\n";
170 WriteFile( fichier, text_out.c_str(), text_out.size(),
171 (LPDWORD)&i_dummy, NULL );
173 FlushFileBuffers( fichier );
174 CloseHandle(fichier);
187 return DefWindowProc( hwnd, msg, wp, lp );
190 void Messages::UpdateLog()
192 msg_subscription_t *p_sub = p_intf->p_sys->p_sub;
196 vlc_mutex_lock( p_sub->p_lock );
197 i_stop = *p_sub->pi_stop;
198 vlc_mutex_unlock( p_sub->p_lock );
200 if( p_sub->i_start != i_stop )
202 for( i_start = p_sub->i_start; i_start != i_stop;
203 i_start = (i_start+1) % VLC_MSG_QSIZE )
205 switch( p_sub->p_msg[i_start].i_type )
209 if( p_intf->p_libvlc_global->i_verbose < 0 ) continue;
212 if( p_intf->p_libvlc_global->i_verbose < 1 ) continue;
215 if( p_intf->p_libvlc_global->i_verbose < 2 ) continue;
219 /* Append all messages to log window */
220 debug = p_sub->p_msg[i_start].psz_module;
222 switch( p_sub->p_msg[i_start].i_type )
224 case VLC_MSG_INFO: debug += ": "; break;
225 case VLC_MSG_ERR: debug += " error: "; break;
226 case VLC_MSG_WARN: debug += " warning: "; break;
227 default: debug += " debug: "; break;
231 debug += p_sub->p_msg[i_start].psz_msg;
235 lv.pszText = TEXT("");
238 lv.iItem = ListView_GetItemCount( hListView );
239 ListView_InsertItem( hListView, &lv );
240 ListView_SetItemText( hListView, lv.iItem, 0,
241 (TCHAR *)_FROMMB(debug.c_str()) );
244 vlc_mutex_lock( p_sub->p_lock );
245 p_sub->i_start = i_start;
246 vlc_mutex_unlock( p_sub->p_lock );