]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/sockets/client.cpp
Fix a couple warnings
[wxWidgets.git] / samples / sockets / client.cpp
index 94e010410e2960525df5e6b3f49d7d66ffbf3a26..9ca5518df842ae4c3479b28a98887c897b447088 100644 (file)
@@ -98,7 +98,7 @@ private:
   wxMenuBar      *m_menuBar;
   bool            m_busy;
 
-  // any class wishing to process wxWindows events must use this macro
+  // any class wishing to process wxWidgets events must use this macro
   DECLARE_EVENT_TABLE()
 };
 
@@ -125,7 +125,7 @@ enum
 };
 
 // --------------------------------------------------------------------------
-// event tables and other macros for wxWindows
+// event tables and other macros for wxWidgets
 // --------------------------------------------------------------------------
 
 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
@@ -157,11 +157,11 @@ bool MyApp::OnInit()
   MyFrame *frame = new MyFrame();
 
   // Show it and tell the application that it's our main window
-  frame->Show(TRUE);
+  frame->Show(true);
   SetTopWindow(frame);
 
   // success
-  return TRUE;
+  return true;
 }
 
 // --------------------------------------------------------------------------
@@ -169,7 +169,7 @@ bool MyApp::OnInit()
 // --------------------------------------------------------------------------
 
 // frame constructor
-MyFrame::MyFrame() : wxFrame((wxFrame *)NULL, -1,
+MyFrame::MyFrame() : wxFrame((wxFrame *)NULL, wxID_ANY,
                              _("wxSocket demo: Client"),
                              wxDefaultPosition, wxSize(300, 200))
 {
@@ -209,7 +209,7 @@ MyFrame::MyFrame() : wxFrame((wxFrame *)NULL, -1,
   CreateStatusBar(2);
 
   // Make a textctrl for logging
-  m_text  = new wxTextCtrl(this, -1,
+  m_text  = new wxTextCtrl(this, wxID_ANY,
                            _("Welcome to wxSocket demo: Client\nClient ready\n"),
                            wxDefaultPosition, wxDefaultSize,
                            wxTE_MULTILINE | wxTE_READONLY);
@@ -222,9 +222,9 @@ MyFrame::MyFrame() : wxFrame((wxFrame *)NULL, -1,
   m_sock->SetNotify(wxSOCKET_CONNECTION_FLAG |
                     wxSOCKET_INPUT_FLAG |
                     wxSOCKET_LOST_FLAG);
-  m_sock->Notify(TRUE);
+  m_sock->Notify(true);
 
-  m_busy = FALSE;
+  m_busy = false;
   UpdateStatusBar();
 }
 
@@ -238,8 +238,8 @@ MyFrame::~MyFrame()
 
 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
 {
-  // TRUE is to force the frame to close
-  Close(TRUE);
+  // true is to force the frame to close
+  Close(true);
 }
 
 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
@@ -253,8 +253,8 @@ void MyFrame::OnOpenConnection(wxCommandEvent& WXUNUSED(event))
 {
   wxIPV4address addr;
 
-  m_menuSocket->Enable(CLIENT_OPEN, FALSE);
-  m_menuSocket->Enable(CLIENT_CLOSE, FALSE);
+  m_menuSocket->Enable(CLIENT_OPEN, false);
+  m_menuSocket->Enable(CLIENT_CLOSE, false);
 
   // Ask user for server address
   wxString hostname = wxGetTextFromUser(
@@ -271,21 +271,21 @@ void MyFrame::OnOpenConnection(wxCommandEvent& WXUNUSED(event))
   // There are two ways to use Connect(): blocking and non-blocking,
   // depending on the value passed as the 'wait' (2nd) parameter.
   //
-  // Connect(addr, TRUE) will wait until the connection completes,
-  // returning TRUE on success and FALSE on failure. This call blocks
+  // Connect(addr, true) will wait until the connection completes,
+  // returning true on success and false on failure. This call blocks
   // the GUI (this might be changed in future releases to honour the
   // wxSOCKET_BLOCK flag).
   //
-  // Connect(addr, FALSE) will issue a nonblocking connection request
-  // and return immediately. If the return value is TRUE, then the
+  // Connect(addr, false) will issue a nonblocking connection request
+  // and return immediately. If the return value is true, then the
   // connection has been already succesfully established. If it is
-  // FALSE, you must wait for the request to complete, either with
+  // false, you must wait for the request to complete, either with
   // WaitOnConnect() or by watching wxSOCKET_CONNECTION / LOST
   // events (please read the documentation).
   //
   // WaitOnConnect() itself never blocks the GUI (this might change
   // in the future to honour the wxSOCKET_BLOCK flag). This call will
-  // return FALSE on timeout, or TRUE if the connection request
+  // return false on timeout, or true if the connection request
   // completes, which in turn might mean:
   //
   //   a) That the connection was successfully established
@@ -298,13 +298,13 @@ void MyFrame::OnOpenConnection(wxCommandEvent& WXUNUSED(event))
   //
   // For blocking Connect:
   //
-  //   bool success = client->Connect(addr, TRUE);
+  //   bool success = client->Connect(addr, true);
   //
   // For nonblocking Connect:
   //
-  //   client->Connect(addr, FALSE);
+  //   client->Connect(addr, false);
   //
-  //   bool waitmore = TRUE;
+  //   bool waitmore = true;
   //   while (! client->WaitOnConnect(seconds, millis) && waitmore )
   //   {
   //     // possibly give some feedback to the user,
@@ -315,7 +315,7 @@ void MyFrame::OnOpenConnection(wxCommandEvent& WXUNUSED(event))
   // And that's all :-)
 
   m_text->AppendText(_("\nTrying to connect (timeout = 10 sec) ...\n"));
-  m_sock->Connect(addr, FALSE);
+  m_sock->Connect(addr, false);
   m_sock->WaitOnConnect(10);
 
   if (m_sock->IsConnected())
@@ -337,7 +337,7 @@ void MyFrame::OnTest1(wxCommandEvent& WXUNUSED(event))
   unsigned char len;
 
   // Disable socket menu entries (exception: Close Session)
-  m_busy = TRUE;
+  m_busy = true;
   UpdateStatusBar();
 
   m_text->AppendText(_("\n=== Test 1 begins ===\n"));
@@ -387,7 +387,7 @@ void MyFrame::OnTest1(wxCommandEvent& WXUNUSED(event))
   m_text->AppendText(_("=== Test 1 ends ===\n"));
 
   delete[] buf2;
-  m_busy = FALSE;
+  m_busy = false;
   UpdateStatusBar();
 }
 
@@ -398,7 +398,7 @@ void MyFrame::OnTest2(wxCommandEvent& WXUNUSED(event))
   size_t len;
 
   // Disable socket menu entries (exception: Close Session)
-  m_busy = TRUE;
+  m_busy = true;
   UpdateStatusBar();
 
   m_text->AppendText(_("\n=== Test 2 begins ===\n"));
@@ -419,7 +419,7 @@ void MyFrame::OnTest2(wxCommandEvent& WXUNUSED(event))
   wxString s = wxGetTextFromUser(
     _("Enter an arbitrary string to send to the server:"),
     _("Test 2 ..."),
-    _("Yes I like wxWindows!"));
+    _("Yes I like wxWidgets!"));
 
   msg1 = s.c_str();
   len  = (wxStrlen(msg1) + 1) * sizeof(wxChar);
@@ -456,7 +456,7 @@ void MyFrame::OnTest2(wxCommandEvent& WXUNUSED(event))
   m_text->AppendText(_("=== Test 2 ends ===\n"));
 
   delete[] msg2;
-  m_busy = FALSE;
+  m_busy = false;
   UpdateStatusBar();
 }
 
@@ -467,7 +467,7 @@ void MyFrame::OnTest3(wxCommandEvent& WXUNUSED(event))
   unsigned char len;
 
   // Disable socket menu entries (exception: Close Session)
-  m_busy = TRUE;
+  m_busy = true;
   UpdateStatusBar();
 
   m_text->AppendText(_("\n=== Test 3 begins ===\n"));
@@ -514,7 +514,7 @@ void MyFrame::OnTest3(wxCommandEvent& WXUNUSED(event))
   m_text->AppendText(_("=== Test 3 ends ===\n"));
 
   delete[] buf2;
-  m_busy = FALSE;
+  m_busy = false;
   UpdateStatusBar();
 }
 
@@ -571,7 +571,8 @@ void MyFrame::OnTestURL(wxCommandEvent& WXUNUSED(event))
   wxYield();
 
   // Get the data
-  wxFileOutputStream sout(wxString("test.url"));
+  wxFile fileTest(wxT("test.url"));
+  wxFileOutputStream sout(fileTest);
   if (!sout.Ok())
   {
     m_text->AppendText(_("Error: couldn't open file for output\n"));