Ejemplo n.º 1
0
bool
GtkAReViWidget::getWidgetString(const StlString &propName,StlString &propValueOut)
{
  GtkWidget *widget=glade_xml_get_widget(_xmlObject,propName.c_str());
  if (!widget)
  {
    cerr << "[getPropertyString] property '" << propName << "' no exist" << endl;
    return false;
  }

  if (GTK_IS_ENTRY(widget))
    propValueOut=/*strFromUTF8*/(gtk_entry_get_text(GTK_ENTRY(widget)));
  else if (GTK_IS_TOGGLE_BUTTON(widget))
  {
    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) propValueOut="true";
    else propValueOut="false";
  }
  else if (GTK_IS_TEXT_VIEW(widget))
  {
    GtkTextBuffer* buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget));
    GtkTextIter start, end;
    gtk_text_buffer_get_bounds(buffer,&start,&end);
    propValueOut=/*strFromUTF8*/(gtk_text_buffer_get_text(buffer,&start,&end,true));
  }
  else return false;

  return true;
}
Ejemplo n.º 2
0
 URLSound3D::URLSound3D(StlString const &url) :
     _gain(0),
     _attenuated(false)
 {
     buffer = LoadSound(url.c_str());
     alGenSources(1, &source);
     alSourcei(source, AL_BUFFER, buffer);
 }
Ejemplo n.º 3
0
bool IsValidFolder(StlString folder_name)
{
	bool ret_val;
	TCHAR curr_dir[MAX_PATH];
	GetCurrentDirectory(MAX_PATH, curr_dir);
	ret_val = (FALSE != SetCurrentDirectory(folder_name.c_str()));
	SetCurrentDirectory(curr_dir);
	return ret_val;	
}
void
UDPKinectSkeleton::_writeStringOSC(const StlString & value,
                                   ArRef<AbstractOStream> stream)
{
unsigned int modulo = 4+4*(value.size()/4)-value.size();
//cout<<"size "<<value.size()<<" Modulo "<<modulo<<endl;
//cout<<"Write string OSC [";
for (unsigned int i(0);i<value.size();++i)
  { 
  stream->writeChar(value[i]);
  //cout<<value[i];
  }
for (unsigned int i(0);i<modulo;++i)
  { 
  //cout<<"0";
  stream->writeChar(0);
  }
//cout<<"]"<<endl;
}
Ejemplo n.º 5
0
//-------- Construction / Destruction ----------------------------------------
GtkAReViWidget::GtkAReViWidget(ArCW & arCW,
                               const StlString &fileName,
                               const StlString &mainWidget) // Protected
: ArObject(arCW),
  _xmlObject(glade_xml_new(fileName.c_str(),  mainWidget.c_str(), NULL)),
  _wndMain(NULL),
  _hideOnDestroy(false),
  _dockDst(),
  _dockDstWidget(""),
  _wndDockSrc(NULL),
  _docked(false) {
  if(_xmlObject) {
    _wndMain=GTK_WIDGET(glade_xml_get_widget(_xmlObject,mainWidget.c_str()));
    if (!_wndMain)
      setErrorMessage("Can't find main widget " + mainWidget);
    else
      g_signal_connect ((gpointer)_wndMain,"delete_event",G_CALLBACK(_onWidgetCloseCB),this);
  }
  else
    thisRef().destroy();
}
Ejemplo n.º 6
0
static bool IsPartOfMultipartArchive(const StlString& fname)
{
	StlString fname_nopath;
	size_t last_slash_pos = fname.find_last_of(_T('\\'));
	if (fname.size() == last_slash_pos)
	{
		LOG(("[IsPartOfMultipartArchive] ERROR: wrong file name: %S\n", 
			(wstring(fname.begin(), fname.end())).c_str()));
		return false;
	}
	fname_nopath = (StlString::npos == last_slash_pos) ? fname : fname.substr(last_slash_pos + 1);

	boost::tregex re(_T("(.*)(\\.part)([0-9]+)(\\.rar)"), 
		boost::tregex::perl|boost::tregex::icase); 


	bool ret_val = false;

	if (boost::regex_match(fname_nopath, re))
	{
		size_t pos;
		pos = fname_nopath.find_last_of(_T('.'));
		if (StlString::npos != pos)
		{
			StlString tmp = fname_nopath.substr(0, pos);
			pos = tmp.find_last_of(_T(".part"));
			if (StlString::npos != pos && pos < tmp.size() - 1)
			{
				tmp = tmp.substr(pos + 1);
				int part_num = _ttoi(tmp.c_str());
				
				ret_val = (part_num != 1);
			}
		}
	}

	return ret_val;
}
Ejemplo n.º 7
0
bool
GtkAReViWidget::setWidgetString(const StlString &propName,const StlString &propValue)
{
  GtkWidget *widget=glade_xml_get_widget(_xmlObject,propName.c_str());
  if (!widget)
  {
    cerr << "[setPropertyString] property '" << propName << "' no exist" << endl;
    return false;
  }
  if (GTK_IS_ENTRY(widget))
    gtk_entry_set_text(GTK_ENTRY(widget),/*strToUTF8*/(propValue).c_str());
  else if (GTK_IS_TOGGLE_BUTTON(widget))
  {
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),propValue=="true");
  }
  else if (GTK_IS_TEXT_VIEW(widget))
  {
    GtkTextBuffer* buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget));
    gtk_text_buffer_set_text(buffer,/*strToUTF8*/(propValue).c_str(),-1);
  }
  else return false;

  return true;
}
Ejemplo n.º 8
0
    Sound3DPlayer::Sound3DPlayer(StlVector<StlString> const * params)
    {
        //Sound3D::_initSuccess=false;
        StlString openArgs;
        if(params&&!params->empty())
        {
            for(unsigned int i = 0; i < params->size(); i++)
            {
                if(i) openArgs+=" ";
                openArgs += (*params)[i];
            }
            openArgs = "'( ( devices '( " + openArgs + " ) ) )";
            device = alcOpenDevice(openArgs.c_str());
        }

        if(!device)
        {
            device = alcOpenDevice(NULL);
            if(!device)
            {
                cerr << "ERROR: Sound3DPlayer init: unable to open sound3D device !!!" << endl;
                //return(false);
                return;
            }
        }

        globalContext = alcCreateContext(device, NULL);

        if(!globalContext)
        {
            alcCloseDevice(device);
            globalContext = NULL;
            cerr << "ERROR: Sound3DPlayer init: unable to create al context !!!" << endl;
            //return(false);
            return;
        }

        if(alcMakeContextCurrent(globalContext) == ALC_FALSE)
        {
            alcDestroyContext(globalContext);
            alcCloseDevice(device);
            cerr << "ERROR: Sound3DPlayer init: unable to make context current !!!" << endl;
            return;
        }

        if(!alcIsExtensionPresent(alcGetContextsDevice(alcGetCurrentContext()), "ALC_EXT_EFX"))
        {
            alcDestroyContext(globalContext);
            alcCloseDevice(device);
            cerr << "ERROR: Sound3DPlayer init: EFX not supported" << endl;
            return;
        }

#if defined(AL_SOFT_buffer_samples) && AL_SOFT_buffer_samples
        if(alIsExtensionPresent("AL_SOFT_buffer_samples"))
        {
            alIsBufferFormatSupportedSOFT = (LPALISBUFFERFORMATSUPPORTEDSOFT)alGetProcAddress("alIsBufferFormatSupportedSOFT");
            alBufferSamplesSOFT = (LPALBUFFERSAMPLESSOFT)alGetProcAddress("alBufferSamplesSOFT");
        }
#endif

        alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
        //alDistanceModel(AL_EXPONENT_DISTANCE_CLAMPED);

        cout << "Sound3DPlayer Opened \"" << alcGetString(device, ALC_DEVICE_SPECIFIER) << "\"" << endl;
#if 0
        cout << "AL_DOPPLER_FACTOR: " << alGetDouble(AL_DOPPLER_FACTOR) << endl;
        cout << "AL_SPEED_OF_SOUND: " << alGetDouble(AL_SPEED_OF_SOUND) << endl;
        cout << "AL_DISTANCE_MODEL: " << alGetInteger(AL_DISTANCE_MODEL) << endl;
#endif
    }
Ejemplo n.º 9
0
bool Downloader::CheckMd5(const std::string& url, const StlString& file_name)
{
	FileDescriptorList::iterator file_desc_iter = FindDescriptor(url);
	if (file_desc_iter == file_desc_list_.end())
	{
		LOG(("[CheckMd5] ERROR: File descriptor not found for URL %s\n", url.c_str()));
		return false;
	}

	HANDLE file_handle = OpenOrCreate(file_name, GENERIC_READ);
	if (INVALID_HANDLE_VALUE == file_handle)
	{
		LOG(("[CheckMd5] ERROR: Could not open file: %S\n", 
			std::wstring(file_name.begin(), file_name.end()).c_str()));
		return false;
	}

	MD5 file_md5;
	file_md5.reset();

	bool ret_val = true;

	vector <BYTE> buf;

	const unsigned int BUF_SIZE = 1024 * 1024;
	buf.resize(BUF_SIZE);

	ULARGE_INTEGER offset, size;
	size.LowPart = GetFileSize(file_handle, &size.HighPart);
	list<string>::iterator md5_iter = file_desc_iter->md5_list_.begin();
	for (offset.QuadPart = 0; offset.QuadPart < size.QuadPart; 
								offset.QuadPart += PART_SIZE, md5_iter++) 
	{
		DWORD read_size;

		MD5 part_md5;
		part_md5.reset();

		ULONG64 pos = 0;
		do {
			if (ReadFile(file_handle, &buf[0], BUF_SIZE, &read_size, NULL))
			{
				LOG(("Read OK, pos=0x%llx, read_size=0x%x\n", pos, read_size));
				file_md5.append(&buf[0], read_size);
				part_md5.append(&buf[0], read_size);

				pos += read_size;

				if (pos == PART_SIZE || read_size != BUF_SIZE)
				{
					part_md5.finish();
					string md5_str = part_md5.getFingerprint();
					if (md5_str != *md5_iter)
					{
						// MD5 is wrong
						ret_val = false;
						goto __end;
					}
					break;
				}
			}
			else
			{
				ret_val = false;
				goto __end;
			}
		} while (read_size == BUF_SIZE);

		if (distance(md5_iter, file_desc_iter->md5_list_.end()) == 1)
		{
			// MD5 list is too short
			ret_val = false;
			goto __end;
		}
	}

	file_md5.finish();

	if (ret_val && md5_iter != file_desc_iter->md5_list_.end())
	{
		// Check total MD5
		if (file_md5.getFingerprint() != *md5_iter)
			ret_val = false;
	}
__end:
	CloseHandle(file_handle);

	return ret_val;
}