Ejemplo n.º 1
0
bool sHotKeyOpts::Write(Setting& cProfile)
{
	Setting* s;
	std::string hk("Start");
	if(cProfile.exists(hk)) {
		s = &(cProfile[hk]);
	} else
		s = &(cProfile.add(hk, Setting::TypeGroup));
	UpdateSetting(*s, "Key", (int&)m_RecordStart.m_vKey, Setting::TypeInt);
	UpdateSetting(*s, "Mod", (int&)m_RecordStart.m_fsMod, Setting::TypeInt);

	hk = "End";
	if(cProfile.exists(hk)) {
		s = &(cProfile[hk]);
	} else
		s = &(cProfile.add(hk, Setting::TypeGroup));
	UpdateSetting(*s, "Key", (int&)m_RecordEnd.m_vKey, Setting::TypeInt);
	UpdateSetting(*s, "Mod", (int&)m_RecordEnd.m_fsMod, Setting::TypeInt);

	hk = "Cancel";
	if(cProfile.exists(hk)) {
		s = &(cProfile[hk]);
	} else
		s = &(cProfile.add(hk, Setting::TypeGroup));
	UpdateSetting(*s, "Key", (int&)m_RecordCancel.m_vKey, Setting::TypeInt);
	UpdateSetting(*s, "Mod", (int&)m_RecordCancel.m_fsMod, Setting::TypeInt);

	hk = "Next";
	if(cProfile.exists(hk)) {
		s = &(cProfile[hk]);
	} else
		s = &(cProfile.add(hk, Setting::TypeGroup));
	UpdateSetting(*s, "Key", (int&)m_Next.m_vKey, Setting::TypeInt);
	UpdateSetting(*s, "Mod", (int&)m_Next.m_fsMod, Setting::TypeInt);

	hk = "Prev";
	if(cProfile.exists(hk)) {
		s = &(cProfile[hk]);
	} else
		s = &(cProfile.add(hk, Setting::TypeGroup));
	UpdateSetting(*s, "Key", (int&)m_Prev.m_vKey, Setting::TypeInt);
	UpdateSetting(*s, "Mod", (int&)m_Prev.m_fsMod, Setting::TypeInt);

	hk = "Layout";
	if(cProfile.exists(hk)) {
		s = &(cProfile[hk]);
	} else
		s = &(cProfile.add(hk, Setting::TypeGroup));
	UpdateSetting(*s, "Key", (int&)m_ShowLayout.m_vKey, Setting::TypeInt);
	UpdateSetting(*s, "Mod", (int&)m_ShowLayout.m_fsMod, Setting::TypeInt);

	hk = "Zoom";
	if(cProfile.exists(hk)) {
		s = &(cProfile[hk]);
	} else
		s = &(cProfile.add(hk, Setting::TypeGroup));
	UpdateSetting(*s, "Key", (int&)m_Zoom.m_vKey, Setting::TypeInt);
	UpdateSetting(*s, "Mod", (int&)m_Zoom.m_fsMod, Setting::TypeInt);
	return true;
}
Ejemplo n.º 2
0
void cMenuDirSelect::AddDistinct(const char* szText)
{
    int iLevel = Level(szText);
    MaxLevel = max(MaxLevel, iLevel);

    if (iLevel > CurLevel) // only show Items of the specified level, except those with vars
	return;

    for(int i=0; i<Count(); i++)
    {
	const char* ItemText = Get(i)->Text();
	char* itemtext = strdup(ItemText);
	char* sztext = strdup(szText);
	ToLower(itemtext);
	ToLower(sztext);
	if (itemtext && strlen(itemtext) > 0 && strcmp(sztext, itemtext) == 0)
	{
	    free(itemtext);
	    free(sztext);
	    return;
	}
	free(itemtext);
	free(sztext);
    }
    Add(new cMenuDirItem(hk(szText)));
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    CHotKeyEventFilter hk(w.winId());
    a.installNativeEventFilter(&hk);


    QObject::connect(&hk, &CHotKeyEventFilter::HotKeyTrigger, &w, &Widget::HotKeyTriggered);
    w.show();
    return a.exec();
}
int main() {
	iofast;
	
	cin>>n>>m>>p;

	for(i=0; i<p; i++) {
		cin>>j>>k;
		w[j-1].pb(k-1);
	}

	cout<<hk();
}
Ejemplo n.º 5
0
bool sHotKeyOpts::Read(Setting& cProfile)
{
	std::string hk("Start");
	if(cProfile.exists(hk)) {
		const Setting& s = cProfile[hk];
		s.lookupValue("Key", m_RecordStart.m_vKey);
		s.lookupValue("Mod", m_RecordStart.m_fsMod);
	}
	hk = "End";
	if(cProfile.exists(hk)) {
		const Setting& s = cProfile[hk];
		s.lookupValue("Key", m_RecordEnd.m_vKey);
		s.lookupValue("Mod", m_RecordEnd.m_fsMod);
	}
	hk = "Cancel";
	if(cProfile.exists(hk)) {
		const Setting& s = cProfile[hk];
		s.lookupValue("Key", m_RecordCancel.m_vKey);
		s.lookupValue("Mod", m_RecordCancel.m_fsMod);
	}
	hk = "Next";
	if(cProfile.exists(hk)) {
		const Setting& s = cProfile[hk];
		s.lookupValue("Key", m_Next.m_vKey);
		s.lookupValue("Mod", m_Next.m_fsMod);
	}
	hk = "Prev";
	if(cProfile.exists(hk)) {
		const Setting& s = cProfile[hk];
		s.lookupValue("Key", m_Prev.m_vKey);
		s.lookupValue("Mod", m_Prev.m_fsMod);
	}
	hk = "Layout";
	if(cProfile.exists(hk)) {
		const Setting& s = cProfile[hk];
		s.lookupValue("Key", m_ShowLayout.m_vKey);
		s.lookupValue("Mod", m_ShowLayout.m_fsMod);
	}
	hk = "Zoom";
	if(cProfile.exists(hk)) {
		const Setting& s = cProfile[hk];
		s.lookupValue("Key", m_Zoom.m_vKey);
		s.lookupValue("Mod", m_Zoom.m_fsMod);
	}
	bool pass = false;
	cProfile.lookupValue("PassThrough", pass);
	setPassThrough(pass); // see hook.cpp
	return true;
}
Ejemplo n.º 6
0
	int Ardb::GetValueByPattern(const DBID& db, const Slice& pattern,
	        ValueObject& subst, ValueObject& value)
	{
		const char *p, *f;
		const char* spat;
		/* If the pattern is "#" return the substitution object itself in order
		 * to implement the "SORT ... GET #" feature. */
		spat = pattern.data();
		if (spat[0] == '#' && spat[1] == '\0')
		{
			value = subst;
			return 0;
		}

		/* If we can't find '*' in the pattern we return NULL as to GET a
		 * fixed key does not make sense. */
		p = strchr(spat, '*');
		if (!p)
		{
			return -1;
		}

		f = strstr(spat, "->");
		if (NULL != f && (uint32)(f - spat) == (pattern.size() - 2))
		{
			f = NULL;
		}
		std::string vstr;
		subst.ToString(vstr);
		std::string keystr(pattern.data(), pattern.size());
		string_replace(keystr, "*", vstr);
		if (f == NULL)
		{
			KeyObject k(keystr, KV, db);
			return GetValue(k, &value);
		}
		else
		{
			size_t pos = keystr.find("->");
			std::string field = keystr.substr(pos + 2);
			keystr = keystr.substr(0, pos);
			HashKeyObject hk(keystr, field, db);
			return GetValue(hk, &value);
		}
	}
Ejemplo n.º 7
0
	int Ardb::Type(const DBID& db, const Slice& key)
	{
		if (GetValue(db, key, NULL) == 0)
		{
			return KV;
		}
		int type = -1;
		Slice empty;
		KeyObject sk(key, SET_META, db);
		if (0 == GetValue(sk, NULL))
		{
			return SET_ELEMENT;
		}
		KeyObject lk(key, LIST_META, db);
		if (0 == GetValue(lk, NULL))
		{
			return LIST_META;
		}
		KeyObject zk(key, ZSET_META, db);
		if (0 == GetValue(zk, NULL))
		{
			return ZSET_ELEMENT_SCORE;
		}

		HashKeyObject hk(key, empty, db);
		GET_KEY_TYPE(hk, type);
		if (type > 0)
		{
			return type;
		}
		KeyObject tk(key, TABLE_META, db);
		if (0 == GetValue(tk, NULL))
		{
			return TABLE_META;
		}
		KeyObject bk(key, BITSET_META, db);
		if (0 == GetValue(bk, NULL))
		{
			return BITSET_META;
		}
		return -1;
	}
Ejemplo n.º 8
0
void cMenuEPGSearchSetup::Set()
{
  int current = Current();
  Clear();
  SetStatus(tr("Use 'OK Button' for opening and closing menus"));
  SetHasHotkeys();
  Add(new cOsdItem(hk(tr("General")),                 osUser1));
  Add(new cOsdItem(hk(tr("EPG menus")),               osUser2));
  Add(new cOsdItem(hk(tr("User-defined EPG times")),  osUser3));
  Add(new cOsdItem(hk(tr("Timer programming")),       osUser4));
  Add(new cOsdItem(hk(tr("Search and search timers")),osUser5));
  Add(new cOsdItem(hk(tr("Timer conflict checking")), osUser6));

  SetCurrent(Get(current));
  Display();
}
Ejemplo n.º 9
0
	int Ardb::Type(const DBID& db, const Slice& key)
	{
		if (Exists(db, key))
		{
			return KV;
		}
		int type = -1;
		Slice empty;
		SetKeyObject sk(key, empty, db);
		GET_KEY_TYPE(sk, type);
		if (type < 0)
		{
			ZSetScoreKeyObject zk(key, empty, db);
			GET_KEY_TYPE( zk, type);
			if (type < 0)
			{
				HashKeyObject hk(key, empty, db);
				GET_KEY_TYPE( hk, type);
				if (type < 0)
				{
					KeyObject lk(key, LIST_META, db);
					GET_KEY_TYPE( lk, type);
					if (type < 0)
					{
						KeyObject tk(key, TABLE_META, db);
						GET_KEY_TYPE(tk, type);
						if (type < 0)
						{
							KeyObject bk(key, BITSET_META, db);
							GET_KEY_TYPE(bk, type);
						}
					}
				}
			}
		}
		return type;
	}
Ejemplo n.º 10
0
cCMDMenu::cCMDMenu(cMainMenuItem *item, cMainMenu *osdobject)
  : cOsdMenu(tr("Commands"))
{
  iItem = item;
  OsdObject = osdobject;
  cOsdItem *mItem = NULL;

  SetHasHotkeys();

  if (iItem)
     MYDEBUG ("cMainMenu  FileName %s ItemType %d ", iItem->FileName(), iItem->Type());
  else
     MYDEBUG ("cMainMenu  no valid Item");

  //Add(new cOsdItem(hk(tr("Directory management"))));

  Add(new cOsdItem(hk(tr("Burn image"))));
  if(!iItem || (iItem && iItem->Type() != iDVD))
  {
	  mItem = Last();
	  mItem->SetSelectable(false);
  }

  Add(new cOsdItem(hk(tr("Rename image"))));
  if(!iItem || (iItem && iItem->Type() != iDVD))
  {
    mItem = Last();
    mItem->SetSelectable(false);
  }

  Add(new cOsdItem(hk(tr("Open DVD-tray"))));
#ifdef RBLITE
  Add(new cOsdItem(hk(tr("Close DVD-tray"))));
#endif
  /*Add(new cOsdItem(tr("Play")));
  if(!iItem
     || (iItem && iItem->Type() != iDVD && iItem->Type() != iDevice && iItem->Type()
         != iDataBase))
  {
    mItem = Last();
    mItem->SetSelectable(false);
  }
  */

  Add(new cOsdItem(hk(tr("Delete cache"))));
  Add(new cOsdItem(hk(tr("Format DVD-RW"))));

 /* Add(new cOsdItem(tr("Move image")));
  if(!iItem || (iItem && iItem->Type() != iDVD))
  {
    mItem = Last();
    mItem->SetSelectable(false);
  }
*/
/*
  Add(new cOsdItem(tr("Delete Image")));
  if(!iItem || (iItem && iItem->Type() != iDVD))
  {
    mItem = Last();
    mItem->SetSelectable(false);
  }
  Add(new cOsdItem(tr("Burn Image")));
  if(!iItem || (iItem && iItem->Type() != iDVD))
  {
    mItem = Last();
    mItem->SetSelectable(false);
  }
  Add(new cOsdItem(tr("Read DVD")));
*/
  Display();
}
Ejemplo n.º 11
0
void run( const int N, const int M, const int L, const int hyper_threads, const int vector_lanes,
                  const int nx, const int ny, const int nz, const int ichunk,
                  const int nang, const int noct, const int ng, const int nmom, const int cmom,
                  const vector<diag_c>& diag )
{
  
	typedef typename Kokkos::DefaultExecutionSpace device_t;
	typedef TeamPolicy<device_t> team_policy_t;
	typedef View<double*, device_t> view_1d_t;
	typedef View<double**, Kokkos::LayoutLeft, device_t> view_2d_t;
	typedef View<double***, Kokkos::LayoutLeft, device_t> view_3d_t;
	typedef View<double****, Kokkos::LayoutLeft, device_t> view_4d_t;
	typedef View<double*****, Kokkos::LayoutLeft, device_t> view_5d_t;
	typedef View<double******, Kokkos::LayoutLeft, device_t> view_6d_t;
	typedef View<double*******, Kokkos::LayoutLeft, device_t> view_7d_t;


	int id = 1;
	int ich = 1;
	int jlo = 0;
	int jhi = ny-1;
	int jst = 1;
	int jd = 2;
	int klo = 0;
	int khi = nz-1;
	int kst = 1;
	int kd = 2;
	double hi = c1;
	
	Kokkos::initialize();
	Kokkos::DefaultExecutionSpace::print_configuration(cout);
	
	view_4d_t psii( "psii", nang, ny, nz, ng );
	view_4d_t psij( "psij", nang, ichunk, nz, ng );
	view_4d_t psik( "psik", nang, ichunk, ny, ng );
	view_4d_t jb_in( "jb_in", nang, ichunk, ny, ng ); // jb_in(nang,ichunk,nz,ng)
	view_4d_t kb_in( "kb_in", nang, ichunk, ny, ng ); // kb_in(nang,ichunk,nz,ng)
	view_6d_t qim( "qim", nang, nx, ny, nz, noct, ng ); // qim(nang,nx,ny,nz,noct,ng)
  view_5d_t qtot( "qtot", cmom, nx, ny, nx, ng ); // qtot(cmom,nx,ny,nz,ng)
	view_2d_t ec( "ec", nang, cmom ); // ec(nang,cmom)
	view_1d_t mu( "mu", nang ); // mu(nang)
	view_1d_t w( "w", nang ); // w(nang)
	view_1d_t wmu( "wmu", nang ); // wmu(nang)
	view_1d_t weta( "weta", nang ); // weta(nang)
	view_1d_t wxi( "wxi", nang ); // wxi(nang)
	view_1d_t hj( "hj", nang ); // hj(nang)
	view_1d_t hk( "hk", nang ); // hk(nang)
	view_1d_t vdelt( "vdelt", ng ); // vdelt(ng)
	view_6d_t ptr_in( "ptr_in", nang, nx, ny, nz, noct, ng ); // ptr_in(nang,nx,ny,nz,noct,ng)
	view_6d_t ptr_out( "ptr_out", nang, nx, ny, nz, noct, ng ); // ptr_out(nang,nx,ny,nz,noct,ng)
	view_4d_t flux( "flux", nx, ny, nz, ng ); // flux(nx,ny,nz,ng)
	view_5d_t fluxm( "fluxm", cmom-1, nx, ny, nz, ng ); //fluxm(cmom-1,nx,ny,nz,ng)
	view_2d_t psi( "psi", nang, M );
	view_2d_t pc( "pc", nang, M );
	view_4d_t jb_out( "jb_out", nang, ichunk, nz, ng );
	view_4d_t kb_out( "kb_out", nang, ichunk, ny, ng );
	view_4d_t flkx( "flkx", nx+1, ny, nz, ng );
	view_4d_t flky( "flky", nx, ny+1, nz, ng );
	view_4d_t flkz( "flkz", nx, ny, nz+1, ng );
  view_3d_t hv( "hv", nang, 4, M ); // hv(nang,4,M)
  view_3d_t fxhv( "fxhv", nang, 4, M ); // fxhv(nang,4,M)
  view_5d_t dinv( "dinv", nang, nx, ny, nz, ng ); // dinv(nang,nx,ny,nz,ng)
  view_2d_t den( "den", nang, M ); // den(nang,M)
  view_4d_t t_xs( "t_xs", nx, ny, nz, ng ); // t_xs(nx,ny,nz,ng)
   	  
  const team_policy_t policy( N, hyper_threads, vector_lanes );
  
  for (int ii = 0; ii < n_test_iter; ii++) {
    Kokkos::Impl::Timer timer;
    
    for (int oct = 0; oct < noct; oct++) {
      parallel_for( policy, dim3_sweep2<  team_policy_t,
                                          view_1d_t, view_2d_t, view_3d_t, view_4d_t,
                                          view_5d_t, view_6d_t, view_7d_t >
                                        ( M, L,
                                          ng, cmom, noct,
                                          nx, ny, nz, ichunk,
                                          diag,
                                          id, ich, oct,
                                          jlo, jhi, jst, jd,
                                          klo, khi, kst, kd,
                                          psii, psij, psik,
                                          jb_in, kb_in,
                                          qim, qtot, ec,
                                          mu, w,
                                          wmu, weta, wxi,
                                          hi, hj, hk,
                                          vdelt, ptr_in, ptr_out,
                                          flux, fluxm, psi, pc,
                                          jb_out, kb_out,
                                          flkx, flky, flkz,
                                          hv, fxhv, dinv,
                                          den, t_xs ) );
    }// end noct
    
    std::cout << " ii " << ii << " elapsed time " << timer.seconds() << std::endl;
  } // end n_test_iter	
	
	Kokkos::finalize();
}
Ejemplo n.º 12
0
void run_serial(  int nx, int ny, int nz, int ndiag, const vector<diag_c>& diag,
                  int ndimen, int id, int jd, int kd,
                  int nang, int nmom, int noct, int ng,
                  int ich, int ichunk,
                  int jlo, int klo, int jhi, int khi, int jst, int kst,
                  bool firsty, bool lasty, bool firstz, bool lastz,
                  int nnested, int src_opt, int fixup,
                  double hi, double vdelt )
{

	typedef Kokkos::Serial device_type;
	typedef Kokkos::View<double*, Kokkos::LayoutLeft, device_type> serial_view_t_1d;
	typedef Kokkos::View<double**, Kokkos::LayoutLeft, device_type> serial_view_t_2d;
	typedef Kokkos::View<double***, Kokkos::LayoutLeft, device_type> serial_view_t_3d;
	typedef Kokkos::View<double****, Kokkos::LayoutLeft, device_type> serial_view_t_4d;
	typedef Kokkos::View<double*****, Kokkos::LayoutLeft, device_type> serial_view_t_5d;
	typedef Kokkos::View<double******, Kokkos::LayoutLeft, device_type> serial_view_t_6d;
	typedef Kokkos::View<double*, Kokkos::LayoutStride> serial_view_t_1d_s;

//   cout << " a " << endl;
  
	int cmom = nmom * nmom;
	int d1 = nang; // TEST, (timedep == 1 => 		d1 = nang; d2 = nx; d3 = ny; d4 = nz )
	int d2 = nx; // TEST
	int d3 = ny; // TEST
	int d4 = nz; // TEST

//   cout << " b " << endl;
  
  serial_view_t_1d hj( "hj", nang );
  serial_view_t_1d hk( "hk", nang );
  serial_view_t_1d mu( "mu", nang );
	serial_view_t_1d w( "w", nang );
  serial_view_t_6d qim( "qim", nang, nx, ny, nz, noct, ng );
	serial_view_t_3d psii( "psii", nang, ny, nz );
	serial_view_t_3d psij( "psij", nang, ichunk, nz );
	serial_view_t_3d psik( "psik", nang, ichunk, ny );
  serial_view_t_4d qtot( "qtot", cmom, nx, ny, nz );
	serial_view_t_2d ec( "ec", nang, cmom );
  serial_view_t_4d ptr_in( "ptr_in", d1, d2, d3, d4 );
  serial_view_t_4d ptr_out( "ptr_out", d1, d2, d3, d4 );
  serial_view_t_4d dinv( "dinv", nang, nx, ny, nz );
	serial_view_t_3d flux( "flux", nx, ny, nz );
  serial_view_t_4d fluxm( "fluxm", cmom-1, nx, ny, nz );
 	serial_view_t_3d jb_in( "jb_in", nang, ichunk, nz );
  serial_view_t_3d jb_out( "jb_out", nang, ichunk, nz );
	serial_view_t_3d kb_in( "kb_in", nang, ichunk, ny );
	serial_view_t_3d kb_out( "kb_out", nang, ichunk, ny );
	serial_view_t_1d wmu( "wmu", nang );
	serial_view_t_1d weta( "weta", nang );
	serial_view_t_1d wxi( "wxi", nang );
  serial_view_t_3d flkx( "flkx", nx+1, ny, nz );
  serial_view_t_3d flky( "flky", nx, ny+1, nz );
  serial_view_t_3d flkz( "flkz", nx, ny, nz+1 );
  serial_view_t_3d t_xs( "t_xs", nx, ny, nz );

//   cout << " c " << endl;
  
  for (int ii = 0; ii < n_test_iter; ii++) {
    time(&timer_start);
    
    for (int oct = 0; oct < noct; oct++) {
      for (int g = 0; g < ng; g++) {	
        dim3_sweep< device_type, serial_view_t_1d, serial_view_t_2d,
                  serial_view_t_3d, serial_view_t_4d, serial_view_t_5d,
                  serial_view_t_6d, serial_view_t_1d_s >
                ( ichunk, firsty, lasty, firstz, lastz, nnested,
                  nx, hi, hj, hk, ndimen, ny, nz, ndiag, diag,
                  cmom, nang, mu, w, noct,
                  src_opt, ng, qim,
                  fixup,
                  ich, id, d1, d2, d3, d4, jd, kd, jlo, klo, oct, g,
                  jhi, khi, jst, kst, psii, psij, psik, qtot, ec, vdelt,
                  ptr_in, ptr_out, dinv, flux, fluxm, jb_in, jb_out,
                  kb_in, kb_out, wmu, weta, wxi, flkx, flky, flkz, t_xs );
      }
    }
    
    time(&timer_end);
    std::cout << " ii " << ii << " elapsed time " << difftime(timer_end, timer_start) << std::endl;
  }
}
Ejemplo n.º 13
0
cMMInputMenu::cMMInputMenu(void):
		cOsdMenu(tr("Streaming Control")) {
	SetHasHotkeys();
	Add(new cOsdItem(hk(tr("Synchronize EPG")),   (eOSState)subSyncEPG));
}
Ejemplo n.º 14
0
void cMenuFavouritesFunction::Set()
{
    Clear();
    SetHasHotkeys();
/*
    cString note_text = cString::sprintf("%s '%s', %s",
                                         channel && channel->GroupSep() ?  tr("For folder") : tr("For channel"),
                                         channel?channel->Name():"undefined",
                                         tr("please choose one of the following options")
                                         );
*/
    cString note_text;
    if (channel && channel->GroupSep())
        note_text = cString::sprintf(tr("For folder '%s' please choose one of the following options:"),
                                         channel ? channel->Name() : "undefined"
                                         );
    else
        note_text = cString::sprintf(tr("For channel '%s' please choose one of the following options:"),
                                         channel ? channel->Name() : "undefined"
                                         );

    AddFloatingText(*note_text, 45);
    Add(new cOsdItem("",osUnknown, false)); // blank line
    // Add(new cOsdItem("",osUnknown, false)); // blank line

    //Add(new cOsdItem(hk(tr("Create new favourites folder"))));
    //Add(new cOsdItem(hk(tr("Move selected favourites"))));
    if (channel) {
        cString  tmp;
        if (channel->GroupSep()) {
            // selected is a fav. folder/bouquet
            //tmp = cString::sprintf("%s: '%s'", tr("Rename folder"), channel->Name());
            tmp = tr("Rename folder");
            Add(new cOsdItem(hk(*tmp)));

            //tmp = cString::sprintf("%s: '%s'", tr("Delete folder"), channel->Name());
            tmp = tr("Delete folder");
            Add(new cOsdItem(hk(*tmp)));

            //tmp = cString::sprintf("%s: '%s'", tr("Move folder"), channel->Name());
            tmp = tr("Move folder");
            Add(new cOsdItem(hk(*tmp)));

            //tmp = cString::sprintf("%s: '%s'", tr("CI-slot assignment for folder"),
            //                        channel->Name());
            tmp = tr("CI-slot assignment for folder");
            Add(new cOsdItem(hk(*tmp)));
        }
        else {
            // selected is a channel
            //tmp = cString::sprintf("%s: '%s'", tr("Move channel"), channel->Name());
            tmp = tr("Move channel");
            Add(new cOsdItem(hk(*tmp)));

            //tmp = cString::sprintf("%s: '%s'", tr("Delete channel"), channel->Name());
            tmp = tr("Delete channel");
            Add(new cOsdItem(hk(*tmp)));

            //tmp = cString::sprintf("%s: '%s'", tr("CI-slot assignment for channel"),
            //                       channel->Name());
            tmp = tr("CI-slot assignment for channel");
            Add(new cOsdItem(hk(*tmp)));
        }
    } // if

    Display();
}
Ejemplo n.º 15
0
myMenuCommands::myMenuCommands(const char *_Title,cList<cNestedItem> *_Commands,const char *Parameters):cOsdMenu(_Title)
#else
myMenuCommands::myMenuCommands(const char *_Title,cCommands *_Commands, const char *Parameters):cOsdMenu(_Title)
#endif
{
 SetHasHotkeys();
 commands=_Commands;
#if VDRVERSNUM > 10713
 result=NULL;
 parameters=Parameters;
 for(cNestedItem *Command=commands->First();Command;Command=commands->Next(Command)) {
  const char *s=Command->Text();
  if(Command->SubItems())
   Add(new cOsdItem(hk(cString::sprintf("%s...", s))));
  else if(Parse(s))
   Add(new cOsdItem(hk(title)));
 }
#else
 parameters=Parameters?strdup(Parameters):NULL;
 for(cCommand *command=commands->First();command;command=commands->Next(command))
  Add(new cOsdItem(hk(command->Title())));
#endif
}

myMenuCommands::~myMenuCommands()
{
#if VDRVERSNUM > 10713
 free(result);
#else
 free(parameters);
#endif
}

#if VDRVERSNUM > 10713
bool myMenuCommands::Parse(const char *s)
{
 const char *p=strchr(s,':');
 if(p) {
  int l=p-s;
  if(l>0) {
   char t[l+1];
   stripspace(strn0cpy(t,s,l+1));
   l=strlen(t);
   if(l>1&&t[l-1]=='?') {
    t[l-1]=0;
    confirm=true;
   }
   else
    confirm=false;
   title=t;
   command=skipspace(p+1);
   return true;
  }
 }
 return false;
}
#endif

#if VDRVERSNUM > 10713
eOSState myMenuCommands::Execute()
{
 cNestedItem *Command=commands->Get(Current());
 if(Command) {
  if(Command->SubItems())
   return AddSubMenu(new myMenuCommands(Title(),Command->SubItems(),parameters));
  if(Parse(Command->Text())) {
   if(!confirm||Interface->Confirm(cString::sprintf("%s?",*title))) {
    Skins.Message(mtStatus,cString::sprintf("%s...",*title));
    free(result);
    result=NULL;
    cString cmdbuf;
    if(!isempty(parameters))
     cmdbuf=cString::sprintf("%s %s",*command,*parameters);
    const char *cmd=*cmdbuf?*cmdbuf:*command;
    dsyslog("executing command '%s'",cmd);
    cPipe p;
    if(p.Open(cmd,"r")) {
     int l=0;
     int c;
     while((c=fgetc(p))!=EOF) {
      if(l%20==0)
       result=(char *)realloc(result,l+21);
      result[l++]=char(c);
     }
     if(result)
      result[l]=0;
     p.Close();
    }
    else
     esyslog("ERROR: can't open pipe for command '%s'",cmd);
    Skins.Message(mtStatus,NULL);
    if(result)
     return AddSubMenu(new cMenuText(title,result,fontFix));
    return osEnd;
   }
  }
 }
 return osContinue;
}
#else
eOSState myMenuCommands::Execute()
{
 cCommand *command=commands->Get(Current());
 if(command)
 {
  char *buffer=NULL;
  bool confirmed=false;
#ifdef CMDSUBMENUVERSNUM
  if (command->hasChilds())
  {
   AddSubMenu(new myMenuCommands(command->Title(), command->getChilds(), parameters));
   return osContinue;
  }
#endif
  if(command->Confirm())
  {
   if(asprintf(&buffer,"%s?",command->Title())!=-1)
   {
    confirmed=Interface->Confirm(buffer);
    free(buffer);
   }
  } else {
    confirmed=true;
  }
  if(confirmed)
  {
   if(asprintf(&buffer, "%s...",command->Title())!=-1)
   {
    Skins.Message(mtStatus,buffer);
    free(buffer);
   }
   const char *Result=command->Execute(parameters);
   Skins.Message(mtStatus,NULL);
   if(Result)
    return AddSubMenu(new cMenuText(command->Title(),Result,fontFix));
   return osEnd;
  }
 }
 return osContinue;
}
#endif

eOSState myMenuCommands::ProcessKey(eKeys Key)
{
 eOSState state=cOsdMenu::ProcessKey(Key);

 if(state==osUnknown)
 {
  switch(Key)
  {
   case kRed:
   case kGreen:
   case kYellow:
   case kBlue: return osContinue;
   case kOk: return Execute();
   default: break;
  }
 }
 return state;
}