Exemplo n.º 1
0
MBEG
#else
int main( int argc, char* argv[] )
#endif
{
        int cacheControl = -1;

        if ( argc == 1 ) {
                printf( "usage: clock [cache_control_in_sec]\n" );
                cacheControl = 1800;
        }
        else if ( argc > 2 ) {
                printf( "usage: clock [cache_control_in_sec]\n" );
                exit( 0 );
        }
        else if (sscanf(argv[1], "%i", &cacheControl) != 1) {
                printf( "Invalid CACHE-CONTROL value.\n" );
                exit( 0 );
        }

        printf( "Using CACHE-CONTROL value: %d sec\n", cacheControl );

	if (!InitApp( cacheControl )) {
		fprintf(stderr, "Couldn't create this clock device !!\n");
		exit(0);
	}
				
#if !defined(TENGINE)
	kbinit();
#endif
	int ch = 0;
	do
	{
#if !defined(TENGINE)
		if (0 < kbhit()) {
			ch = getchar();
			ch = toupper( ch );
		}
		else
			mupnp_wait(1000);
#else
		mupnp_wait(1000);
#endif
		
		upnp_clock_device_update(clockDev);
		
	} while( ch != 'Q');

#if !defined(TENGINE)
	kbexit();
#endif
	
	ExitApp();
	
	return(0);
}
Exemplo n.º 2
0
/**
 * Do an M-SEARCH to look for devices in the network.
 *
 * @param ctrlPoint The control point in question
 * @param target The Search Target parameter (ex. "ssdp:all")
 */
bool mupnp_controlpoint_search(mUpnpControlPoint *ctrlPoint, const char *target)
{
	mUpnpSSDPRequest *ssdpReq;
	mUpnpSSDPResponseServerList *ssdpResServerList;
	int i = 0;
	bool retval = false;
	
	mupnp_log_debug_l4("Entering...\n");

	ssdpReq = mupnp_ssdprequest_new();
	mupnp_ssdprequest_setmethod(ssdpReq, MUPNP_HTTP_MSEARCH);
	mupnp_ssdprequest_setst(ssdpReq, target);
	mupnp_ssdprequest_setmx(ssdpReq, mupnp_controlpoint_getssdpsearchmx(ctrlPoint));
	mupnp_ssdprequest_setman(ssdpReq, MUPNP_MAN_DISCOVER);
	
	mupnp_log_debug("Announcing %d times.\n", mupnp_ssdp_getannouncecount());
	mupnp_ssdprequest_print(ssdpReq);
	
	for (i = 0; i < mupnp_ssdp_getannouncecount(); i++)
	{
		ssdpResServerList = mupnp_controlpoint_getssdpresponseserverlist(ctrlPoint);
		retval = ( mupnp_ssdpresponse_serverlist_post(ssdpResServerList, ssdpReq ) || retval );
		mupnp_wait(MUPNP_CONTROLPOINT_SSDP_MIN_DELAY);
	}
	
	mupnp_ssdprequest_delete(ssdpReq);

	mupnp_log_debug_l4("Leaving...\n");

	return retval;
}
Exemplo n.º 3
0
void mupnp_service_createnotifyallthread(mUpnpService* service, mUpnpTime waitTime)
{
  mUpnpThread* thread;

  thread = mupnp_thread_new();
  mupnp_thread_setaction(thread, mupnp_service_notifyall_thread);
  mupnp_thread_setuserdata(thread, service);

  mupnp_wait(waitTime);
  mupnp_thread_start(thread);
}
Exemplo n.º 4
0
MBEG
#else
int main( int argc, char* argv[] )
#endif
{
	mUpnpControlPoint *ctrlPoint;
	int key;
	
	ctrlPoint = mupnp_controlpoint_new();
	mupnp_controlpoint_setssdplistener(ctrlPoint, SSDPNotifyListner);
	mupnp_controlpoint_seteventlistener(ctrlPoint, EventListener);
	if (mupnp_controlpoint_start(ctrlPoint) == false) {
		printf("Couldn't start this control point !!");
		exit(1);
	}
	
	PrintKeyMessage();

#if (!defined(WIN32) || defined(__CYGWIN__)) && !defined(TENGINE)
	kbinit();
#endif
	
	key = 0;
	do
	{
#if !defined(TENGINE)
		key = kbgetkey();
		key = toupper(key);
		switch (key) {
		case 'P':
			PrintControlPointDevice(ctrlPoint);
			break;
#if !defined(MUPNP_NOUSE_ACTIONCTRL)
		case 'C':
			ControlDeviceAlter(ctrlPoint, CMD_NO_ALTERATIONS);
			break;

		case 'O':
			ControlDeviceAlter(ctrlPoint, CMD_LOOP_ACTION_CALLS);
			break;
#endif
#if !defined(MUPNP_NOUSE_QUERYCTRL)
		case 'Q':
			QueryDevice(ctrlPoint);
			break;
#endif
#if !defined(MUPNP_NOUSE_SUBSCRIPTION)
		case 'S':
			SubscribeService(ctrlPoint);
			break;
		case 'U':
			UnsubscribeService(ctrlPoint);
			break;
#endif
                case 'M':
                        SetMXValue(ctrlPoint);
                        break;
		case 'R':
	          printf("M-Search upnp::rootdevice\n");
		  mupnp_controlpoint_search(ctrlPoint, MUPNP_ST_ROOT_DEVICE);
		  break;
		case 'H':
	          printf("M-Search ssdp:all\n");
		  mupnp_controlpoint_search(ctrlPoint, "ssdp:all");
		  break;
		case 'V':
	          printf("M-Search device type\n");
		  mupnp_controlpoint_search(ctrlPoint, "urn:schemas-upnp-org:device:clock:1");
		  break;
		case 'T':
	          printf("M-Search service type\n");
		  mupnp_controlpoint_search(ctrlPoint, "urn:schemas-upnp-org:service:timer:1");
		  break;
		case 'A':
		  {
			  int i;

			  printf("Doing all searches four times...\n");
			  
			  for (i=0; i<4; i++)
			  {
				  mupnp_controlpoint_search(ctrlPoint, MUPNP_ST_ROOT_DEVICE);
				  mupnp_controlpoint_search(ctrlPoint, "ssdp:all");
				  mupnp_controlpoint_search(ctrlPoint, "urn:schemas-upnp-org:device:clock:1");
				  mupnp_controlpoint_search(ctrlPoint, "urn:schemas-upnp-org:service:timer:1");
			  }
			  
			  printf("Done (doing all searches four times).\n");
		  }
		  break;
		case 'X':
			break;
		default:
			PrintKeyMessage();
		}
#else
		mupnp_wait(1000);
#endif
	} while( key != 'X');

#if (!defined(WIN32) || defined(__CYGWIN__)) && !defined(TENGINE)
	kbexit();
#endif
	
	mupnp_controlpoint_stop(ctrlPoint);
	mupnp_controlpoint_delete(ctrlPoint);
	
	return(0);
}