]> git.sesse.net Git - vlc/blob - plugins/win32/network.cpp
* Added a win32 interface plugin, developed with Borland C++ Builder.
[vlc] / plugins / win32 / network.cpp
1 /*****************************************************************************\r
2  * network.cpp: the "network" dialog box\r
3  *****************************************************************************\r
4  * Copyright (C) 2002 VideoLAN\r
5  *\r
6  * Authors: Olivier Teuliere <ipkiss@via.ecp.fr>\r
7  *\r
8  * This program is free software; you can redistribute it and/or modify\r
9  * it under the terms of the GNU General Public License as published by\r
10  * the Free Software Foundation; either version 2 of the License, or\r
11  * (at your option) any later version.\r
12  * \r
13  * This program is distributed in the hope that it will be useful,\r
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
16  * GNU General Public License for more details.\r
17  *\r
18  * You should have received a copy of the GNU General Public License\r
19  * along with this program; if not, write to the Free Software\r
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.\r
21  *****************************************************************************/\r
22 \r
23 #include <vcl.h>\r
24 #pragma hdrstop\r
25 \r
26 #include <videolan/vlc.h>\r
27 \r
28 #include "stream_control.h"\r
29 #include "input_ext-intf.h"\r
30 \r
31 #include "interface.h"\r
32 #include "intf_playlist.h"\r
33 \r
34 #include "network.h"\r
35 #include "win32_common.h"\r
36 \r
37 #include "netutils.h"\r
38 \r
39 //---------------------------------------------------------------------------\r
40 //#pragma package(smart_init)\r
41 #pragma resource "*.dfm"\r
42 \r
43 extern struct intf_thread_s *p_intfGlobal;\r
44 \r
45 //---------------------------------------------------------------------------\r
46 __fastcall TNetworkDlg::TNetworkDlg( TComponent* Owner )\r
47         : TForm( Owner )\r
48 {\r
49 }\r
50 //---------------------------------------------------------------------------\r
51 void __fastcall TNetworkDlg::FormShow( TObject *Sender )\r
52 {\r
53     p_intfGlobal->p_sys->p_window->MenuNetworkStream->Checked = true;\r
54     p_intfGlobal->p_sys->p_window->PopupNetworkStream->Checked = true;\r
55 }\r
56 //---------------------------------------------------------------------------\r
57 void __fastcall TNetworkDlg::FormHide( TObject *Sender )\r
58 {\r
59     p_intfGlobal->p_sys->p_window->MenuNetworkStream->Checked = false;\r
60     p_intfGlobal->p_sys->p_window->PopupNetworkStream->Checked = false;\r
61 }\r
62 //---------------------------------------------------------------------------\r
63 void __fastcall TNetworkDlg::BitBtnCancelClick( TObject *Sender )\r
64 {\r
65     Hide();\r
66 }\r
67 //---------------------------------------------------------------------------\r
68 void __fastcall TNetworkDlg::CheckBoxBroadcastClick( TObject *Sender )\r
69 {\r
70     ComboBoxBroadcast->Enabled = NOT( ComboBoxBroadcast->Enabled );\r
71 }\r
72 //---------------------------------------------------------------------------\r
73 void __fastcall TNetworkDlg::CheckBoxChannelClick( TObject *Sender )\r
74 {\r
75     LabelAddress->Enabled = NOT( LabelAddress->Enabled );\r
76     ComboBoxAddress->Enabled = NOT( ComboBoxAddress->Enabled );\r
77     LabelPort->Enabled = NOT( LabelPort->Enabled );\r
78     EditPort->Enabled = NOT( EditPort->Enabled );\r
79     UpDownPort->Enabled = NOT( UpDownPort->Enabled );\r
80     CheckBoxBroadcast->Enabled = NOT( CheckBoxBroadcast->Enabled );\r
81     ComboBoxBroadcast->Enabled = ( NOT( ComboBoxBroadcast->Enabled ) &&\r
82                                    CheckBoxBroadcast->Checked );\r
83     ComboBoxChannel->Enabled = NOT( ComboBoxChannel->Enabled );\r
84     LabelPortCS->Enabled = NOT( LabelPortCS->Enabled );\r
85     EditPortCS->Enabled = NOT( EditPortCS->Enabled );\r
86     UpDownPortCS->Enabled = NOT( UpDownPortCS->Enabled );\r
87 }\r
88 //---------------------------------------------------------------------------\r
89 void __fastcall TNetworkDlg::BitBtnOkClick( TObject *Sender )\r
90 {\r
91     AnsiString      Source, Protocol, Server;\r
92     boolean_t       b_channel;\r
93     boolean_t       b_broadcast;\r
94     unsigned int    i_port;\r
95     int             i_end = p_main->p_playlist->i_size;\r
96 \r
97     Hide();\r
98     Server = ComboBoxAddress->Text;\r
99 \r
100     /* select added item */\r
101     if( p_input_bank->pp_input[0] != NULL )\r
102     {\r
103         p_input_bank->pp_input[0]->b_eof = 1;\r
104     }\r
105 \r
106     /* Check which protocol was activated */\r
107     switch( RadioGroupProtocol->ItemIndex )\r
108     {\r
109         case 0:\r
110             Protocol = "udp";\r
111             break;\r
112         case 1:\r
113             intf_ErrMsg( "intf error: rtp protocol not yet implemented" );\r
114             return;\r
115         case 2:\r
116             Protocol = "http";\r
117             break;\r
118     }\r
119 \r
120     /* Manage channel server */\r
121     b_channel = CheckBoxChannel->Checked ? TRUE : FALSE;\r
122     config_PutIntVariable( "network_channel", b_channel );\r
123     if( b_channel )\r
124     {\r
125         AnsiString      Channel = ComboBoxChannel->Text;\r
126         unsigned int    i_channel_port = UpDownPortCS->Position;\r
127 \r
128         if( p_main->p_channel == NULL )\r
129         {\r
130             network_ChannelCreate();\r
131         }\r
132 \r
133         config_PutPszVariable( "channel_server", Channel.c_str() );\r
134         if( i_channel_port < 65536 )\r
135         {\r
136             config_PutIntVariable( "channel_port", i_channel_port );\r
137         }\r
138 \r
139         p_intfGlobal->p_sys->b_playing = 1;\r
140     }\r
141     else\r
142     {\r
143         /* Get the port number and make sure it will not\r
144          * overflow 5 characters */\r
145         i_port = UpDownPort->Position;\r
146         if( i_port > 65535 )\r
147         {\r
148             intf_ErrMsg( "intf error: invalid port %i", i_port );\r
149         }\r
150 \r
151         /* do we have a broadcast address */\r
152         b_broadcast = CheckBoxBroadcast->Checked ? TRUE : FALSE;\r
153         if( b_broadcast )\r
154         {\r
155             AnsiString Broadcast = ComboBoxBroadcast->Text;\r
156 \r
157             /* Build source name */\r
158             Source = Protocol + "://" + Server + "@:" + IntToStr( i_port )\r
159                      + "/" + Broadcast;\r
160         }\r
161         else\r
162         {\r
163             /* Build source name */\r
164             Source = Protocol + "://" + Server + "@:" + IntToStr( i_port );\r
165         }\r
166 \r
167         intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, Source.c_str() );\r
168         \r
169         /* update the display */\r
170         p_intfGlobal->p_sys->p_playlist->UpdateGrid( p_main->p_playlist );\r
171 \r
172         intf_PlaylistJumpto( p_main->p_playlist, i_end - 1 );\r
173     }\r
174 }\r
175 //---------------------------------------------------------------------------\r
176 \r