コード例 #1
0
ファイル: VcardForm.cpp プロジェクト: m8r-ds1twq/bombusng-qd
void VcardForm::onWmUserUpdate() {
    //std::string xml=*(vcard->toXML());
    //const std::string &xml2=XMLStringPrep(xml);
    //const std::wstring xml3=utf8::utf8_wchar(xml2);

    //SendMessage(hwndHTML, WM_SETTEXT, 0, (LPARAM)"");

    //img.reset();

	imgFile=appRootPath;// + L"userdata\\avatars\\" + L"$$$_tmp.jpg";

	if (savePhoto(imgFile.c_str())){
        //img=ImageRef(new Image(imgFile.c_str()));
		//Contact::ref contact = Contact::ref(new Contact(this->jid,"","","",""));
		//contact->img_avatar=img;
	}


    startHtml();
    addImg(L"\\vcard");
    beginForm("vcard-photo", "photo");
    if (img) if (img->getHBmp()) {
        button("save",std::string("Save")); 
        if (editForm) button("clear",std::string("Clear")); 
    }
    if (editForm) button("load",std::string("Load")); 
    addText("<BR>");
    endForm(); 

	//contact->img_avatar=img;
    

    beginForm("vcard-fields", "publish");

    addHtmlField("FN", NULL,        "Full Name", TXT);
    addHtmlField("NICKNAME", NULL,  "Nickname", TXT);
    addHtmlField("BDAY", NULL,      "Birthday", TXT);
    addHtmlField("ADR", "STREET",   "Street", TXT);
    addHtmlField("ADR", "EXTADR",   "Street2", TXT);
    addHtmlField("ADR", "LOCALITY", "City", TXT);
    addHtmlField("ADR", "REGION",   "State", TXT);
    addHtmlField("ADR", "PCODE",    "Post code", TXT);
    addHtmlField("ADR", "CTRY",     "Country", TXT);
    addHtmlField("TEL", "HOME",     "Home Phone Number", TXT);
    addHtmlField("TEL", "NUMBER",   "Phone Number", TXT);
    addHtmlField("EMAIL", "USERID", "E-Mail", URL);
    addHtmlField("TITLE", NULL,     "Position", TXT);
    addHtmlField("ROLE", NULL,      "Role", TXT);
    addHtmlField("ORG", "ORGNAME",  "Organization", TXT);
    addHtmlField("ORG", "ORGUNIT",  "Dept", TXT);
    addHtmlField("URL", NULL,       "Url", URL);
    addHtmlField("DESC", NULL,      "About", MULTILINE);

    if (editForm) button(std::string("Publish"));
    //button("reload",std::string("Reload")); 
    endForm();

    endHtml();
}
コード例 #2
0
ファイル: fsync-config.cpp プロジェクト: yangxq/fsync
void FsyncConfig::saveToFile(map<string, Photo*>& photos, PhotoSet* photoset) {
	xmlDocPtr doc = xmlNewDoc(NULL);

	//Root-photos
	xmlNodePtr root = xmlNewDocNode(doc, NULL, (xmlChar*) "photos", NULL);
	xmlDocSetRootElement(doc, root);

	savePhotoSet(root, photoset);

	map<string, Photo*>::iterator it;
	for (it = photos.begin(); it != photos.end(); it++) {
		Photo* photo = it->second;

		savePhoto(root, photo);
	}

	//Photo
	xmlSaveFormatFileEnc("flickr-sync.xml", doc, "UTF-8", 1);
}
コード例 #3
0
ファイル: VcardForm.cpp プロジェクト: m8r-ds1twq/bombusng-qd
void VcardForm::onHotSpot( LPCSTR url, LPCSTR param ) {
    std::string nurl=std::string(url);
    if (nurl=="load") {
        wchar_t filename[MAX_PATH];
        *filename=0;
        OPENFILENAME ofn;
        memset(&ofn, 0, sizeof(OPENFILENAME));
        ofn.lStructSize=sizeof(OPENFILENAME);
        ofn.hwndOwner=getHWnd();
        ofn.hInstance=g_hInst;
        ofn.lpstrFilter=FILEIMGMASK;
        ofn.nFilterIndex=0;
        ofn.lpstrFile=filename;
        ofn.nMaxFile=MAX_PATH;
        ofn.lpstrTitle=L"Select image file";
        ofn.Flags=OFN_FILEMUSTEXIST | OFN_EXPLORER;
        BOOL result=GetOpenFileNameEx(&ofn);
        if (!result) return;

        loadPhoto(filename);

        vcardArrivedNotify(vcard);
        return;
    }
    if (nurl=="save") {
        savePhoto(NULL);
        return;
    }
    if (nurl=="clear") {
        //todo: clear photo
        JabberDataBlockRef vcardTemp=vcard->findChildNamespace("vCard","vcard-temp");
        if (!vcardTemp) return;
        vcardTemp->removeChild("PHOTO");
        vcardArrivedNotify(vcard);
        return;
    }
    if (nurl=="reload") {
        //todo: re-request vcard
        return;
    }
    if (nurl=="publish") {
        //todo: publish vcard

        
        JabberDataBlockRef vcardTemp=vcard->findChildNamespace("vCard","vcard-temp");
        if (!vcardTemp) {
            vcardTemp=JabberDataBlockRef(new JabberDataBlock("vCard"));
            vcardTemp->setAttribute("xmlns","vcard-temp");
        }

        JabberDataBlock viq("iq");
        viq.setAttribute("to",vcard->getAttribute("from"));
        viq.setAttribute("type","set");
        viq.setAttribute("id","my-vcard-publish");
        viq.addChild(vcardTemp);

        StringMapRef m=HtmlView::splitHREFtext(param);
        for (StringMap::iterator i=m->begin(); i!=m->end(); i++) {
            std::string key=i->first;
            std::string value=i->second;
            std::string key2;
            int k2=key.find('#');
            if (k2>0) {
                key2=key.substr(k2+1, key.length()-k2-1);
                key=key.substr(0, k2);
            }

            JabberDataBlockRef child=vcardTemp->getChildByName(key.c_str());
            if (!child) child=vcardTemp->addChild(key.c_str(), NULL);
            if (k2>0) {
                JabberDataBlockRef child2=child->getChildByName(key2.c_str());
                if (!child2) child2=child->addChild(key2.c_str(), NULL);
                child=child2;
            }
            child->setText(value);
        }

        /*if (img) if (img->getHBmp()) {
            std::wstring imgFile=appRootPath+L"$tmpimg.jpg";
            loadPhoto(imgFile.c_str());
        }*/

        //StringRef result=viq->toXML();

        //todo: verify result
        rc.lock()->jabberStream->sendStanza(viq);
        
        vcardArrivedNotify(vcard);
        return;
    }

}
コード例 #4
0
ファイル: rcam.c プロジェクト: YamSoup/pistereocam
void *initLocalCamera(void *VoidPtrArgs)
{
  struct cameraControl *currentArgs = VoidPtrArgs;

  pthread_mutex_lock(&currentArgs->mutexPtr);
  ILCLIENT_T *client = currentArgs->client;
  pthread_mutex_unlock(&currentArgs->mutexPtr);

  //////////////////
  //VARIABLES

  COMPONENT_T *camera = NULL, *video_render = NULL, *image_encode = NULL;
  COMPONENT_T *component_list[3] = {camera, video_render, image_encode};
  COMPONENT_T *image_encode_list[1] = {image_encode}; //needed to destroy component?
  OMX_ERRORTYPE OMXstatus;

  TUNNEL_T tunnel_camera_to_render, tunnel_camera_to_encode;
  memset(&tunnel_camera_to_render, 0, sizeof(tunnel_camera_to_render));
  memset(&tunnel_camera_to_encode, 0, sizeof(tunnel_camera_to_encode));

  //////////////////
  // STARTUP

  //////////////////
  // Initalize Components

  //////////////////
  ////initialise camera

  ilclient_create_component(client,
			    &camera,
			    "camera",
			    ILCLIENT_DISABLE_ALL_PORTS);

  OMXstatus = ilclient_change_component_state(camera, OMX_StateIdle);
  if (OMXstatus != OMX_ErrorNone)
    {
      fprintf(stderr, "unable to move camera component to Idle (1)");
      exit(EXIT_FAILURE);
    }

  //change the capture resolution
  setCaptureRes(camera, currentArgs->photoWidth, currentArgs->photoHeight);

  //change the preview resolution
  setPreviewRes(camera, currentArgs->previewWidth, currentArgs->previewHeight, currentArgs->previewFramerate);

  //////////////////
  ////Initialise video render
  
  ilclient_create_component(client,
			    &video_render,
			    "video_render",
			    ILCLIENT_DISABLE_ALL_PORTS
			    );

  OMXstatus = ilclient_change_component_state(video_render, OMX_StateIdle);
  if (OMXstatus != OMX_ErrorNone)
    {
      fprintf(stderr, "unable to move render component to Idle (1)\n");
      exit(EXIT_FAILURE);
    }

  setRenderConfig(video_render, currentArgs->displayType);

  ////////////////////
  ////Initalise Image Encoder

  ilclient_create_component(client,
			    &image_encode,
			    "image_encode",
			    ILCLIENT_DISABLE_ALL_PORTS
			    /*| ILCLIENT_ENABLE_INPUT_BUFFERS*/
			    | ILCLIENT_ENABLE_OUTPUT_BUFFERS);

  OMXstatus = ilclient_change_component_state(image_encode, OMX_StateIdle);
  if (OMXstatus != OMX_ErrorNone)
    {
      fprintf(stderr, "unable to move image encode component to Idle (1)\n");
      exit(EXIT_FAILURE);
    }

  //image format Param set
  setParamImageFormat(image_encode, JPEG_HIGH_FORMAT);

  ////////////////////
  // enable components and tunnels

  //setup tunnel of camera preview to renderer
  set_tunnel(&tunnel_camera_to_render, camera, 70, video_render, 90);
  ilclient_setup_tunnel(&tunnel_camera_to_render, 0, 0);

  // change camera component to executing
  OMXstatus = ilclient_change_component_state(camera, OMX_StateExecuting);
  if (OMXstatus != OMX_ErrorNone)
    {
      fprintf(stderr, "unable to move camera component to Executing (1)\n");
      exit(EXIT_FAILURE);
    }

  //change preview render to executing
  OMXstatus = ilclient_change_component_state(video_render, OMX_StateExecuting);
  if (OMXstatus != OMX_ErrorNone)
    {
      fprintf(stderr, "unable to move video render component to Executing (1)\n");
      exit(EXIT_FAILURE);
    }

  //enable port and buffers for output port of image encode
  ilclient_enable_port_buffers(image_encode, 341, NULL, NULL, NULL);
  ilclient_enable_port(image_encode, 341);
  
  //setup tunnel from camera image port too image encode
  set_tunnel(&tunnel_camera_to_encode, camera, 72, image_encode, 340);
  ilclient_setup_tunnel(&tunnel_camera_to_encode, 0, 0);

  //change image_encode to executing
  OMXstatus = ilclient_change_component_state(image_encode, OMX_StateExecuting);
  if (OMXstatus != OMX_ErrorNone)
    {
      fprintf(stderr, "unable to move image_encode component to Executing (1) Error = %s\n", err2str(OMXstatus));
      exit(EXIT_FAILURE);
    }

  /////////////////
  // Main initLocalCamera() Loop

  while(1)
    {
      pthread_mutex_lock(&currentArgs->mutexPtr);
      if (currentArgs->previewChanged == true)
	{
	  //working
	  ilclient_disable_tunnel(&tunnel_camera_to_render);
	  OMXstatus = ilclient_change_component_state(camera, OMX_StatePause);
	  setPreviewRes(camera,
			currentArgs->previewWidth,
			currentArgs->previewHeight,
			currentArgs->previewFramerate);
	  OMXstatus = ilclient_change_component_state(camera, OMX_StateExecuting);
  	  ilclient_enable_tunnel(&tunnel_camera_to_render);
	  currentArgs->previewChanged = false;
	}
      else if (currentArgs->photoChanged == true)
	{
	  //NOT WORKING? CANT GET WORKING!!
	  //TUNNEL_T *tunnel_ptr = &tunnel_camera_to_encode;
	  ilclient_disable_tunnel(&tunnel_camera_to_encode);
	  ilclient_flush_tunnels(&tunnel_camera_to_encode, 30);
	  //ilclient_teardown_tunnels(&tunnel_camera_to_encode);
	  //printf("teardown done");
	  setCaptureRes(camera, currentArgs->photoWidth, currentArgs->photoHeight);
	  // DESTROY image encode and recreate (appears to be the only way)
	  //destory
	  
	  OMXstatus = ilclient_change_component_state(image_encode, OMX_StateIdle);
	  OMXstatus = ilclient_change_component_state(image_encode, OMX_StateLoaded);
	  //OMX_FreeHandle(ilclient_get_handle(image_encode));
	  ilclient_cleanup_components(image_encode_list);
	  printf("managed to free the image_encode handle");
	  image_encode = NULL;
	  
	  //recreate
	  ilclient_create_component(client,
				    &image_encode,
				    "image_encode",
				    ILCLIENT_DISABLE_ALL_PORTS
				    /*| ILCLIENT_ENABLE_INPUT_BUFFERS*/
				    | ILCLIENT_ENABLE_OUTPUT_BUFFERS);

	  OMXstatus = ilclient_change_component_state(image_encode, OMX_StateIdle);
	  if (OMXstatus != OMX_ErrorNone)
	    {
	      fprintf(stderr, "unable to move image encode component to Idle (1)\n");
	      exit(EXIT_FAILURE);
	    }

	  //image format Param set
	  setParamImageFormat(image_encode, JPEG_HIGH_FORMAT);

	  //OMXstatus = ilclient_change_component_state(camera, OMX_StateExecuting);
	  ilclient_enable_tunnel(&tunnel_camera_to_encode);
	  	  
	  currentArgs->photoChanged = false;
	}
      else if (currentArgs->displayChanged == true)
	{
	  //working
	  setRenderConfig(video_render, currentArgs->displayType);
	  currentArgs->displayChanged = false;
	}
      else if (currentArgs->takePhoto == true)
	{
	  //working
	  savePhoto(camera, image_encode, "/home/pi/Desktop/photo_", "_L.jpg");	  
	  currentArgs->takePhoto = false;
	}
      //loop termination
      else if (currentArgs->rcamDeInit == true)
	{
	  //working
	  printf("~~~~~ End local camera ~~~~~\n");
	  break;
	}
      pthread_mutex_unlock(&currentArgs->mutexPtr);
      usleep(500);
    }

  ///////////////
  //CLEANUP

  // Teardown tunnels
  ilclient_disable_tunnel(&tunnel_camera_to_render);
  ilclient_disable_tunnel(&tunnel_camera_to_encode);
  
  ilclient_teardown_tunnels(&tunnel_camera_to_render);
  ilclient_teardown_tunnels(&tunnel_camera_to_encode);
  
  // Disable components
  ilclient_cleanup_components(component_list);


  //Destroy ilclient
  // dont do for local as its done in main program
  //ilclient_destroy(currentArgs->client)
  
  //unlock mutex before teminating
  pthread_mutex_unlock(&currentArgs->mutexPtr);
    
  //call pthread_exit so caller can join
  pthread_exit(NULL);
}