Exemplo n.º 1
0
void wxPlaylist::Play()
{
	PLEntry *ple;

	if (!HasValidEntries()) return;

	RefreshCurrent();

	if (m_cur_entry >= (s32)gf_list_count(m_entries)) {
		if (!m_pApp->m_loop) return;
		m_cur_entry = 0;
	}

	ple = (PLEntry *) gf_list_get(m_entries, m_cur_entry);
	if (!ple || ple->m_bIsDead) {
		m_cur_entry++;
		Play();
	} else {
		char szPLE[20];
		ple->m_bIsPlaying = 1;
		UpdateEntry(m_cur_entry);
		sprintf(szPLE, "%d", m_cur_entry);
		gf_cfg_set_key(m_pApp->m_user.config, "General", "PLEntry", szPLE);
		m_pApp->DoConnect();
	}
}
Exemplo n.º 2
0
void Playlist::Play()
{
	PLEntry *ple;

	if (!HasValidEntries()) return;

	RefreshCurrent();
	if (m_cur_entry==-1) m_cur_entry = 0;

	if (m_cur_entry >= (s32)gf_list_count(m_entries)) {
		if (!GetApp()->m_Loop) return;
		m_cur_entry = 0;
	}

	ple = (PLEntry *) gf_list_get(m_entries, m_cur_entry);
	assert(ple);
	if (ple->m_bIsDead) {
		m_cur_entry++;
		Play();
	} else {
		char szPLE[20];
		ple->m_bIsPlaying = GF_TRUE;
		UpdateEntry(m_cur_entry);
		sprintf(szPLE, "%d", m_cur_entry);
		gf_cfg_set_key(GetApp()->m_user.config, "General", "PLEntry", szPLE);
		GetApp()->m_pMainWnd->PostMessage(WM_OPENURL);
	}
}
bool FInternationalizationArchive::AddEntry(const FString& Namespace, const FString& Key, const FLocItem& Source, const FLocItem& Translation, const TSharedPtr<FLocMetadataObject> KeyMetadataObj, const bool bOptional)
{
	if (Key.IsEmpty())
	{
		return false;
	}

	TSharedPtr<FArchiveEntry> ExistingEntry = FindEntryByKey(Namespace, Key, KeyMetadataObj);
	if (ExistingEntry.IsValid() && ExistingEntry->Source == Source)
	{
		return (ExistingEntry->Translation == Translation);
	}

	TSharedRef<FArchiveEntry> NewEntry = MakeShareable(new FArchiveEntry(Namespace, Key, Source, Translation, KeyMetadataObj, bOptional));
	if (ExistingEntry.IsValid())
	{
		UpdateEntry(ExistingEntry.ToSharedRef(), NewEntry);
	}
	else
	{
		EntriesBySourceText.Add(Source.Text, NewEntry);
		EntriesByKey.Add(Key, NewEntry);
	}

	return true;
}
Exemplo n.º 4
0
void Playlist::SetDuration(u32 duration)
{
	PLEntry *ple = (PLEntry *) gf_list_get(m_entries, m_cur_entry);
	if (ple) {
		ple->m_duration = duration;
		UpdateEntry(m_cur_entry);
	}
}
void CDepartmentEstimationDialog::AddNewEntry(SDialogPositioingMessage *Message)
{
	UINT iItem = GetIndexForNewEntry(Message);

	m_PositionEstimationsList.InsertItem(iItem, Message->m_BDADDRESS.c_str());

	UpdateEntry(iItem, Message);
}
Exemplo n.º 6
0
void cSoundHandler::Update(float afTimeStep)
{
    if(mfNewSpeed != mfSpeed)
        {
            mfSpeed+=mfSpeedRate;
            if(mfSpeedRate<0 && mfSpeed<mfNewSpeed)mfSpeed=mfNewSpeed;
            if(mfSpeedRate>0 && mfSpeed>mfNewSpeed)mfSpeed=mfNewSpeed;
        }

    if(mfNewVolume != mfVolume)
        {
            mfVolume+=mfVolumeRate * afTimeStep;
            if(mfVolumeRate<0 && mfVolume<mfNewVolume)mfVolume=mfNewVolume;
            if(mfVolumeRate>0 && mfVolume>mfNewVolume)mfVolume=mfNewVolume;
        }

    tSoundEntryListIt it;
    it = mlstGuiSounds.begin();
    while(it != mlstGuiSounds.end())
        {
            if(UpdateEntry(&(*it), afTimeStep, eSoundDest_Gui)==false)
                {
                    it = mlstGuiSounds.erase(it);
                }
            else
                {
                    ++it;
                }

        }

    it = mlstWorldSounds.begin();
    while(it != mlstWorldSounds.end())
        {
            if(UpdateEntry(&(*it), afTimeStep, eSoundDest_World)==false)
                {
                    it = mlstWorldSounds.erase(it);
                }
            else
                {
                    ++it;
                }
        }

    mlCount++;
}
Exemplo n.º 7
0
void Playlist::RefreshCurrent()
{
	if (m_cur_entry==-1) return;
	PLEntry *ple = (PLEntry *) gf_list_get(m_entries, m_cur_entry);
	if (ple && ple->m_bIsPlaying) {
		ple->m_bIsPlaying = GF_FALSE;
		UpdateEntry(m_cur_entry);
	}
}
Exemplo n.º 8
0
void wxPlaylist::RefreshCurrent()
{
	PLEntry *ple;
	if (m_cur_entry<0) return;
	ple = (PLEntry *) gf_list_get(m_entries, m_cur_entry);
	if (ple && ple->m_bIsPlaying) {
		ple->m_bIsPlaying = 0;
		UpdateEntry(m_cur_entry);
	}
}
Exemplo n.º 9
0
void Playlist::SetDead()
{
	PLEntry *ple = (PLEntry *) gf_list_get(m_entries, m_cur_entry);
	if (ple) {
		ple->m_bIsDead = GF_TRUE;
		UpdateEntry(m_cur_entry);
		m_all_dead_entries=-1;
		if (ple->m_bIsPlaying) PlayNext();
	}
}
Exemplo n.º 10
0
void CDepartmentEstimationDialog::HandlePositioningMessage(SDialogPositioingMessage *Message)
{
	Assert(Message->m_MessageType == DialogPositioningMessage);

	int ListEntryIndex = GetListEntryIndex(Message);

	if (ListEntryIndex == -1)
		AddNewEntry(Message);
	else
		UpdateEntry(ListEntryIndex, Message);

	UpdateUserLocation(Message->m_BDADDRESS, Message->m_EstimatedPosition, Message->m_DepartmentNamesUserCurrentlyIn);
}
Exemplo n.º 11
0
exp bool CopyOut(const char* source, const char* dest) {
    // Convert the filename into DOS8.3 format
    char* dosName = new char[12];
    ToDos83Name(source, dosName);

    // Find the file on the disk
    DirectoryEntry* entry = FindEntry(dosName, &directory);
    if (!entry) {
        LastError("CopyOut", "File doesn't exist");
        return false;
    }

    if (!(entry->attrib & ATTRIB_ARCHIVE)) {
        LastError("CopyOut", "This is not a file");
        return false;
    }

    // Update the entry
    UpdateEntry(entry, 0, 0);

    std::ofstream outHandle(dest, std::ios::out | std::ios::binary);
    if (!outHandle.is_open())
        return false;

    // Set up a FatEntry
    FatEntry fatEntry;
    fatEntry.cluster = GetClusterFromEntry(entry);
    fatEntry.sector = GetFATSector(fatEntry.cluster);
    fatEntry.buffer = new char[bpb->bytesPerSector];
    ReadSector(fatEntry.buffer, fatEntry.sector);

    char* sectorData = new char[bpb->bytesPerSector];

    // Read Data
    while (ReadCluster(&fatEntry, sectorData))
        outHandle.write(sectorData, 512);

    if (!(entry->size % bpb->bytesPerSector))
        outHandle.write(sectorData, 512);
    else
        outHandle.write(sectorData, entry->size % bpb->bytesPerSector);

    delete[] fatEntry.buffer;
    delete[] sectorData;
    delete[] dosName;

    outHandle.close();

    return true;
}
Exemplo n.º 12
0
bool Vehicle::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehicleId, uint32 team, const CreatureData *data)
{
    SetMapId(map->GetId());
    SetInstanceId(map->GetInstanceId());
    SetPhaseMask(phaseMask,false);

    CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(Entry);
    if(!cinfo)
    {
        sLog.outErrorDb("Creature entry %u does not exist.", Entry);
        return false;
    }

    Object::_Create(guidlow, Entry, HIGHGUID_VEHICLE);

    if(!UpdateEntry(Entry, team, data))
        return false;

    if(!vehicleId)
    {
        CreatureDataAddon const *cainfo = GetCreatureAddon();
        if(!cainfo)
            return false;
        vehicleId = cainfo->vehicle_id;
    }
    if(!SetVehicleId(vehicleId))
        return false;

    LoadCreaturesAddon();

    m_regenHealth = false;
    m_creation_time = getMSTime();

    SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);
    //RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);

    //Notify the map's instance data.
    //Only works if you create the object in it, not if it is moves to that map.
    //Normally non-players do not teleport to other maps.
    if(map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData())
    {
        ((InstanceMap*)map)->GetInstanceData()->OnCreatureCreate(this);
    }

    return true;
}
Exemplo n.º 13
0
void wxPlaylist::RefreshList()
{
	u32 i, top_idx;
	char szPath[GF_MAX_PATH];
	Bool first_sel;

	top_idx = m_FileList->GetTopItem();
	m_FileList->DeleteAllItems();

	first_sel = 0;
	for (i=0; i<gf_list_count(m_entries); i++) {
		PLEntry *ple = (PLEntry *) gf_list_get(m_entries, i);
		m_FileList->InsertItem(i, wxT(""));
		/*cast for 64-bit compilation*/
		m_FileList->SetItemData(i, (unsigned long) ple);
		UpdateEntry(i);

		if (ple->m_bIsPlaying) m_cur_entry = i;

		if (ple->m_bIsSelected) {
			m_FileList->SetItemState(i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED | wxLIST_MASK_STATE);
			ple->m_bIsSelected = 0;
			/*ensure first item of selection is visible*/
			if (!first_sel) {
				first_sel = 1;
				top_idx = i;
			}
		}
	}

	if (m_cur_entry >= (s32) gf_list_count(m_entries)-1) m_cur_entry = gf_list_count(m_entries)-1;
	else {
		s32 last_idx = top_idx + m_FileList->GetCountPerPage();
		m_FileList->EnsureVisible(top_idx);
		if (gf_list_count(m_entries)<1+ (u32) last_idx) last_idx = gf_list_count(m_entries)-1;
		m_FileList->EnsureVisible(last_idx);
	}

	strcpy((char *) szPath, m_pApp->szAppPath);
#ifdef WIN32
	strcat(szPath, "gpac_pl.m3u");
#else
	strcat(szPath, ".gpac_pl.m3u");
#endif
	Save(szPath, 1);
}
bool FInternationalizationArchive::SetTranslation(const FString& Namespace, const FString& Key, const FLocItem& Source, const FLocItem& Translation, const TSharedPtr<FLocMetadataObject> KeyMetadataObj)
{
	TSharedPtr<FArchiveEntry> Entry = FindEntryByKey(Namespace, Key, KeyMetadataObj);
	if (Entry.IsValid())
	{
		if (Entry->Source != Source)
		{
			UpdateEntry(Entry.ToSharedRef(), MakeShareable(new FArchiveEntry(Namespace, Key, Source, Translation, KeyMetadataObj, Entry->bIsOptional)));
		}
		else
		{
			Entry->Translation = Translation;
		}

		return true;
	}

	return false;
}
Exemplo n.º 15
0
void Playlist::RefreshList()
{
	u32 i, top_idx;
	char szPath[GF_MAX_PATH];

	top_idx = m_FileList.GetTopIndex();
	m_FileList.DeleteAllItems();

	for (i=0; i<gf_list_count(m_entries); i++) {
		PLEntry *ple = (PLEntry *) gf_list_get(m_entries, i);
		m_FileList.InsertItem(i, "");
		m_FileList.SetItemData(i, (u32) ple);

		UpdateEntry(i);
		/*in case of sorting*/
		if (ple->m_bIsPlaying) m_cur_entry = i;

		if (ple->m_bIsSelected) {
			m_FileList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
			ple->m_bIsSelected = GF_FALSE;
		}
	}

	if (m_cur_entry >= (s32)gf_list_count(m_entries)) m_cur_entry = gf_list_count(m_entries);
	else {
		s32 last_idx = top_idx + m_FileList.GetCountPerPage();
		m_FileList.EnsureVisible(top_idx, 0);
		if (gf_list_count(m_entries)<(u32) last_idx) last_idx = gf_list_count(m_entries);
		m_FileList.EnsureVisible(last_idx, 1);
	}


	strcpy((char *) szPath, GetApp()->szUserPath);
	strcat(szPath, "gpac_pl.m3u");
	Save(szPath, GF_TRUE);
}
Exemplo n.º 16
0
exp bool CopyIn(const char* source, const char* dest) {
    DirectoryEntry* entry = 0;
    char* buffer = new char[bpb->bytesPerSector];

    // Open file we're copying in
    std::ifstream inHandle(source, std::ios::in | std::ios::binary | std::ios::ate);
    if (!inHandle.is_open()) {
        LastError("CopyIn", "Failed to open source file");
        return false;
    }

    // Get size of source file
    size_t inLength = (size_t)inHandle.tellg();
    inHandle.seekg(std::ios::beg);

    // Convert the filename into DOS8.3 format
    char* dosName = new char[12];
    ToDos83Name(dest, dosName);

    // Check if entry exists, if so, overwrite it
    entry = FindEntry(dosName, &directory);
    if (entry) {
        // Delete file
        Delete(dest);

        // Undelete entry
        entry->name[0] = dosName[0];
    }

    // Create the directory entry
    if (!entry) {
        // Didn't delete file, make it
        entry = MakeEntry(dosName, ATTRIB_ARCHIVE, inLength, &directory);
        if (!entry) {
            LastError("CopyIn", "Failed to create directory entry");
            delete[] dosName;
            delete[] buffer;
            return false;
        }
    }
    else {
        // Deleted file, find it
        entry = FindEntry(dosName, &directory);
        if (!entry) {
            LastError("CopyIn", "Somehow a file that was just undeleted can't be found...");
            delete[] dosName;
            delete[] buffer;
            return false;
        }

        UpdateEntry(entry, 0, inLength);
    }

    // Write entry to disk
    DirectoryWrite(&directory);

    // Update FAT and then load each cluster and write it while updating the FAT
    FatEntry fatEntry;
    fatEntry.buffer = new char[bpb->bytesPerSector];
    fatEntry.cluster = GetClusterFromEntry(entry);
    fatEntry.sector = GetFATSector(fatEntry.cluster);
    ReadSector(fatEntry.buffer, fatEntry.sector);

    UpdateFAT(&fatEntry, FindFreeCluster());

    // Write to disk
    for (size_t i = 0; i < inLength; i += bpb->bytesPerSector) {
        memset(buffer, 0, bpb->bytesPerSector);
        if (!(i % bpb->bytesPerSector))
            inHandle.read(buffer, bpb->bytesPerSector);
        else
            inHandle.read(buffer, i % bpb->bytesPerSector);

        WriteCluster(&fatEntry, buffer);
    }

    delete[] dosName;
    delete[] buffer;
    delete[] fatEntry.buffer;

    inHandle.close();

    return true;
}
Exemplo n.º 17
0
bool Vehicle::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehicleId, uint32 team, const CreatureData *data)
{
    SetMap(map);
    SetPhaseMask(phaseMask,false);

    CreatureInfo const *cinfo = sObjectMgr.GetCreatureTemplate(Entry);
    if(!cinfo)
    {
        sLog.outErrorDb("Creature entry %u does not exist.", Entry);
        return false;
    }

    Object::_Create(guidlow, Entry, HIGHGUID_VEHICLE);

    if(!UpdateEntry(Entry, team, data))
        return false;

    if(!vehicleId)
    {
        CreatureDataAddon const *cainfo = GetCreatureAddon();
        if(!cainfo)
            return false;
        vehicleId = cainfo->vehicle_id;
    }
    if(!SetVehicleId(vehicleId))
        return false;

    LoadCreaturesAddon();

    m_regenHealth = false;
    m_creation_time = getMSTime();

    SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);
    //RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);

    //Notify the map's instance data.
    //Only works if you create the object in it, not if it is moves to that map.
    //Normally non-players do not teleport to other maps.
    if(map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData())
    {
        ((InstanceMap*)map)->GetInstanceData()->OnCreatureCreate(this);
    }
    
    if(m_vehicleInfo->m_powerType == POWER_TYPE_STEAM)
    {
        setPowerType(POWER_ENERGY);
        SetMaxPower(POWER_ENERGY, 100);
        SetPower(POWER_ENERGY, 100);
    }
    else if(m_vehicleInfo->m_powerType == POWER_TYPE_PYRITE)
    {
        setPowerType(POWER_ENERGY);
        SetMaxPower(POWER_ENERGY, 50);
        SetPower(POWER_ENERGY, 50);
    }
    else
    {
        for (uint32 i = 0; i < MAX_VEHICLE_SPELLS; ++i)
        {
            if(!GetVehicleData()->v_spells[i])
                continue;
            SpellEntry const *spellInfo = sSpellStore.LookupEntry(GetVehicleData()->v_spells[i]);
            if(!spellInfo)
                continue;

            if(spellInfo->powerType == POWER_MANA)
                break;

            if(spellInfo->powerType == POWER_ENERGY)
            {
                setPowerType(POWER_ENERGY);
                SetMaxPower(POWER_ENERGY, 100);
                SetPower(POWER_ENERGY, 100);
                break;
            }
        }
    }
    SetHealth(GetMaxHealth());
    InstallAllAccessories();

    return true;
}
Exemplo n.º 18
0
/*       index_3    index_4 (large)      */
bool QuickIndexImpl::AddEntry( const std::string &path, const Entry &entry )
{
    if (NULL == header_) {
        return false;
    }

    if (!PrepareIndexFile()) {
        return false;
    }

    if (UseLargeEntryToStore(path) && !IsLargeEntry()) {
        assert(0 == header_->current_file);
        if (0 != header_->current_file) {
            return false;
        }
        if (header_->next_large_file == 0){
            header_->next_large_file = header_->current_file + 2;
        }
        QuickIndex *qi = NextLarge();
        if (NULL == qi){
            return false;
        }
        return qi->AddEntry(path, entry);
    }

    // Find entry in current index file,
    // if we find the match entry,
    // use new entry value to replace it
    EntryAddr found_addr;
    if (FindEntryInCurrentIndex(path, found_addr)) {
        UpdateEntry(found_addr, path, entry);
        return true;
    }

    // If current index file is full,
    // use next index to store the entry
    if (IsFileFull()) {
        QuickIndex *qi = NULL;
        if (!IsLargeEntry()) {
            if (header_->next_file == 0) {
                header_->next_file =
                    (0 == header_->current_file) ? 1 : header_->current_file + 2;
            }
            qi = Next();
        }
        else {
            if (header_->next_large_file == 0) {
                header_->next_large_file = header_->current_file + 2;
            }
            qi = NextLarge();
        }

        if (NULL == qi) {
            return false;
        }
        return qi->AddEntry(path, entry);
    }

    // If current index file not full, but not empty entry,
    // just grow the index file
    if (header_->num_entries == header_->num_entries_capacity) {
        if (!GrowIndexFile()) {
            return false;
        }
    }

    size_t entry_pos = GetHash(path);
    EntryAddr addr = GetEntryAddr(entry_pos);
    EntryAddr entry_addr;
    if (IsAddrValid(addr) && IsAddrUsed(addr)) {
        // Handle hash conflict situation
        entry_addr = GetEmptyEntryAddr();
        if (!IsAddrValid(entry_addr)) {
            return false;
        }
        if (!UpdateLastConflictEntry(addr, entry_addr)) {
            return false;
        }
    }
    else {
        entry_addr = GetEmptyEntryAddr();
        if (!IsAddrValid(entry_addr)) {
            return false;
        }
        header_->entries[entry_pos] = entry_addr;
    }

    UpdateEntry(entry_addr, path, entry);
    header_->num_entries++;
    return true;
}
Exemplo n.º 19
0
  QByteArray tree_bytes = s.value("tree").toByteArray();

  if (!tree_bytes.isEmpty()) {
    QDataStream stream(&tree_bytes, QIODevice::ReadOnly);
    stream >> tree_;
  }

  app->player()->RegisterUrlHandler(new SeafileUrlHandler(this, this));

  connect(&tree_, SIGNAL(ToAdd(QString, QString, SeafileTree::Entry)), this,
          SLOT(AddEntry(QString, QString, SeafileTree::Entry)));
  connect(&tree_, SIGNAL(ToDelete(QString, QString, SeafileTree::Entry)), this,
          SLOT(DeleteEntry(QString, QString, SeafileTree::Entry)));
  connect(&tree_, SIGNAL(ToUpdate(QString, QString, SeafileTree::Entry)), this,
          SLOT(UpdateEntry(QString, QString, SeafileTree::Entry)));
}

bool SeafileService::has_credentials() const {
  return !access_token_.isEmpty();
}

void SeafileService::AddAuthorizationHeader(QNetworkRequest* request) const {
  request->setRawHeader("Authorization",
                        QString("Token %1").arg(access_token_).toAscii());
}

void SeafileService::ForgetCredentials() {
  QSettings s;
  s.beginGroup(kSettingsGroup);
Exemplo n.º 20
0
    void NextWave()
    {
        ++Wave;

        switch (Wave)
        {
            case 1:
                for (int i = 0; i < 3; i++)
                {
                    switch (i)
                    {
                        case 0:
                            me->SummonCreature(NPC_TARREN_MILL_GUARDSMAN, 2639.87f, 696.65f, 55.803f, 4.51f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
                            break;
                        case 1:
                            me->SummonCreature(NPC_TARREN_MILL_LOOKOUT, 2635.31f, 697.35f, 56.024f, 4.51f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
                            break;
                        case 2:
                            me->SummonCreature(NPC_TARREN_MILL_PROTECTOR, 2644.64f, 697.09f, 55.860f, 4.51f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
                            break;
                    }
                }
                break;
            case 2:
                UpdateEntry();
                Next = false;
                break;
            case 3:
                for (int i = 0; i < 3; i++)
                {
                    switch (i)
                    {
                        case 0:
                            me->SummonCreature(NPC_TARREN_MILL_GUARDSMAN, 2594.84f, 683.77f, 55.826f, 5.92f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
                            break;
                        case 1:
                            me->SummonCreature(NPC_TARREN_MILL_LOOKOUT, 2599.79f, 686.86f, 55.774f, 5.92f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
                            break;
                        case 2:
                            me->SummonCreature(NPC_TARREN_MILL_PROTECTOR, 2596.47f, 679.29f, 56.177f, 5.92f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
                            break;
                    }
                }
                Next = true;
                break;
             case 4:
                UpdateEntry();
                Next = false;
                break;
             case 5:
                for (int i = 0; i < 4; i++)
                {
                    switch (i)
                    {
                        case 0:
                            me->SummonCreature(NPC_TARREN_MILL_GUARDSMAN, 2639.87f, 696.65f, 55.803f, 4.51f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
                            break;
                        case 1:
                            me->SummonCreature(NPC_TARREN_MILL_LOOKOUT, 2635.31f, 697.35f, 56.024f, 4.51f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
                            break;
                        case 2:
                            me->SummonCreature(NPC_TARREN_MILL_PROTECTOR, 2644.64f, 697.09f, 55.860f, 4.51f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
                            break;
                        case 3:
                            me->SummonCreature(NPC_TARREN_MILL_GUARDSMAN, 2640.52f, 700.75f, 55.962f, 4.51f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
                            break;
                    }
                }
                Next = true;
                break;
            case 6:
                UpdateEntry();
                Next = false;
                break;
            case 7:
                me->SetReactState(REACT_AGGRESSIVE);
                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                me->GetMotionMaster()->MovePoint(0, 2638.60f, 686.948f, 58.245f);
                if (Creature* Thrall = me->GetMap()->GetCreature(ThrallGUID))
                    Thrall->AI()->AttackStart(me);
                me->SetLevitate(false);
                Intro = false;
                break;
        }
    }
void CWebBrowserDownloadHandler::OnDownloadUpdated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefDownloadItem> download_item,
                                                   CefRefPtr<CefDownloadItemCallback> callback)
{
  std::string url = download_item->GetOriginalUrl().ToString();
  std::shared_ptr<CDownloadItem> downloadItem;

  {
    std::lock_guard<std::mutex> lock(m_mutex);

    auto it = m_activeDownloads.find(url);
    if (it == m_activeDownloads.end())
    {
      downloadItem = std::make_shared<CDownloadItem>(url, callback);
      m_activeDownloads[url] = downloadItem;
    }
    else
      downloadItem = it->second;
  }

  if (!downloadItem->IsActive())
    return;

#ifdef DEBUG_LOGS
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s", __FUNCTION__);
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s --- IsValid: '%i'", __FUNCTION__, download_item->IsValid());
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s --- IsInProgress: '%i'", __FUNCTION__, download_item->IsInProgress());
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s --- IsComplete: '%i'", __FUNCTION__, download_item->IsComplete());
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s --- IsCanceled: '%i'", __FUNCTION__, download_item->IsCanceled());
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s --- GetCurrentSpeed: '%li'", __FUNCTION__, download_item->GetCurrentSpeed());
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s --- GetPercentComplete: '%i'", __FUNCTION__, download_item->GetPercentComplete());
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s --- GetTotalBytes: '%li'", __FUNCTION__, download_item->GetTotalBytes());
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s --- GetReceivedBytes: '%li'", __FUNCTION__, download_item->GetReceivedBytes());
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s --- GetStartTime: '%f'", __FUNCTION__, download_item->GetStartTime().GetDoubleT());
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s --- GetEndTime: '%f'", __FUNCTION__, download_item->GetEndTime().GetDoubleT());
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s --- GetFullPath: '%s'", __FUNCTION__, download_item->GetFullPath().ToString().c_str());
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s --- GetId: '%i'", __FUNCTION__, download_item->GetId());
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s --- GetURL: '%s'", __FUNCTION__, download_item->GetURL().ToString().c_str());
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s --- GetOriginalUrl: '%s'", __FUNCTION__, download_item->GetOriginalUrl().ToString().c_str());
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s --- GetSuggestedFileName: '%s'", __FUNCTION__, download_item->GetSuggestedFileName().ToString().c_str());
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s --- GetContentDisposition: '%s'", __FUNCTION__, download_item->GetContentDisposition().ToString().c_str());
  LOG_MESSAGE(ADDON_LOG_DEBUG, "%s --- GetMimeType: '%s'", __FUNCTION__, download_item->GetMimeType().ToString().c_str());
#endif

  downloadItem->SetCanceled(download_item->IsCanceled());
  downloadItem->SetInProgress(download_item->IsInProgress());
  downloadItem->SetProgressText(static_cast<long>(download_item->GetTotalBytes() / 1024 / 1024),
                                static_cast<long>(download_item->GetReceivedBytes() / 1024 / 1024),
                                static_cast<float>(download_item->GetPercentComplete()));

  if (download_item->IsComplete())
  {
    downloadItem->SetComplete();

    std::lock_guard<std::mutex> lock(m_mutex);
    m_finishedDownloads[url] = downloadItem;
    m_activeDownloads.erase(url);
    SaveDownloadHistory();

    kodi::Log(ADDON_LOG_INFO, "Download of '%s' finished", download_item->GetOriginalUrl().ToString().c_str());
    kodi::Log(ADDON_LOG_INFO, " - Is valid: '%i'", download_item->IsValid());
    kodi::Log(ADDON_LOG_INFO, " - Is complete: '%i'", download_item->IsComplete());
    kodi::Log(ADDON_LOG_INFO, " - Is canceled: '%i'", download_item->IsCanceled());
    kodi::Log(ADDON_LOG_INFO, " - Total bytes: '%li'", download_item->GetTotalBytes());
    kodi::Log(ADDON_LOG_INFO, " - Received bytes: '%li'", download_item->GetReceivedBytes());
    kodi::Log(ADDON_LOG_INFO, " - Start time: '%f'", download_item->GetStartTime().GetDoubleT());
    kodi::Log(ADDON_LOG_INFO, " - End time: '%f'", download_item->GetEndTime().GetDoubleT());
    kodi::Log(ADDON_LOG_INFO, " - Full path: '%s'", download_item->GetFullPath().ToString().c_str());
    kodi::Log(ADDON_LOG_INFO, " - URL: '%s'", download_item->GetURL().ToString().c_str());
    kodi::Log(ADDON_LOG_INFO, " - Original Url: '%s'", download_item->GetOriginalUrl().ToString().c_str());
    kodi::Log(ADDON_LOG_INFO, " - Suggested file name: '%s'", download_item->GetSuggestedFileName().ToString().c_str());
    kodi::Log(ADDON_LOG_INFO, " - Content disposition: '%s'", download_item->GetContentDisposition().ToString().c_str());
    kodi::Log(ADDON_LOG_INFO, " - Mime type: '%s'", download_item->GetMimeType().ToString().c_str());
  }

  UpdateEntry(downloadItem, download_item->IsComplete());
}
Exemplo n.º 22
0
void CLDS_File::x_SyncWithDir(const string& path,
                              CLDS_Set*     deleted,
                              CLDS_Set*     updated,
                              set<string>*  scanned_files,
                              TFlags        flags)
{
    CDir dir(path);
    if (!dir.Exists()) {
        LOG_POST_X(2, Info << "LDS: Directory is not found or access denied:" << path);
        return;
    } else {
        LOG_POST_X(3, Info << "LDS: scanning " << path);
    }

    CLDS_Query lds_query(m_DataBase);
    CChecksum checksum(CChecksum::eCRC32);


    // Scan the directory, compare it against File table
    // Here I intentionally take only files, skipping sub-directories,
    // Second pass scans for sub-dirs and implements recursion

    bool compute_check_sum =
        (flags & CLDS_Manager::fControlSumMask) == CLDS_Manager::fComputeControlSum;

    {{

    CDir::TEntries  content(dir.GetEntries());
    ITERATE(CDir::TEntries, i, content) {
        if (!(*i)->IsFile()) {
            continue;
        }
        (*i)->DereferenceLink();

        CTime modification;
        string entry = (*i)->GetPath();
        string name = (*i)->GetName();
        string ext = (*i)->GetExt();
        (*i)->GetTime(&modification);
        time_t tm = modification.GetTimeT();
        CFile aFile(entry);
        Int8 file_size = aFile.GetLength();

        if (ext == ".db" || ext == ".idx") {
            continue; // Berkeley DB file, no need to index it.
        }

        bool found = lds_query.FindFile(entry);

        scanned_files->insert(entry);

        if (!found) {  // new file arrived
            CFormatGuess fg;

            Uint4 crc = 0;

            if (compute_check_sum) {
                checksum.Reset();
                ComputeFileChecksum(entry, checksum);
                crc = checksum.GetChecksum();
            }

            CFormatGuess::EFormat format = fg.Format(entry);

            FindMaxRecId();
            ++m_MaxRecId;

            m_FileDB.file_id = m_MaxRecId;
            m_FileDB.file_name = entry.c_str();
            m_FileDB.format = format;
            m_FileDB.time_stamp = tm;
            m_FileDB.CRC = crc;
            m_FileDB.file_size = file_size;

            m_FileDB.Insert();

            m_DataBase.GetTables().file_filename_idx.file_id = m_MaxRecId;
            m_DataBase.GetTables().file_filename_idx.file_name = entry.c_str();
            m_DataBase.GetTables().file_filename_idx.UpdateInsert();

            updated->set(m_MaxRecId);

            LOG_POST_X(4, Info << "New LDS file found: " << entry);

            continue;
        }

        if (tm != m_FileDB.time_stamp || file_size != m_FileDB.file_size) {
            updated->set(m_FileDB.file_id);
            UpdateEntry(m_FileDB.file_id,
                        entry,
                        0,
                        tm,
                        file_size,
                        compute_check_sum);
        } else {

            Uint4 crc = 0;
            if (compute_check_sum) {
                checksum.Reset();
                ComputeFileChecksum(entry, checksum);
                crc = checksum.GetChecksum();

                if (crc != (Uint4)m_FileDB.CRC) {
                    updated->set(m_FileDB.file_id);
                    UpdateEntry(m_FileDB.file_id,
                                entry,
                                crc,
                                tm,
                                file_size,
                                compute_check_sum);
                }
            }
        }

    } // ITERATE

    }}

    if ( (flags & CLDS_Manager::fRecurseMask) == CLDS_Manager::fDontRecurse )
        return;

    // Scan sub-directories

    {{

    CDir::TEntries  content(dir.GetEntries());
    ITERATE(CDir::TEntries, i, content) {

        if ((*i)->IsDir()) {
            string name = (*i)->GetName();

            if (name == "LDS" || name == "." || name == "..") {
                continue;
            }
            string entry = (*i)->GetPath();

            x_SyncWithDir(entry,
                          deleted,
                          updated,
                          scanned_files,
                          flags);

        }
    } // ITERATE

    }}
}