Example #1
0
int 
SockDgram::doStart()
{
	int ret = MW_SUCCESS;

	if(getOpMode() == OSAL::OPMODE_ASYNC)
	{
#ifdef OSAL_WIN32      
		OSAL_SOCKET os_sock_desc = this->getSD(_ACCEPT_USE_);
		setHandle(pSysEventProcessor_->createHandleRequest());
		OSAL_HANDLE os_handle = this->getHandle();
		WSAEventSelect(os_sock_desc, os_handle, FD_READ);
#else
		setHandle(this->getSD());
#endif
		//TODO: Who will deallocate this allocated memory?
		pSockAsyncOperation_ = new SockDgram_AsyncOpeartion(this);
		ret = registerAsyncOperation(DevType_, os_handle, pSockAsyncOperation_, os_sock_desc);
	}
	else
	{	
		//TODO: Who will deallocate this allocated memory?
		pSockSyncOperation_ = new SockDgram_SyncOpeartion(this);
		//TODO: When it comes to sync operation, its return handle shall be managed by concrete IO devices.
		//		so, I have to implement it.
		ret=registerSyncOperation(pSockSyncOperation_);

	}
	return ret;
}
 AbstractOverlappedEventNotifier(QSerialPortPrivate *d, Type type, bool manual, QObject *parent)
     : QWinEventNotifier(parent), dptr(d), t(type) {
     ::memset(&o, 0, sizeof(o));
     o.hEvent = ::CreateEvent(NULL, manual, FALSE, NULL);
     setHandle(o.hEvent);
     dptr->notifiers[o.hEvent] = this;
 }
Example #3
0
BOOL USplashWindow::onTimer(WPARAM wParam, LPARAM lParam)
{
    killTimer(ID_SPLASH_TIMER);
    destroy();
    setHandle(NULL);
	return FALSE;
}
/*
 * Class:     org_dmlc_xgboost4j_wrapper_XgboostJNI
 * Method:    XGBoosterCreate
 * Signature: ([J)J
 */
JNIEXPORT jint JNICALL Java_org_dmlc_xgboost4j_wrapper_XgboostJNI_XGBoosterCreate
  (JNIEnv *jenv, jclass jcls, jlongArray jhandles, jlongArray jout) {
    DMatrixHandle* handles;
    bst_ulong len = 0;
    jlong* cjhandles = 0;
    BoosterHandle result;
    
    if(jhandles) {
        len = (bst_ulong)jenv->GetArrayLength(jhandles);
        handles = new DMatrixHandle[len];
        //put handle from jhandles to chandles
        cjhandles = jenv->GetLongArrayElements(jhandles, 0);
        for(bst_ulong i=0; i<len; i++) {
            handles[i] = (DMatrixHandle) cjhandles[i];
        }
    }
    
    int ret = XGBoosterCreate(handles, len, &result);    
    //release
    if(jhandles) {
        delete[] handles;
        jenv->ReleaseLongArrayElements(jhandles, cjhandles, 0);
    }
    setHandle(jenv, jout, result);
    
    return ret;
}
Example #5
0
/*
 * Construct a new Java magick.MagickImage object and set the
 * handle.
 *
 * Input:
 *   env     Java VM environment
 *   image   ImageMagick image handle
 *
 * Return:
 *   A new instance of magick.MagickImage object.
 *
 */
jobject newImageObject(JNIEnv *env, Image* image)
{
    jclass magickImageClass = 0;
    jmethodID consMethodID = 0;
    jobject newObj;

    magickImageClass = (*env)->FindClass(env, "magick/MagickImage");
    if (magickImageClass == 0) {
	return NULL;
    }

    consMethodID = (*env)->GetMethodID(env, magickImageClass,
				       "<init>", "()V");
    if (consMethodID == 0) {
	return NULL;
    }

    newObj = (*env)->NewObject(env, magickImageClass, consMethodID);
    if (newObj == NULL) {
	return NULL;
    }

    if (!setHandle(env, newObj, "magickImageHandle", (void*) image, NULL)) {
#ifdef DIAGNOSTIC
	fprintf(stderr, "newImageObject: Unable to set handle\n");
#endif
	return NULL;
    }

    return newObj;
}
/*
 * Class:     magick_MontageInfo
 * Method:    init
 * Signature: (Lmagick/ImageInfo;)V
 */
JNIEXPORT void JNICALL Java_magick_MontageInfo_init
  (JNIEnv *env, jobject self, jobject imageInfo)
{
    ImageInfo *info;
    MontageInfo *montageInfo;

    /* Obtain the ImageInfo */
    info = (ImageInfo*) getHandle(env, imageInfo, "imageInfoHandle", NULL);
    if (info == NULL) {
        throwMagickException(env, "Unable to obtain ImageInfo handle");
        return;
    }

    /* Initialise the MontageInfo handle, allocating memory if required */
    montageInfo =
        (MontageInfo*) getHandle(env, self, "montageInfoHandle", NULL);
    if (montageInfo == NULL) {
        montageInfo = (MontageInfo*) AcquireMemory(sizeof(MontageInfo));
        if (montageInfo == NULL) {
            throwMagickException(env,
                                 "Unable to allocate "
                                 "memory for MontageInfo");
            return;
        }
    }
    GetMontageInfo(info, montageInfo);
    setHandle(env, self, "montageInfoHandle", (void*) montageInfo, NULL);
}
Example #7
0
mxRadioButton::mxRadioButton (mxWindow *parent, int x, int y, int w, int h, const char *label, int id, bool newGroup)
: mxWidget (parent, x, y, w, h, label)
{
	if (!parent)
		return;

	DWORD dwStyle = WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON;
	HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();

	if (newGroup)
		dwStyle |= WS_GROUP;

	void *handle = (void *) CreateWindowEx (0, "BUTTON", label, dwStyle,
				x, y, w, h, hwndParent,
				(HMENU) id, (HINSTANCE) GetModuleHandle (NULL), NULL);
	
	SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
	SetWindowLong ((HWND) handle, GWL_USERDATA, (LONG) this);

	setHandle (handle);
	setType (MX_RADIOBUTTON);
	setParent (parent);
	setId (id);

	setChecked (newGroup);
}
mxProgressBar::mxProgressBar (mxWindow *parent, int x, int y, int w, int h, int style)
: mxWidget (parent, x, y, w, h)
{
	if (!parent)
		return;

	d_this = new mxProgressBar_i;

	DWORD dwStyle = WS_VISIBLE | WS_CHILD;
	HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();

	if (style == Smooth)
		dwStyle |= PBS_SMOOTH;

	void *handle = (void *) CreateWindowEx (0, PROGRESS_CLASS, "", dwStyle,
				x, y, w, h, hwndParent,
				(HMENU) NULL, (HINSTANCE) GetModuleHandle (NULL), NULL);
	
	SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));

	setHandle (handle);
	setType (MX_PROGRESSBAR);
	setParent (parent);

	parent->addWidget (this);
}
Example #9
0
void
TDECModuleInfo::loadAll() 
{
  if( !_service ) /* We have a bogus service. All get functions will return empty/zero values */
    return;

  _allLoaded = true;

  // library and factory
  setHandle(_service->property("X-TDE-FactoryName", TQVariant::String).toString());

  TQVariant tmp;

  // read weight
  tmp = _service->property( "X-TDE-Weight", TQVariant::Int );
  setWeight( tmp.isValid() ? tmp.toInt() : 100 );

  // does the module need super user privileges?
  tmp = _service->property( "X-TDE-RootOnly", TQVariant::Bool );
  setNeedsRootPrivileges( tmp.isValid() ? tmp.toBool() : false );

  // does the module need to be shown to root only?
  // Deprecated ! KDE 4
  tmp = _service->property( "X-TDE-IsHiddenByDefault", TQVariant::Bool );
  setIsHiddenByDefault( tmp.isValid() ? tmp.toBool() : false );

  // get the documentation path
  setDocPath( _service->property( "DocPath", TQVariant::String ).toString() );

  tmp = _service->property( "X-TDE-Test-Module", TQVariant::Bool );
  setNeedsTest( tmp.isValid() ? tmp.asBool() : false );
}
int timeListener::start() {
    int fd = socket(AF_INET, SOCK_STREAM, 0);
    int ret = -1;
    struct sockaddr_in servaddr;
    if(fd < 0) {
        perror("socket error!");
        return -1;
    }
    setHandle(fd);
    bzero(&servaddr, sizeof(servaddr));
    servaddr.sin_family = AF_INET;
    servaddr.sin_port  = htons(port_);
    ret = inet_pton(AF_INET, ip_.c_str(), &servaddr.sin_addr);
    if(ret < 0) {
        perror("inet_pton error!");
        return -1;
    }
    ret = bind(fd, (struct sockaddr*)&servaddr, sizeof(servaddr));
    if(ret < 0) {
        perror("bind error!");
        return -1;
    }
    ret = listen(fd, 64);
    if(ret < 0) {
        perror("listen error!");
        return -1;
    }
    std::cerr<<"time server is listening..."<<std::endl;
    return 0;
}
Example #11
0
////////////////////////////////////////////////////////////////////////////////
// create
//virtual
void RsVertexBufferGL::create()
{
	// Generate buffers.
	GLuint Handle;
	glGenBuffers( 1, &Handle );
	setHandle( Handle );
	
	if( Handle != 0 )
	{
		// Increment fence, update will decrement it.
		UpdateSyncFence_.increment();

		// Update resource.
		update();
		
		// Destroy if there is a failure.
		if ( glGetError() != GL_NO_ERROR )
		{
			destroy();
		}
		else
		{
			Created_ = BcTrue;
		}
	}
}
Example #12
0
void PublicationBase::update(void *data)
{
	if (_handle != nullptr) {
		int ret = orb_publish(getMeta(), getHandle(), data);

		if (ret != PX4_OK) { warnx("publish fail"); }

	} else {
		orb_advert_t handle;

		if (_priority > 0) {
			handle = orb_advertise_multi(
					 getMeta(), data,
					 &_instance, _priority);

		} else {
			handle = orb_advertise(getMeta(), data);
		}

		if (int64_t(handle) != PX4_ERROR) {
			setHandle(handle);

		} else {
			warnx("advert fail");
		}
	}
}
Example #13
0
/*
 * Class:     magick_ImageInfo
 * Method:    setFileName
 * Signature: (Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_magick_ImageInfo_setFileName
    (JNIEnv *env, jobject obj, jstring fileName)
{
    ImageInfo *imageInfo = NULL;
    jfieldID handleFid = 0;
    const char *cstr = NULL;

    imageInfo = (ImageInfo*) getHandle(env, obj,
				       "imageInfoHandle", &handleFid);

    if (imageInfo == NULL) {
	imageInfo = (ImageInfo *) AcquireMemory(sizeof(ImageInfo));
	if (imageInfo == NULL) {
	    throwMagickException(env, "Unable to allow memory for handle");
	    return;
	}
	GetImageInfo(imageInfo);
	setHandle(env, obj, "imageInfoHandle", (void*) imageInfo, &handleFid);
    }

    cstr = (*env)->GetStringUTFChars(env, fileName, 0);
    strcpy(imageInfo->filename, cstr);
    (*env)->ReleaseStringUTFChars(env, fileName, cstr);

#ifdef DIAGNOSTIC
    fprintf(stderr, "Set the file name in ImageInfo to %s\n",
            imageInfo->filename);
#endif
}
/*
 * Class:     org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia
 * Method:    open
 * Signature: (Ljava/lang/String;)I
 */
JNIEXPORT jint JNICALL
Java_org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia_open
(JNIEnv *env, jobject obj, jstring strDevice)
{
	int	nReturn;
	const char*	cd_dev;
	cdrom_drive*	cdrom = NULL;
	handle_t*	pHandle;
	int		nParanoiaMode;

	if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia_open(): begin\n"); }
	cd_dev = (*env)->GetStringUTFChars(env, strDevice, NULL);
	if (cd_dev == NULL)
	{
		if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia_open(): GetStringUTFChars() failed.\n"); }
		return -1;
	}
	if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia_open(): device name: %s\n", cd_dev); }
	cdrom = cdda_identify(cd_dev, 0, NULL);
	if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia_open(): device name: %s\n", cd_dev); }
	(*env)->ReleaseStringUTFChars(env, strDevice, cd_dev);
	if (cdrom == NULL)
	{
		if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia_open(): cdda_identify() failed.\n"); }
		return -1;
	}
	nReturn = cdda_open(cdrom);
	if (nReturn < 0)
	{
		if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia_open(): cdda_open() failed.\n"); }
		return -1;
	}

	if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia_open(): drive endianess: %d\n", cdrom->bigendianp); }

	pHandle = (handle_t*) malloc(sizeof(handle_t));
	if (pHandle == NULL)
	{
		if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia_open(): malloc() failed.\n"); }
		cdda_close(cdrom);
		return -1;
	}
	pHandle->drive = cdrom;
	pHandle->paranoia = paranoia_init(pHandle->drive);
	if (pHandle->paranoia == NULL)
	{
		if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia_open(): paranoia_init() failed.\n"); }
		cdda_close(pHandle->drive);
		free(pHandle);
		return -1;
	}
	nParanoiaMode = getParanoiaMode();
	if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia_open(): paranoia mode: %d\n", nParanoiaMode); }
	paranoia_modeset(pHandle->paranoia, nParanoiaMode);

	setHandle(env, obj, pHandle);
	if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia_open(): end\n"); }
	return 0;
}
Example #15
0
///析构函数
CwxAppHandler4UnixConn::~CwxAppHandler4UnixConn()
{
    if (getHandle() != CWX_INVALID_HANDLE)
    {
        ::close(getHandle());
        setHandle(CWX_INVALID_HANDLE);
    }
}
Example #16
0
// Subclasses a dialog item inside a dialog, usually used in combination with Dialog resources.
void Widget::attach( unsigned id ) {
	if ( !itsParent )
		throw DWTException("Can't attach a Widget without a parent...");
	HWND hWnd = ::GetDlgItem( itsParent->handle(), id );
	if ( !hWnd )
		throw Win32Exception("GetDlgItem failed.");
	setHandle(hWnd);
}
Example #17
0
Subscription<T>::Subscription(
	List<SubscriptionBase *> * list,
	const struct orb_metadata *meta, unsigned interval) :
	T(), // initialize data structure to zero
	SubscriptionBase(list, meta) {
	setHandle(orb_subscribe(getMeta()));
	orb_set_interval(getHandle(), interval);
}
Example #18
0
mxMenu::mxMenu ()
: mxWidget (0, 0, 0, 0, 0)
{
	void *handle = (void *) CreateMenu ();

	setHandle (handle);
	setType (MX_MENU);
}
SockDgram_AsyncOpeartion::SockDgram_AsyncOpeartion(SockDgram * pSockDgram): pOwnDevice_(pSockDgram)
{
	setAOPType(OSAL::AOP_TYPE_USER_CALLBACK);
	setHandle(pOwnDevice_->getHandle());
    
	incomingMsg_.len_ = pOwnDevice_->bufferLen_;
	incomingMsg_.pData_ = pOwnDevice_->pBuffer_;
}
Example #20
0
///析构函数
CwxAppHandler4Channel::~CwxAppHandler4Channel()
{
    clear();
    if (getHandle() != CWX_INVALID_HANDLE)
    {
        ::close(getHandle());
        setHandle(CWX_INVALID_HANDLE);
    }
}
JNIEXPORT jint JNICALL Java_org_dmlc_xgboost4j_wrapper_XgboostJNI_XGDMatrixCreateFromFile
  (JNIEnv *jenv, jclass jcls, jstring jfname, jint jsilent, jlongArray jout) {
    DMatrixHandle result;
    const char* fname = jenv->GetStringUTFChars(jfname, 0);
    int ret = XGDMatrixCreateFromFile(fname, jsilent, &result);
    if (fname) jenv->ReleaseStringUTFChars(jfname, fname);    
    setHandle(jenv, jout, result);
    return ret;
}
Example #22
0
DirectShowEventLoop::DirectShowEventLoop(QObject *parent)
    : QWinEventNotifier(parent)
    , m_postsHead(0)
    , m_postsTail(0)
    , m_eventHandle(::CreateEvent(0, 0, 0, 0))
    , m_waitHandle(::CreateEvent(0, 0, 0, 0))
{
    setHandle(m_eventHandle);
    setEnabled(true);
}
Example #23
0
//----------------------------------------------------------------------------------------------------
void UIColorSlider::setViewSize (const CRect& rect, bool invalid)
{
	bool different = rect != getViewSize ();
	CSlider::setViewSize (rect, invalid);
	if (different)
	{
		setHandle (0);
		setBackground (0);
	}
}
Example #24
0
bool WindowControl::DestroyThis()
{
	if ( getHandle() != NULL && DestroyWindow(getHandle()) == TRUE )
	{
		setHandle(NULL);
		defaultProc = NULL;
		return true;
	}
	else
		return false;
}
Example #25
0
		void Control::renew() {
			update();

			HWND handle = getHandle();
			if (handle != nullptr) {
				::DestroyWindow(handle);
				setHandle(nullptr);
			}

			refresh();
		}
Example #26
0
		void Control::refresh() {
			updated = false;

			HWND handle = getHandle();
			if (handle == nullptr) {
				handle = createHandle();
				setHandle(handle);
			}

			setAttributes(handle);
		}
Example #27
0
/*
 * Class:     com_thalmic_myo_Hub
 * Method:    initialize
 * Signature: (Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_com_thalmic_myo_Hub_initialize (JNIEnv *jenv, jobject thisObject, jstring applicationIdentifier) {
	setbuf(stdout, NULL);
	try {
		const char* mystring = jenv->GetStringUTFChars(applicationIdentifier, NULL);
		myo::Hub *hub = new myo::Hub(mystring);
		setHandle(jenv, thisObject, hub);
	} catch (const std::exception& e) {
		jclass exceptionClass = jenv->FindClass("java/lang/RuntimeException");
		jenv->ThrowNew(exceptionClass, e.what());
	}
}
/*
 * Class:     org_tritonus_lowlevel_esd_EsdRecordingStream
 * Method:    close
 * Signature: ()V
 */
JNIEXPORT void JNICALL
Java_org_tritonus_lowlevel_esd_EsdRecordingStream_close
(JNIEnv *env, jobject obj)
{
	int		nFd = -1;

	if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_esd_EsdRecordingStream_close(): begin\n"); }
	nFd = getHandle(env, obj);
	close(nFd);
	setHandle(env, obj, -1);
	if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_esd_EsdRecordingStream_close(): end\n"); }
}
Example #29
0
bool MdiClient::CreateMdiClient( HANDLE hWindowMenu, UINT idFirstChild, DWORD dwStyle,
                                 int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu )
{
    CLIENTCREATESTRUCT ccs;
    ccs.hWindowMenu  = hWindowMenu;
    ccs.idFirstChild = idFirstChild;

    setHandle(CreateWindow("MDICLIENT", NULL, dwStyle,
        X, Y, nWidth, nHeight, hWndParent, hMenu, GetModuleHandle(NULL), (LPVOID)&ccs));

    return getHandle() != NULL;
}
Example #30
0
/*
 * Class:     ml_dmlc_xgboost4j_java_XGBoostJNI
 * Method:    XGDMatrixCreateFromMat
 * Signature: ([FIIF)J
 */
JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixCreateFromMat
  (JNIEnv *jenv, jclass jcls, jfloatArray jdata, jint jnrow, jint jncol, jfloat jmiss, jlongArray jout) {
  DMatrixHandle result;
  jfloat* data = jenv->GetFloatArrayElements(jdata, 0);
  bst_ulong nrow = (bst_ulong)jnrow;
  bst_ulong ncol = (bst_ulong)jncol;
  int ret = (jint) XGDMatrixCreateFromMat((float const *)data, nrow, ncol, jmiss, &result);
  setHandle(jenv, jout, result);
  //release
  jenv->ReleaseFloatArrayElements(jdata, data, 0);
  return ret;
}