Esempio n. 1
0
int GMetaArchiveTypeSession::getType() const
{
	GASSERT(this->isInSession());
	GASSERT(! this->needType());

	return this->typeStack->top();
}
Esempio n. 2
0
GPublic void utest_rbtree()
{
    RBTreeP_t pTree = NULL;
    Int32_t i = 0;
    Int32_t sdwCount = 10240;

    pTree = urbt_new();

    for (i = 0; i < sdwCount; i++)
    {
        urbt_insert(pTree, i);
        urbt_insert(pTree, 0 - i);
    }

    for (i = 0; i < sdwCount; i++)
    {
        Int32_t j = 0;
        j = urbt_search(pTree, i);
        GASSERT(j == i);
        j = urbt_search(pTree, 0 - i);
        GASSERT(j == 0 - i);
    }

    for (i = 0; i < sdwCount / 4; i++)
    {
        urbt_delete(pTree, i);
        urbt_delete(pTree, 0 - i);
    }

    rbtree_free(pTree);
}
Esempio n. 3
0
void Global::save(QString filename)
{
  GASSERT(_db != NULL, "Cannot save empty database");

  QFile fd (filename);
  if (!fd.open(QIODevice::WriteOnly))
    GEXITDIALOG("Could not open project file for writing " + filename);
  QTextStream file (&fd);

  file << "VERSION=" << DB_VERSION << "\n";
  file << "IMAGE_PATH=.\n"; // Images are always in the same directory as the project file
  file << "QUESTIONS_PER_STUDENT=" << Global::db()->getNumQuestions() << "\n";
  GASSERT(_numPagesPerStudent > 0, "_numPagesPerStudent %zu is not valid", _numPagesPerStudent);
  file << "PAGES_PER_STUDENT=" << _numPagesPerStudent << "\n";
  file << "TOTAL_STUDENTS=" << Global::db()->getNumStudents() << "\n";
  file << "SAVE_DATE_TIME=" << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss") << "\n";
  file << "NUM_IMAGES=" << Global::getPages()->size() << "\n";
  if (Global::getPages()->size() != Global::db()->getNumStudents() * _numPagesPerStudent)
  {
    GDEBUG("Detected mismatch in number of pages %zu, number of students %zu, and number of pages per student %zu",
           Global::getPages()->size(), Global::db()->getNumStudents(), _numPagesPerStudent);
    GINFODIALOG("Detected page mismatch during save, but will continue anyway");
  }

  file << "-2\tPAGE\tPAGE\t" << -1;
  for (size_t q = 0; q < Global::db()->getNumQuestions(); q++)
    file << "\t" << Global::db()->getQuestionPage(q);
  for (size_t q = 0; q < Global::db()->getNumQuestions(); q++)
    file << "\t" << "NF"; // Emit empty feedback columns
  file << "\n";

  file << "-1\tMAX\tMAX\t" << Global::db()->getTotalMaximum();
  for (size_t q = 0; q < Global::db()->getNumQuestions(); q++)
    file << "\t" << Global::db()->getQuestionMaximum(q);
  for (size_t q = 0; q < Global::db()->getNumQuestions(); q++)
    file << "\t" << "NF"; // Emit empty feedback columns
  file << "\n";

  for (size_t s = 0; s < Global::db()->getNumStudents(); s++)
  {
    Student& student = Global::db()->getStudent(s);
    file << s << "\t" << student.getStudentId() << "\t" << student.getStudentName();
    file << "\t" << student.getTotal();
    for (size_t q = 0; q < Global::db()->getNumQuestions(); q++)
      file << "\t" << student.getGrade(q);
    for (size_t q = 0; q < Global::db()->getNumQuestions(); q++)
      file << "\t" << student.getFeedback(q);
    file << "\n";
  }

  // Verify that the write actually worked ok
  fd.flush();
  if (fd.error() != QFile::NoError)
    GINFODIALOG ("Failed to write out complete project file - will not exit, but you need to re-save your work!");
  fd.close();

  // TODO: We could also dump out the Qt table as well as a backup in a different file
}
Esempio n. 4
0
    void removeShape(Shape* target) {
        GASSERT(target);

        std::vector<Shape*>::iterator it = std::find(fList.begin(), fList.end(), target);
        if (it != fList.end()) {
            fList.erase(it);
        } else {
            GASSERT(!"shape not found?");
        }
    }
Esempio n. 5
0
void MainWindow::DateRangeUpdated(QDate s, QDate e)
{
    Range<QDate> r( m_sdr->GetDateRange() );

    lbl_dateStart->setText(QString("Start Date: %1").arg(r.LowerBound().Value().toString("ddd MMMM d yyyy")));
    lbl_dateEnd->setText(QString("End Date: %1").arg(r.UpperBound().Value().toString("ddd MMMM d yyyy")));
    lbl_updateCount->setText(QString("Update Count: %1").arg(++m_updateCount));

    GASSERT(s.isNull() || s == r.LowerBound().Value());
    GASSERT(e.isNull() || e == r.UpperBound().Value());
}
Esempio n. 6
0
void Function::configure(PinIdxType idx, FuncSel sel)
{
    std::size_t selIdx = idx / NumOfLinesPerSelWord;
    GASSERT(selIdx < NumOfSelWords);
    SingleSelWord selValue = pSel->entries[selIdx];

    GASSERT(static_cast<SingleSelWord>(sel) <
                        (static_cast<SingleSelWord>(1) << NumOfBitsPerLine));
    std::size_t selEntryIdx = idx % NumOfLinesPerSelWord;
    std::size_t selEntryShift = selEntryIdx * NumOfBitsPerLine;
    selValue &= ~(BitsPerLineMask << selEntryShift);
    selValue |= static_cast<SingleSelWord>(sel) << selEntryShift;
    pSel->entries[selIdx] = selValue;
}
Esempio n. 7
0
void CppContainer::doAddItem(CppItem * item)
{
	switch(item->getCategory()) {
		case icNamespace:
			this->pushItem(this->namespaceList, item);
			break;

		case icClass:
			this->pushItem(this->classList, item);
			break;

		case icField:
			this->pushItem(this->fieldList, item);
			break;
			
		case icMethod:
			this->pushItem(this->methodList, item);
			break;

		case icEnum:
			this->pushItem(this->enumList, item);
			break;

		case icOperator:
			this->pushItem(this->operatorList, item);
			break;

		default:
			GASSERT(false);
			break;
	}
}
Esempio n. 8
0
static void ril_sms_notify(GRilIoChannel *io, guint ril_event,
				const void *data, guint len, void *user_data)
{
	struct ril_sms *sd = user_data;
	GRilIoParser rilp;
	char *ril_pdu;
	int ril_pdu_len;
	unsigned int smsc_len;
	long ril_buf_len;
	guchar *ril_data;

	ril_pdu = NULL;
	ril_data = NULL;

	DBG("event: %d; data_len: %d", ril_event, len);

	grilio_parser_init(&rilp, data, len);
	ril_pdu = grilio_parser_get_utf8(&rilp);
	if (ril_pdu == NULL)
		goto error;

	ril_pdu_len = strlen(ril_pdu);

	DBG("ril_pdu_len is %d", ril_pdu_len);
	ril_data = decode_hex(ril_pdu, ril_pdu_len, &ril_buf_len, -1);
	if (ril_data == NULL)
		goto error;

	/* The first octect in the pdu contains the SMSC address length
	 * which is the X following octects it reads. We add 1 octet to
	 * the read length to take into account this read octet in order
	 * to calculate the proper tpdu length.
	 */
	smsc_len = ril_data[0] + 1;
	ofono_info("sms received, smsc_len is %d", smsc_len);
	DBG("(%s)", ril_pdu);

	if (ril_event == RIL_UNSOL_RESPONSE_NEW_SMS) {
		/* Last parameter is 'tpdu_len' ( substract SMSC length ) */
		ofono_sms_deliver_notify(sd->sms, ril_data, ril_buf_len,
						ril_buf_len - smsc_len);
	} else {
		GASSERT(ril_event == RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT);
		ofono_sms_status_notify(sd->sms, ril_data, ril_buf_len,
						ril_buf_len - smsc_len);
	}

	g_free(ril_pdu);
	g_free(ril_data);
	ril_ack_delivery(sd, TRUE);
	return;

error:
	g_free(ril_pdu);
	g_free(ril_data);
	ril_ack_delivery(sd, FALSE);
	ofono_error("Unable to parse NEW_SMS notification");
}
Esempio n. 9
0
static gboolean ril_mtu_watch_start(struct ril_mtu_watch *self)
{
	if (self->fd >= 0) {
		return TRUE;
	} else if (ril_mtu_watch_open_socket(self)) {
		GASSERT(!self->channel);
		GASSERT(!self->io_watch);
		self->channel = g_io_channel_unix_new(self->fd);
		if (self->channel) {
			g_io_channel_set_encoding(self->channel, NULL, NULL);
			g_io_channel_set_buffered(self->channel, FALSE);
			self->io_watch = g_io_add_watch(self->channel,
					G_IO_IN | G_IO_NVAL | G_IO_HUP,
					ril_mtu_watch_event, self);
			return TRUE;
		}
		close(self->fd);
		self->fd = -1;
	}
	return FALSE;
}
Esempio n. 10
0
File: GBase.cpp Progetto: zzj/TopHat
//hash function used for strings in GHash
int strhash(const char* str){
  register int h=0;
  register int g;
  while (*str) {
    h=(h<<4)+*str++;
    g=h&0xF0000000;
    if(g) h^=g>>24;
    h&=0x0fffffff;
    }
  GASSERT(h<=0x0fffffff);
  return h;
  }
Esempio n. 11
0
static void vRuleAttrs(ATTRS_CTX* spCtx, G_UINT uiRuleIndex, ATTRS* spAttrs){
	ATTRS* spRuleAttrs;
	ATTRS* spFrame;
	ATTRS* spFrameAttrs;
	ATTRS* spFrameOpen;
	G_UINT i;
	G_OPCODE* spOp;
	G_RULE* spRule;

	spRuleAttrs = &spCtx->spAttrs[uiRuleIndex];
	ATTRS_TRACE(spCtx, WHICH_RULE, uiRuleIndex, NULL, spRuleAttrs);
	while(APG_TRUE){
		if(spRuleAttrs->uipRefCount[spCtx->uiStartRuleIndex] == 0){	// does not refer to start rule - use rule attrs
			vAttrsCopy(spAttrs, spRuleAttrs);
			break;
		}
		spFrame = spFramePeek(spCtx->vpFrameCtx);
		GASSERT(spFrame);
		spFrameAttrs = spFrame + uiRuleIndex;
		if(spFrameAttrs->uiIsComplete || spFrameAttrs->uiIsOpen){
			vAttrsCopy(spAttrs, spFrameAttrs);	// use leaf or previously calculated result
			break;
		}

//		// open the rule and traverse it
		// this rule is not complete or open - push a frame and copy up and traverse the rule
		spFrameOpen = spFramePush(spCtx->vpFrameCtx); // push a new frame for this rule
		GASSERT(spFrameOpen);
		spFrameAttrs = spFrameOpen + uiRuleIndex;
		spFrame = spFramePrev(spCtx->vpFrameCtx);// refresh the previous frame
		GASSERT(spFrame);
		for(i = 0; i < spCtx->uiRuleCount; i++){ // copy previous frame up to this frame for initialization
			spFrameOpen[i].uiIsOpen = spFrame[i].uiIsOpen;
			spFrameOpen[i].uiIsComplete = spFrame[i].uiIsComplete;
			spFrameOpen[i].cpRuleName = spFrame[i].cpRuleName;
			vAttrsCopy(&spFrameOpen[i], &spFrame[i]);
		}

		spRule = spCtx->spRules + uiRuleIndex;
		spOp = spCtx->spOpcodes + spRule->uiChildOffset;
		spFrameAttrs->uiIsOpen = APG_TRUE;
		spCtx->uiTreeDepth++;
		vOpcodeAttrs(spCtx, spOp, spAttrs);
		spCtx->uiTreeDepth--;

		// copy this rule only down to previous frame
		spFrameOpen = spFramePeek(spCtx->vpFrameCtx); // refresh top frame pointer
		GASSERT(spFrameOpen);
		spFrame = spFramePrev(spCtx->vpFrameCtx);// refresh the previous frame pointer
		GASSERT(spFrame);
		spFrameAttrs = spFrame + uiRuleIndex;
		spFrameAttrs->uiIsOpen = APG_FALSE;
		spFrameAttrs->uiIsComplete = APG_TRUE;
		vAttrsRecursiveCopy(spFrameAttrs, spAttrs);
		vAttrsNonRecursiveCopy(spFrameAttrs, spRuleAttrs);
		spFrame = spFramePop(spCtx->vpFrameCtx); // pop the unneeded frame for this rule
		GASSERT(spFrame);
		break;
	}
}
Esempio n. 12
0
void MainWindow::adjustQuestion(size_t question)
{
  GASSERT(question < Global::getNumQuestions(), "Question %zu is larger than max question %zu", question, Global::getNumQuestions());
  curQuestion = question;
  Student &student = Global::db()->getStudent(curStudent());
  ui->questionStats->setText(QString("Question %1 of %2").arg(curQuestion+1).arg(Global::getNumQuestions()));
  ui->questionFeedback->setText(student.getFeedback(curQuestion));
  ui->questionMaximum->setText(getStrFromGrade(Global::db()->getQuestionMaximum(curQuestion)));
  ui->questionScore->setText(getStrFromGrade(student.getGrade(curQuestion)));
  ui->questionPage->setText(getStrFromGrade(Global::db()->getQuestionPage(curQuestion)));
  adjustAnswer(question);
  Global::gw()->update(curStudent(), curQuestion);
}
Esempio n. 13
0
// Resize memory
bool GRealloc(pointer* ptr,unsigned long size){
  GASSERT(ptr);
  if (size==0) {
    GFree(ptr);
    return true;
    }
  void *p=realloc(*ptr,size);
  if (p) {
      *ptr=p;
      return true;
      }
  return false;
  }
Esempio n. 14
0
void MainWindow::handlePageNext()
{
#ifdef NO_WRAPPING
  if (curPage < (Global::getNumPages()-1))
    curPage++;
#else
  if (curPage == (Global::getNumPages()-1))
    curPage = 0;
  else
    curPage++;
#endif // NO_WRAPPING
  GASSERT(curPage < Global::getNumPages(), "Current page %zu is out of bounds for %zu pages", curPage, Global::getNumPages());
  adjustPage(curPage);
}
Esempio n. 15
0
void FxPlayerTiny::RegisterHUDView (const FxDelegateArgs& params)
{
	GASSERT(params.GetArgCount()==1);   // HUD movieclip

	GFxValue hud = params[0];

	GFxValue ConfigWindowMC;
	hud.GetMember("ConfigWindowMC", &ConfigWindowMC);
	SetVisible(&ConfigWindowMC, false);

    //FxPlayerTiny* pthis = (FxPlayerTiny*)params.GetHandler();
	//pthis->HUDMC = hud;
	return;
}
Esempio n. 16
0
void MainWindow::handleScore(int in)
{
  if (in > Global::db()->getQuestionMaximum(curQuestion))
  {
    GDEBUG ("Rejected score %d from function keys since it is equal or higher than maximum %d", in, Global::db()->getQuestionMaximum(curQuestion));
    GINFODIALOG("Rejected score since it is higher than the maximum");
    return;
  }
  GASSERT(in >= -1, "Score value %d is not valid", in);
  GDEBUG ("Received score %d from function keys", in);
  Global::db()->getStudent(curStudent()).setGrade(curQuestion, in);
  ui->questionScore->setText(getStrFromGrade(in));
  adjustAnswer(curQuestion);
}
Esempio n. 17
0
static void vOpcodeAttrs(ATTRS_CTX* spCtx, G_OPCODE* spOpcode, ATTRS* spAttrs){
	ATTRS_TRACE(spCtx, WHICH_OP, spOpcode->uiType, spOpcode, spAttrs);
	spAttrs->uiLeft = APG_FALSE;	// default values
	spAttrs->uiNested = APG_FALSE;
	spAttrs->uiRight = APG_FALSE;
	spAttrs->uiCyclic = APG_FALSE;
	spAttrs->uiFinite = APG_UNDEFINED;
	spAttrs->uiEmpty = APG_UNDEFINED;
	switch(spOpcode->uiType){
	case G_TYPE_ALT:
		vAltAttrs(spCtx, spOpcode, spAttrs);
		break;
	case G_TYPE_CAT:
		vCatAttrs(spCtx, spOpcode, spAttrs);
		break;
	case G_TYPE_REP:
		vRepAttrs(spCtx, spOpcode, spAttrs);
		break;
	case G_TYPE_RNM:
		vRuleAttrs(spCtx, spOpcode->sOpType.sRnm.uiRuleIndex, spAttrs);
		break;
	case G_TYPE_UDT:
		spAttrs->uiFinite = APG_TRUE;
		spAttrs->uiEmpty = spOpcode->sOpType.sUdt.uiEmpty;
		break;
	case G_TYPE_AND:
	case G_TYPE_NOT:
		spAttrs->uiFinite = APG_TRUE;
		spAttrs->uiEmpty = APG_TRUE;
		break;
	case G_TYPE_TRG:
		spAttrs->uiEmpty = APG_FALSE;
		spAttrs->uiFinite = APG_TRUE;
		break;
	case G_TYPE_TBS:
		spAttrs->uiFinite = APG_TRUE;
		spAttrs->uiEmpty = APG_FALSE;
		break;
	case G_TYPE_TLS:
		spAttrs->uiFinite = APG_TRUE;
		spAttrs->uiEmpty = (spOpcode->sOpType.sTls.uiLen == 0) ? APG_TRUE:APG_FALSE;
		break;
	default:
		GASSERT(APG_FALSE);
		break;
	}
	spAttrs->uiIsComplete = APG_TRUE;
	spAttrs->uiIsOpen = APG_FALSE;
}
Esempio n. 18
0
static gboolean ril_cbs_register(gpointer user_data)
{
	struct ril_cbs *cd = user_data;

	DBG("");
	GASSERT(cd->timer_id);
	cd->timer_id = 0;
	ofono_cbs_register(cd->cbs);

	cd->event_id = grilio_channel_add_unsol_event_handler(cd->io,
		ril_cbs_notify, RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS, cd);

	/* Single-shot */
	return FALSE;
}
Esempio n. 19
0
void MainWindow::adjustPage(size_t page)
{
  GASSERT(page < Global::getNumPages(), "Page %zu is larger than max page %zu", page, Global::getNumPages());
  curPage = page;
  QPixmap pix = Global::getQPixmap(page);
  int width = zoomFactor * pix.size().width();
  int height = zoomFactor * pix.size().height();
  ui->image->setPixmap(pix.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
  ui->image->resize(width, height);
  ui->pageStats->setText(QString("Page %1 of %2 (Scan %3 of %4)").arg(curPage%Global::getNumPagesPerStudent()+1).arg(Global::getNumPagesPerStudent()).arg(curPage+1).arg(Global::getNumPages()));
  ui->studentStats->setText(QString("Student %1 of %2").arg(curStudent()+1).arg(Global::getNumStudents()));
  ui->studentNum->setText(QString("Student #%1").arg(curStudent()+1));
  ui->studentId->setText(Global::db()->getStudent(curStudent()).getStudentId());
  ui->studentName->setText(Global::db()->getStudent(curStudent()).getStudentName());
  adjustQuestion(curQuestion); // Refresh the question information in the UI
}
Esempio n. 20
0
static void ril_cbs_notify(GRilIoChannel *io, guint code,
				const void *data, guint len, void *user_data)
{
	struct ril_cbs *cd = user_data;
	GRilIoParser rilp;
	char* pdu;

	GASSERT(code == RIL_UNSOL_ON_USSD);
	grilio_parser_init(&rilp, data, len);
	pdu = grilio_parser_get_utf8(&rilp);
	DBG("%s", pdu);
	if (pdu) {
		ofono_cbs_notify(cd->cbs, (const guchar *)pdu, strlen(pdu));
		g_free(pdu);
	}
}
Esempio n. 21
0
int main() {
    auto& system = System::instance();
    auto& led = system.led();
    auto& el = system.eventLoop();

    // Led on on assertion failure.
    embxx::util::EnableAssert<LedOnAssert> assertion(std::ref(led));

    Session session(system);

    device::interrupt::enable();

    el.run();

    GASSERT(0); // Mustn't exit
	return 0;
}
Esempio n. 22
0
/*!
*@brief        GarbageCollectionStart接口回调函数
*@author       zhaohm3
*@param[in]    jvmti_env
*@retval
*@note
*
*@since    2014-9-15 17:58
*@attention
*
*/
GPrivate void JNICALL JVMGarbageCollectionStart(jvmtiEnv *jvmti_env)
{
    GCMON_PRINT_FUNC();

    if (NULL == gpPerfTree && gPerfMemory != NULL)
    {
        //! 通过gPerfMemory构建性能树
        gcmon_init_perf_tree();

        //! 性能计数器红黑树构建好了后,随机初始化性能采样项
        GASSERT(gpPerfTree != NULL);
        sample_init(gpPerfTree);

        gpThread = os_thread_create((Int32_t (JNICALL *)(void *))sample_tdoit, (void *)"OSThread  ");
        os_thread_start(gpThread);
    }
}
GVisual::~GVisual(void)
{
#ifndef PUBLIC_RELEASE
	if(!m_FileName.empty())
		LogInfo() << "Deleting Visual: " << m_FileName;
#endif

	GASSERT(m_Vobs.empty(), "Visual being deleted is still used by at least one vob!");

	for(GBaseDrawable* d : m_RegisteredDrawables)
	{
		DestroyDrawableStates(d);

		// These should be deleted by the vob containing them!
		// TODO: Add a check to find out if there are any memleaks!
	}
}
Esempio n. 24
0
static int ril_sms_probe(struct ofono_sms *sms, unsigned int vendor,
								void *data)
{
	struct ril_modem *modem = data;
	struct ofono_sim *sim = ril_modem_ofono_sim(modem);
	struct ril_sms *sd = g_new0(struct ril_sms, 1);

	sd->modem = modem;
	sd->sms = sms;
	sd->io = grilio_channel_ref(ril_modem_io(modem));
	sd->sim_context = ofono_sim_context_create(sim);
	sd->q = grilio_queue_new(sd->io);
	sd->timer_id = g_idle_add(ril_sms_register, sd);
	ofono_sms_set_data(sms, sd);

	GASSERT(sd->sim_context);
	return 0;
}
bool OrganizeFavoritesDialog::eventFilter(QObject *o, QEvent *ev)
{
    (void)o;
    GASSERT(o == ui->listWidget);
    bool ret = false;
    if(ev->type() == QEvent::ContextMenu){
        QContextMenuEvent *cme = (QContextMenuEvent *)ev;
        m_contextMenu.move(cme->globalPos());
        m_contextMenu.show();
        ret = true;
    }
    else if(ev->type() == QEvent::KeyPress){
        QKeyEvent *ke = (QKeyEvent*)ev;
        if(ke->key() == Qt::Key_Delete){
            _remove_favorite();
        }
    }
    return ret;
}
Esempio n. 26
0
GVariant doReadInteger(const void * address, size_t size)
{
	switch(size) {
		case 1:
			return (T)(*(TYPENAME GIfElse<IsSigned<T>::Result, GFixedTypeInt8::Signed, GFixedTypeInt8::Unsigned>::Result *)(address));

		case 2:
			return (T)(*(TYPENAME GIfElse<IsSigned<T>::Result, GFixedTypeInt16::Signed, GFixedTypeInt16::Unsigned>::Result *)(address));

		case 4:
			return (T)(*(TYPENAME GIfElse<IsSigned<T>::Result, GFixedTypeInt32::Signed, GFixedTypeInt32::Unsigned>::Result *)(address));

		case 8:
			return (T)(*(TYPENAME GIfElse<IsSigned<T>::Result, GFixedTypeInt64::Signed, GFixedTypeInt64::Unsigned>::Result *)(address));
	}

	GASSERT(false);

	return GVariant();
}
Esempio n. 27
0
void __add_children_to_database(V3::File_Entry *fe,
                                PasswordDatabase &pdb,
                                const EntryId &parent_id,
                                int &entry_ctr,
                                function<void(int)> progress_cb)
{
    GASSERT(fe->getType() == V3::File_Entry::directory);

    for(uint i = 0; i < fe->getContents().size(); ++i)
    {
        progress_cb(++entry_ctr);

        V3::File_Entry *cur = fe->getContents()[i];
        Entry e;
        e.SetParentId(parent_id);
        e.SetRow(cur->getRow());
        e.SetName(cur->getLabel().getContent());
        e.SetDescription(cur->getDescription().getContent());
        e.SetFavoriteIndex(cur->getFavorite());
        e.SetModifyDate(*cur->getModifyDate());

        if(V3::File_Entry::password == cur->getType()){
            for(const V3::Attribute &a : cur->getAttributes()){
                SecretValue sv;
                sv.SetName(a.getLabel());
                sv.SetValue(a.getContent().toUtf8());
                sv.SetIsHidden(a.secret);
                sv.SetNotes(a.notes);
                e.Values().append(sv);
            }
        }
        pdb.AddEntry(e, true);

        // We want to show true progress, which means waiting
        //  after each item until the background thread is done adding it
        pdb.WaitForThreadIdle();

        if(V3::File_Entry::directory == cur->getType())
            __add_children_to_database(cur, pdb, e.GetId(), entry_ctr, progress_cb);
    }
}
Esempio n. 28
0
static gboolean ril_mtu_watch_open_socket(struct ril_mtu_watch *self)
{
	GASSERT(self->fd < 0);
	self->fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
	if (self->fd >= 0) {
		struct sockaddr_nl nl;
		memset(&nl, 0, sizeof(nl));
		nl.nl_pid = getpid();
		nl.nl_family = AF_NETLINK;
		nl.nl_groups = RTMGRP_IPV4_IFADDR | RTMGRP_IPV4_ROUTE |
				RTMGRP_IPV6_IFADDR | RTMGRP_IPV6_ROUTE |
				RTMGRP_LINK;

		if (bind(self->fd, (struct sockaddr*)&nl, sizeof(nl)) >= 0) {
			return TRUE;
		}
		close(self->fd);
		self->fd = -1;
	}
	return FALSE;
}
Esempio n. 29
0
static void vCatAttrs(ATTRS_CTX* spCtx, G_OPCODE* spOpcode, ATTRS* spAttrs){
	G_UINT i, uiChildCount;
	G_OPCODE* spChildOp;
	ATTRS saChildren[spOpcode->sOpType.sCat.uiChildCount];
	ATTRS* spChildAttrs = &saChildren[0];
	GASSERT(spOpcode->sOpType.sCat.uiChildCount > 1);
	for(i = 0; i < spOpcode->sOpType.sCat.uiChildCount; i++, spChildAttrs++){
		memset((void*)spChildAttrs, 0, sizeof(ATTRS));
		vAttrsClear(spChildAttrs, spCtx->uiRuleCount);
		spChildOp = spCtx->spOpcodes + spCtx->uipChildList[spOpcode->sOpType.sCat.uiChildListOffset + i];
		vOpcodeAttrs(spCtx, spChildOp, spChildAttrs);
	}
	uiChildCount = spOpcode->sOpType.sCat.uiChildCount;
	spChildAttrs = &saChildren[0];
	spAttrs->uiLeft = uiIsCatLeft(spChildAttrs, uiChildCount);
	spAttrs->uiRight = uiIsCatRight(spChildAttrs, uiChildCount);
	spAttrs->uiNested = uiIsCatNested(spChildAttrs, uiChildCount);
	spAttrs->uiCyclic = uiIsCatCyclic(spChildAttrs, uiChildCount);
	spAttrs->uiFinite = uiIsCatFinite(spChildAttrs, uiChildCount);
	spAttrs->uiEmpty = uiIsCatEmpty(spChildAttrs, uiChildCount);
}
Esempio n. 30
0
static gboolean ril_sms_register(gpointer user_data)
{
	struct ril_sms *sd = user_data;

	DBG("");
	GASSERT(sd->timer_id);
	sd->timer_id = 0;
	ofono_sms_register(sd->sms);

	/* Register event handlers */
	sd->event_id[SMS_EVENT_NEW_SMS] =
		grilio_channel_add_unsol_event_handler(sd->io, ril_sms_notify,
			RIL_UNSOL_RESPONSE_NEW_SMS, sd);
	sd->event_id[SMS_EVENT_NEW_STATUS_REPORT] =
		grilio_channel_add_unsol_event_handler(sd->io, ril_sms_notify,
			RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT, sd);
	sd->event_id[SMS_EVENT_NEW_SMS_ON_SIM] =
		grilio_channel_add_unsol_event_handler(sd->io, ril_sms_on_sim,
			RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM, sd);

	/* Single-shot */
	return FALSE;
}