You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bluesky-commits@incubator.apache.org by ma...@apache.org on 2010/09/27 12:20:50 UTC

svn commit: r1001701 [4/4] - in /incubator/bluesky/branches/apache-bluesky-realclass0.2.0: ./ TserverQT-0.2.0/

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/stdafx.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/stdafx.cpp?rev=1001701&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/stdafx.cpp (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/stdafx.cpp Mon Sep 27 12:20:49 2010
@@ -0,0 +1,20 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements.  See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership.  The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License.  You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied.  See the License for the
+//specific language governing permissions and limitations
+//under the License. 
+
+#include "stdafx.h"
+
+

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/stdafx.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/stdafx.h?rev=1001701&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/stdafx.h (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/stdafx.h Mon Sep 27 12:20:49 2010
@@ -0,0 +1,57 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements.  See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership.  The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License.  You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied.  See the License for the
+//specific language governing permissions and limitations
+//under the License. 
+
+// stdafx.h : include file for standard system include files,
+//  or project specific include files that are used frequently, but
+//      are changed infrequently
+//
+
+#if !defined(STDAFX_H_LINUX)
+#define STDAFX_H_LINUX
+	#include <sys/socket.h>
+	#include <netinet/in.h>
+	#include <arpa/inet.h>
+	#include <sys/ioctl.h>
+	#include <net/if.h>
+	#include <string.h>
+	#include <netdb.h>
+	#include <unistd.h>
+	#include <stdio.h>
+
+
+	#define RTPSOCKERR					-1
+
+
+
+//	#define FALSE						false	
+//	#define TRUE							true	
+	#define INVALID_SOCKET				0
+	#define SOCKET_ERROR  			    RTPSOCKERR
+
+	#define IOCTL						ioctl
+	#define CLOSESOCKET(x)				close(x);
+
+	typedef int							SOCKET;
+	typedef sockaddr					SOCKADDR;
+	typedef struct sockaddr_in		SOCKADDR_IN;
+	typedef bool							BOOL;
+	typedef unsigned int				UINT;
+	typedef const char*					LPCTSTR;
+	typedef char*						LPSTR;
+	typedef unsigned long				DWORD;
+	typedef struct hostent				HOSTENT, *LPHOSTENT;
+#endif // !defined(STDAFX_H_LINUX)

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/support.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/support.cpp?rev=1001701&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/support.cpp (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/support.cpp Mon Sep 27 12:20:49 2010
@@ -0,0 +1,114 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements.  See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership.  The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License.  You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied.  See the License for the
+//specific language governing permissions and limitations
+//under the License. 
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <gtk/gtk.h>
+
+#include "support.hh"
+
+static GList *pixmaps_directories = NULL;
+
+/* Use this function to set the directory containing installed pixmaps. */
+void
+add_pixmap_directory                   (const gchar     *directory)
+{
+  pixmaps_directories = g_list_prepend (pixmaps_directories,
+                                        g_strdup (directory));
+}
+
+/* This is an internally used function to find pixmap files. */
+static gchar*
+find_pixmap_file                       (const gchar     *filename)
+{
+  GList *elem;
+
+  /* We step through each of the pixmaps directory to find it. */
+  elem = pixmaps_directories;
+  while (elem)
+    {
+      gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
+                                         G_DIR_SEPARATOR_S, filename);
+      if (g_file_test (pathname, G_FILE_TEST_EXISTS))
+        return pathname;
+      g_free (pathname);
+      elem = elem->next;
+    }
+  return NULL;
+}
+
+/* This is an internally used function to create pixmaps. */
+GtkWidget*
+create_pixmap                          (GtkWidget       *widget,
+                                        const gchar     *filename)
+{
+  gchar *pathname = NULL;
+  GtkWidget *pixmap;
+
+  if (!filename || !filename[0])
+      return gtk_image_new ();
+
+  pathname = find_pixmap_file (filename);
+
+  if (!pathname)
+    {
+      g_warning (_("Couldn't find pixmap file: %s"), filename);
+      return gtk_image_new ();
+    }
+
+  pixmap = gtk_image_new_from_file (pathname);
+  g_free (pathname);
+  return pixmap;
+}
+
+/* This is an internally used function to create pixmaps. */
+GdkPixbuf*
+create_pixbuf                          (const gchar     *filename)
+{
+  gchar *pathname = NULL;
+  GdkPixbuf *pixbuf;
+  GError *error = NULL;
+
+  if (!filename || !filename[0])
+      return NULL;
+
+  pathname = find_pixmap_file (filename);
+
+  if (!pathname)
+    {
+      g_warning (_("Couldn't find pixmap file: %s"), filename);
+      return NULL;
+    }
+
+  pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
+  if (!pixbuf)
+    {
+      fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
+               pathname, error->message);
+      g_error_free (error);
+    }
+  g_free (pathname);
+  return pixbuf;
+}

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/support.hh
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/support.hh?rev=1001701&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/support.hh (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/support.hh Mon Sep 27 12:20:49 2010
@@ -0,0 +1,62 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements.  See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership.  The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License.  You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied.  See the License for the
+//specific language governing permissions and limitations
+//under the License. 
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+
+/*
+ * Standard gettext macros.
+ */
+#ifdef ENABLE_NLS
+#  include <libintl.h>
+#  undef _
+#  define _(String) dgettext (PACKAGE, String)
+#  define Q_(String) g_strip_context ((String), gettext (String))
+#  ifdef gettext_noop
+#    define N_(String) gettext_noop (String)
+#  else
+#    define N_(String) (String)
+#  endif
+#else
+#  define textdomain(String) (String)
+#  define gettext(String) (String)
+#  define dgettext(Domain,Message) (Message)
+#  define dcgettext(Domain,Message,Type) (Message)
+#  define bindtextdomain(Domain,Directory) (Domain)
+#  define _(String) (String)
+#  define Q_(String) g_strip_context ((String), (String))
+#  define N_(String) (String)
+#endif
+
+/* Use this function to set the directory containing installed pixmaps. */
+void        add_pixmap_directory       (const gchar     *directory);
+
+
+/*
+ * Private Functions.
+ */
+
+/* This is used to create the pixmaps used in the interface. */
+GtkWidget*  create_pixmap              (GtkWidget       *widget,
+                                        const gchar     *filename);
+
+/* This is used to create the pixbufs used in the interface. */
+GdkPixbuf*  create_pixbuf              (const gchar     *filename);
+

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tcpcomm.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tcpcomm.cpp?rev=1001701&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tcpcomm.cpp (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tcpcomm.cpp Mon Sep 27 12:20:49 2010
@@ -0,0 +1,88 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements.  See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership.  The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License.  You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied.  See the License for the
+//specific language governing permissions and limitations
+//under the License. 
+
+// TCPComm.cpp: implementation of the CTCPComm class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#include "stdafx.h"
+#include "asyncsocketex.h"
+#include "tcpcomm.h"
+#include "tcppollthread.h"
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+CTCPComm::CTCPComm()
+{
+
+	m_pThread = 0;
+}
+
+CTCPComm::~CTCPComm()
+{
+	Stop();
+
+}
+
+
+int CTCPComm::OnPollThreadError(int status)
+{
+	return -1;
+}
+
+bool CTCPComm::Init()
+{
+
+	if(m_pThread){
+		m_pThread->Stop();
+		return true;
+	}
+
+	m_pThread = new CTCPPollThread(this);
+
+	if(m_pThread)
+		return true;
+
+	return false;
+}
+
+int CTCPComm::Start()
+{
+	if(m_pThread == 0){
+		return -1;
+	}
+	return m_pThread->Start();
+}
+
+bool CTCPComm::IsPolling()
+{
+	if(m_pThread == 0){
+		return false;
+	}
+	return m_pThread->IsRunning();
+}
+
+
+void CTCPComm::Stop()
+{
+	if(m_pThread){
+		m_pThread->Stop();
+	}
+
+}

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tcpcomm.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tcpcomm.h?rev=1001701&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tcpcomm.h (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tcpcomm.h Mon Sep 27 12:20:49 2010
@@ -0,0 +1,48 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements.  See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership.  The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License.  You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied.  See the License for the
+//specific language governing permissions and limitations
+//under the License. 
+// TCPComm.h: interface for the CTCPComm class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#if !defined(TCPCOMM_H)
+#define TCPCOMM_H
+
+class CTCPPollThread;
+class CTCPComm  
+{
+	friend class CTCPPollThread;
+public:
+	void Stop();
+	bool IsPolling();
+	int Start();
+	virtual bool Init();
+	CTCPComm();
+	virtual ~CTCPComm();
+
+protected:
+	virtual void OnPollThreadStep() = 0;
+	virtual int OnPollThreadError(int status);
+	virtual int PolledSocket() = 0;
+	virtual int Poll() = 0;
+
+	
+
+private:
+	CTCPPollThread *m_pThread;
+};
+
+#endif // !defined(TCPCOMM_H)

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tcppollthread.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tcppollthread.cpp?rev=1001701&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tcppollthread.cpp (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tcppollthread.cpp Mon Sep 27 12:20:49 2010
@@ -0,0 +1,97 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements.  See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership.  The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License.  You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied.  See the License for the
+//specific language governing permissions and limitations
+//under the License. 
+#include "tcppollthread.h"
+#include "tcpcomm.h"
+
+CTCPPollThread::CTCPPollThread(CTCPComm* pcomm)
+{
+	m_pcomm = pcomm;
+	stop = false;
+}
+
+CTCPPollThread::~CTCPPollThread()
+{
+	Stop();
+}
+ 
+int CTCPPollThread::Start()
+{
+	if (JThread::IsRunning())
+		return -1;
+	
+	if (!stopmutex.IsInitialized())
+	{
+		if (stopmutex.Init() < 0)
+			return -1;
+	}
+	stop = false;
+	if (JThread::Start() < 0)
+		return -1;
+	return 0;
+}
+
+void CTCPPollThread::Stop()
+{	
+	if (!IsRunning())
+		return;
+	
+	stopmutex.Lock();
+	stop = true;
+	stopmutex.Unlock();
+	
+	
+	if (JThread::IsRunning())
+	{
+		JThread::Kill();
+	}
+	stop = false;
+}
+
+void *CTCPPollThread::Thread()
+{
+	JThread::ThreadStarted();
+	
+	int status;
+	bool stopthread;
+
+	stopmutex.Lock();
+	stopthread = stop;
+	stopmutex.Unlock();
+	while (!stopthread)
+	{
+
+		status = m_pcomm->Poll();
+		if(status < 0 ){
+			stopthread = 0;
+			m_pcomm->OnPollThreadError(status);
+		}
+		else{
+			status = m_pcomm->PolledSocket();
+			if(status < 0){
+				stopthread = true;
+				m_pcomm->OnPollThreadError(status);
+			}
+			else{
+				m_pcomm->OnPollThreadStep();
+				stopmutex.Lock();
+				stopthread = stop;
+				stopmutex.Unlock();
+			}
+		}
+	}
+	return 0;
+}

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tcppollthread.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tcppollthread.h?rev=1001701&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tcppollthread.h (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tcppollthread.h Mon Sep 27 12:20:49 2010
@@ -0,0 +1,45 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements.  See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership.  The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License.  You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied.  See the License for the
+//specific language governing permissions and limitations
+//under the License. 
+#ifndef CTCPPOLLTHREAD_H
+
+#define CTCPPOLLTHREAD_H
+
+
+
+
+#include "jthread.h"
+#include "jmutex.h"
+
+class CTCPComm;
+class CTCPPollThread : private JThread
+{
+	friend class CTCPComm;
+public:
+	CTCPPollThread(CTCPComm* pcomm);
+	~CTCPPollThread();
+	int Start();
+	void Stop();
+private:
+	void *Thread();
+	
+	bool stop;
+	JMutex stopmutex;
+	CTCPComm *m_pcomm;
+};
+
+
+#endif // CTCPPOLLTHREAD_H

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tserver.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tserver.cpp?rev=1001701&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tserver.cpp (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/tserver.cpp Mon Sep 27 12:20:49 2010
@@ -0,0 +1,81 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements.  See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership.  The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License.  You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied.  See the License for the
+//specific language governing permissions and limitations
+//under the License. 
+
+// TServer.cpp : Defines the entry point for the console application.
+//
+
+#include "stdafx.h"
+#include "asyncsocketex.h"
+#include <list>
+#include <string>
+#include "clientsocket.h"
+#include "multicomm.h"
+#include "listencomm.h"
+
+#include "adminserver.h"
+//#include "interface.hh"
+#include "callbacks.hh"
+#include "support.hh"
+
+#include <signal.h>
+#include <unistd.h>
+
+#define TSERVER_VERSION "1.2"
+
+
+int main(int argc, char* argv[])
+{
+	if(argc==2)
+	{
+		if(strcmp(argv[1],"--version")==0)
+			printf("\n tserver (copyright @ XJTU), version %s\n\n",TSERVER_VERSION);
+		else if(strcmp(argv[1],"-v")==0)
+			printf("%s\n",TSERVER_VERSION);
+		else
+			printf("\n unknow parameter!\n\n");
+	return 0;
+	}
+	GtkWidget *window1;
+	guint timer;
+
+#ifdef ENABLE_NLS
+  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+  textdomain (GETTEXT_PACKAGE);
+#endif
+
+  gtk_set_locale ();
+  gtk_init (&argc, &argv);
+
+//  add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
+
+  window1 = create_window_tserver ();
+  gtk_widget_show (window1);
+  timer = gtk_timeout_add(3000,timer_callback,NULL);
+
+  gtk_main ();
+
+  printf("end\n");
+
+	
+
+	
+
+
+	return 0;
+
+}