2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 vdr = VDR::getInstance();
26 logger = Log::getInstance();
29 if (Video::getInstance()->getFormat() == Video::PAL)
31 setScreenPos(170, 200);
35 setScreenPos(160, 150);
45 vdr->cancelFindingServer();
52 logger->log("VConnect", Log::DEBUG, "Draw done");
55 int VConnect::handleCommand(int command)
65 void VConnect::threadMethod()
71 ViewMan* viewman = ViewMan::getInstance();
75 setOneLiner(tr("Locating server"));
77 viewman->updateView(this);
79 vdr->findServers(servers);
82 for(UINT k = 0; k < servers.size(); k++)
84 delete[] servers[k].ip;
85 delete[] servers[k].name;
91 if (servers.size() == 1)
98 VServerSelect* vs = new VServerSelect(servers, this);
100 viewman->add(vs); // FIXME - do this better - perhaps post message to Command
101 // Otherwise it will be using ViewMan without the Command mutex locked
102 viewman->updateView(vs);
105 threadWaitForSignal();
111 for(UINT k = 0; k < servers.size(); k++)
113 delete[] servers[k].ip;
114 delete[] servers[k].name;
120 logger->log("VConnect", Log::NOTICE, "Connecting to server at %s", servers[selectedServer].ip);
121 vdr->setServerIP(servers[selectedServer].ip);
123 // Clear the serverIPs vector
124 for(UINT k = 0; k < servers.size(); k++)
126 delete[] servers[k].ip;
127 delete[] servers[k].name;
131 setOneLiner(tr("Connecting to VDR"));
133 viewman->updateView(this);
135 success = vdr->connect();
138 logger->log("Command", Log::DEBUG, "Connected ok, doing login");
139 success = vdr->doLogin();
144 setOneLiner(tr("Login failed"));
150 setOneLiner(tr("Connection failed"));
155 viewman->updateView(this);
160 Message* m = new Message(); // Must be done after this thread ends
162 m->message = Message::VDR_CONNECTED;
163 Command::getInstance()->postMessage(m);
166 void VConnect::processMessage(Message* m)
168 if (m->message == Message::SERVER_SELECTED)
170 selectedServer = m->parameter;