Beispiel #1
0
void URL_DataStorage::StartLoadingTvDocument()
{
	loading = OP_NEW(URL_Tv_LoadHandler, (url, g_main_message_handler));
	
	// We need this to be able to continue in the next stage (url_ds.cpp)
	if (!loading) //OOM
	{
		SetAttribute(URL::KLoadStatus,URL_LOADING_FAILURE);
		SetAttribute(URL::KHeaderLoaded,TRUE);		
		SetAttribute(URL::KReloading,FALSE);
		SetAttribute(URL::KResumeSupported,FALSE);
		SetAttribute(URL::KReloadSameTarget,FALSE);
		BroadcastMessage(MSG_URL_LOADING_FAILED, url->GetID(), URL_ERRSTR(SI, ERR_COMM_INTERNAL_ERROR), MH_LIST_ALL);
		//g_memory_manager->RaiseCondition(OpStatus::ERR_NO_MEMORY);
		return;
	}

	SetAttribute(URL::KMIME_ForceContentType, "image/atvef");
	SetAttributeL(URL::KMIME_Type, "image/atvef");
	SetAttributeL(URL::KContentType, URL_TV_CONTENT);

	// Broadcast that header has loaded...
	BroadcastMessage(MSG_HEADER_LOADED, url->GetID(),
					 url->GetIsFollowed() ? 0 : 1, MH_LIST_ALL);

	// Broadcast that data has been loaded.
	BroadcastMessage(MSG_URL_DATA_LOADED, url->GetID(), 0,MH_LIST_ALL);	

	UnsetListCallbacks();
	mh_list->Clean();
	url->SetIsFollowed(TRUE);
	SetAttribute(URL::KHeaderLoaded, TRUE);
	SetAttribute(URL::KLoadStatus,URL_LOADED);
}
Beispiel #2
0
void MythPianoService::WriteAudio(char* samples, size_t bytes)
{
  if (!m_AudioOutput) {

    BroadcastMessage("Setting up audio rate(%d), channels(%d)\n",
                     m_Player.samplerate,
                     m_Player.channels);

    QString passthru = gCoreContext->GetNumSetting("PassThruDeviceOverride", false) ? gCoreContext->GetSetting("PassThruOutputDevice") : QString::null;
    QString main = gCoreContext->GetSetting("AudioOutputDevice");
    QString errMsg;

    m_AudioOutput = AudioOutput::OpenAudio(main, passthru,
					   FORMAT_S16,
					   m_Player.channels,
					   0,
					   m_Player.samplerate,
					   AUDIOOUTPUT_MUSIC,
					   true, false);
  }

  if (!m_AudioOutput) {
    BroadcastMessage("Error in WriteAudio.  m_AudioOutput is null");
    return;
  }

  if (bytes == 0)
    return;

  m_AudioOutput->AddFrames(samples, bytes / 4, -1);
  m_AudioOutput->Drain();
}
Beispiel #3
0
int MythPianoService::GetPlaylist() {
	BroadcastMessage("Getting playlist...\n");
	rlen = sprintf(request, "queue\n");
	SendPianodRequest(204);

	/* parse play list from queue command */
	if(response->back().code == 204) {
		playlist.clear();

		for(int x = 0; x < response->size() - 1; x++) {
			MythPianoResponse r = response->at(x);

			if(response->at(x).code == 203) {
				map<string, string> song = PullOutSong(x + 1);

				if(song.size() != 0) {
					cout<<"Storing new song: " << song["Title"] << endl;
					playlist.push_back(song);
				}
			}
		}
	} 
	else {
		BroadcastMessage("Failed to get playlist(2)!\n");
		return -1;
	}

	if(service_heartbeat() < 0) {
		BroadcastMessage("service heartbeat failed\n");
		return -1;
	}

	return 0;

}
void __fastcall TfrmMain::tcpServerExecute(TIdPeerThread *AThread)
{
  TSimpleClient *Client;
  AnsiString Com;     // System command
  AnsiString Msg;

//Get the text sent from the client
try
{
  Msg    = AThread->Connection->ReadLn("",5000);
}
catch (...)
{

}
  // Get the clients package info
if (Msg.Length()==0)return;
  Client = (TSimpleClient *)(AThread->Data);
// Check to see if the clients name has been assigned yet
  if (Client->Name == "Logging In")
   {
   //  if not, assign the name and announce the client
      Client->Name = Msg;
      UpdateClientList();
      BroadcastMessage("System", Msg + " has just logged in.");
      AThread->Connection->WriteLn(memEntry->Lines->Text);
   }
  else
  // If name is set, then send the message
  if (Msg[1] != '@')
    {
    // Not a system command
      BroadcastMessage(Client->Name, Msg);
    }
  else
    {
    // System command
      Com = UpperCase(Trim(Msg.SubString(2, Msg.Pos(":") -2)));
      Msg = UpperCase(Trim(Msg.SubString(Msg.Pos(":") +1, Msg.Length())));
      if (Com == "CLIENTS")
     AThread->Connection->WriteLn( AnsiString("@") + AnsiString("clients:") +
                 lbClients->Items->CommaText);

     if (Com == "KILL")
        KillClient(Msg);
    }


}
Beispiel #5
0
void MythPianoService::StartPlayback()
{
  BroadcastMessage("Starting playback");

  if (m_Playlist == NULL) {
    BroadcastMessage("Empty playlist");
    return;
  }

  if (m_Player.mode != audioPlayer::PLAYER_FREED &&
      m_Player.mode != audioPlayer::PLAYER_FINISHED_PLAYBACK) {
    BroadcastMessage("So sorry, we think we are already playing.  Try again (%d).", m_Player.mode);
    return;
  }


  memset (&m_Player, 0, sizeof (m_Player));
  WaitressInit (&m_Player.waith);
  WaitressSetUrl (&m_Player.waith, m_CurrentSong->audioUrl);

  m_Player.gain = m_CurrentSong->fileGain;
  m_Player.audioFormat = m_CurrentSong->audioFormat;
  m_Player.mode = audioPlayer::PLAYER_STARTING;
  m_Player.writer = &WriteAudioCallback;
  m_Player.writerCtx = (void*) this;

  pthread_create (&m_PlayerThread,
		  NULL,
		  BarPlayerThread,
		  &m_Player);

  BroadcastMessage("New Song");

  if (class LCD *lcd = LCD::Get())
  {
    lcd->switchToMusic(m_CurrentSong->artist,
                       m_CurrentSong->album,
                       m_CurrentSong->title);
  }

  if (m_Timer) {
    m_Timer->stop();
    m_Timer->disconnect();
    delete m_Timer;
  }
  m_Timer = new QTimer(this);
  connect(m_Timer, SIGNAL(timeout()), this, SLOT(heartbeat()));
  m_Timer->start(1000);
}
Beispiel #6
0
void Proposer :: Accept()
{
    PLGHead("START ProposalID %lu ValueSize %zu ValueLen %zu", 
            m_oProposerState.GetProposalID(), m_oProposerState.GetValue().size(), m_oProposerState.GetValue().size());

    BP->GetProposerBP()->Accept();
    m_oTimeStat.Point();
    
    ExitPrepare();
    m_bIsAccepting = true;
    
    PaxosMsg oPaxosMsg;
    oPaxosMsg.set_msgtype(MsgType_PaxosAccept);
    oPaxosMsg.set_instanceid(GetInstanceID());
    oPaxosMsg.set_nodeid(m_poConfig->GetMyNodeID());
    oPaxosMsg.set_proposalid(m_oProposerState.GetProposalID());
    oPaxosMsg.set_value(m_oProposerState.GetValue());
    oPaxosMsg.set_lastchecksum(GetLastChecksum());

    m_oMsgCounter.StartNewRound();

    AddAcceptTimer();

    PLGHead("END");

    BroadcastMessage(oPaxosMsg, BroadcastMessage_Type_RunSelf_Final);
}
Beispiel #7
0
void PaxosProposer::OnProposeResponse(PaxosMessage& imsg)
{
    PaxosMessage omsg;
    
    Log_Trace("msg.nodeID = %u", imsg.nodeID);
    
    if (!state.proposing || imsg.proposalID != state.proposalID)
        return;
    
    if (imsg.type == PAXOS_PROPOSE_REJECTED)
    {
        Log_Debug("Propose rejected, quorumID: %U", context->GetQuorumID());
        vote->RegisterRejected(imsg.nodeID);
    }
    else
        vote->RegisterAccepted(imsg.nodeID);

    if (vote->IsRejected())
    {
        StopProposing();
        EventLoop::Add(&restartTimeout);
    }
    else if (vote->IsAccepted())
    {
        // a majority have accepted our proposal, we have consensus
        StopProposing();
        omsg.LearnProposal(context->GetPaxosID(), MY_NODEID, state.proposalID);
        BroadcastMessage(omsg);
        state.learnSent = true;
    }
}
void		WED_PackageMgr::Rescan(void)
{

	custom_package_names.clear();
	global_package_names.clear();
	default_package_names.clear();
	system_exists=false;
	if (MF_GetFileType(system_path.c_str(),mf_CheckType) == mf_Directory)
	{
		string cus_dir = system_path + DIR_STR CUSTOM_PACKAGE_PATH;
		if (MF_GetFileType(cus_dir.c_str(),mf_CheckType) == mf_Directory)
		{
			system_exists=true;
			MF_IterateDirectory(cus_dir.c_str(), package_scan_func, &custom_package_names);
			sort(custom_package_names.begin(),custom_package_names.end(),CompareNoCase);
		}

		string glb_dir = system_path + DIR_STR GLOBAL_PACKAGE_PATH;
		if (MF_GetFileType(glb_dir.c_str(),mf_CheckType) == mf_Directory)
		{
			system_exists=true;
			MF_IterateDirectory(glb_dir.c_str(), package_scan_func, &global_package_names);
			sort(global_package_names.begin(),global_package_names.end(),CompareNoCase);
		}

		string def_dir = system_path + DIR_STR DEFAULT_PACKAGE_PATH;
		if (MF_GetFileType(def_dir.c_str(),mf_CheckType) == mf_Directory)
		{
			system_exists=true;
			MF_IterateDirectory(def_dir.c_str(), package_scan_func, &default_package_names);
			sort(default_package_names.begin(),default_package_names.end(),CompareNoCase);
		}
	}
	BroadcastMessage(msg_SystemFolderChanged,0);
}
Beispiel #9
0
void PaxosProposer::OnProposeResponse(PaxosMessage& imsg)
{
    PaxosMessage omsg;
    
    Log_Trace("msg.nodeID = %u", imsg.nodeID);
    
    if (!state.proposing || imsg.proposalID != state.proposalID)
        return;
    
    if (imsg.type == PAXOS_PROPOSE_REJECTED)
    {
        Log_Debug("Propose rejected");
        vote->RegisterRejected(imsg.nodeID);
    }
    else
        vote->RegisterAccepted(imsg.nodeID);

    // see if we have enough positive replies to advance
    if (vote->IsAccepted())
    {
        // a majority have accepted our proposal, we have consensus
        StopProposing();
        omsg.LearnProposal(context->GetPaxosID(), MY_NODEID, state.proposalID);
        BroadcastMessage(omsg);
    }
    else if (vote->IsComplete())
        StartPreparing();
}
Beispiel #10
0
void Proposer :: Prepare(const bool bNeedNewBallot)
{
    PLGHead("START Now.InstanceID %lu MyNodeID %lu State.ProposalID %lu State.ValueLen %zu",
            GetInstanceID(), m_poConfig->GetMyNodeID(), m_oProposerState.GetProposalID(),
            m_oProposerState.GetValue().size());

    BP->GetProposerBP()->Prepare();
    m_oTimeStat.Point();
    
    ExitAccept();
    m_bIsPreparing = true;
    m_bCanSkipPrepare = false;
    m_bWasRejectBySomeone = false;

    m_oProposerState.ResetHighestOtherPreAcceptBallot();
    if (bNeedNewBallot)
    {
        m_oProposerState.NewPrepare();
    }

    PaxosMsg oPaxosMsg;
    oPaxosMsg.set_msgtype(MsgType_PaxosPrepare);
    oPaxosMsg.set_instanceid(GetInstanceID());
    oPaxosMsg.set_nodeid(m_poConfig->GetMyNodeID());
    oPaxosMsg.set_proposalid(m_oProposerState.GetProposalID());

    m_oMsgCounter.StartNewRound();

    AddPrepareTimer();

    PLGHead("END OK");

    BroadcastMessage(oPaxosMsg);
}
Beispiel #11
0
 void DepositHandler::HandlePostEncodedRequest(
     uint160 request_hash,
     uint160 post_encoding_credit_hash)
 {
     log_ << "HandlePostEncodedRequest: " << request_hash << "\n";
     DepositAddressPartMessage part_msg;
     std::vector<uint160> part_hashes = depositdata[request_hash]["parts"];
     foreach_(uint160 part_msg_hash, part_hashes)
     {
         part_msg = msgdata[part_msg_hash]["deposit_part"];
         Point relay = part_msg.VerificationKey();
         log_ << "part " << part_msg_hash << " was sent by "
              << relay << "\n";
         if (keydata[relay].HasProperty("privkey"))
         {
             log_ << "have key for " << relay << "; sending disclosure\n";
             DepositAddressPartDisclosure disclosure(
                 post_encoding_credit_hash, part_msg_hash);
             BroadcastMessage(disclosure);
             log_ << "sent disclosure\n";
         }
         flexnode.scheduler.Schedule("disclosure_timeout_check",
                                     part_msg_hash,
                                     GetTimeMicros() + COMPLAINT_WAIT_TIME);
     }
int			GUI_PopupButton::MouseDown(int x, int y, int button)
{
	vector<GUI_MenuItem_t>	items;

	items.resize(mItems.size()+1);
	for (int n = 0; n < mItems.size(); ++n)
	{
		items[n].name = mItems[n].c_str();
		items[n].key = 0;
		items[n].flags = 0;
		items[n].cmd = 0;
		items[n].checked = 0;
	}

	items.back().name = NULL;
	items.back().key = 0;
	items.back().flags = 0;
	items.back().cmd = 0;
	items.back().checked = 0;

	int bounds[4];
	GetBounds(bounds);

	int picked = PopupMenuDynamic(&*items.begin(), bounds[0], bounds[3], button, GetValue());
	if (picked >= 0)
	{
		SetValue(picked);
		BroadcastMessage(GUI_CONTROL_VALUE_CHANGED,0);
	}
	return 1;
}
Beispiel #13
0
int MythPianoService::RepopulateStations() {
	BroadcastMessage("Retrieving station list...\n");
	stations.clear();
	rlen = sprintf(request, "stations list\n");
	SendPianodRequest(204);
	if(response->back().code == 204) {
		for(int x = 0; x < response->size(); x++) {
			MythPianoResponse r = response->at(x);

			if(r.code != 115)
				continue;

			/* remove the "Station: " */
			r.value = r.value.substr(9);
			std::cout<<"Adding station: " << r.value << endl;
			stations.push_back(r.value);
		}
	} 
	else {
		PianodDisconnect("Failed to retrieve station list. Bailing: " + response->back().value);
		return -1;
	}

	service_heartbeat();
	return 0;
}
Beispiel #14
0
    void TradeHandler::HandleTraderComplaint(TraderComplaint complaint)
    {
        uint160 message_hash = complaint.message_hash;
        
        if (!CheckTraderComplaint(complaint))
        {
            should_forward = false;
            return;
        }

        uint160 complaint_hash = complaint.GetHash160();
        
        TradeSecretMessage msg = msgdata[message_hash]["secret"];

        pair<string_t, Point> complaint_key;
        complaint_key = make_pair("received_complaint_about", 
                                  msg.VerificationKey());

        tradedata[msg.accept_commit_hash][complaint_key] = true;

        vector<Point> awaited_relays;
        awaited_relays = tradedata[msg.accept_commit_hash]["awaited_relays"];
        awaited_relays.push_back(msg.VerificationKey());
        tradedata[msg.accept_commit_hash]["awaited_relays"] = awaited_relays;

        flexnode.pit.HandleRelayMessage(message_hash);

        if (tradedata[message_hash]["is_mine"])
        {
            BroadcastMessage(RefutationOfTraderComplaint(complaint_hash));
        }
    }
void	GUI_SimpleScroller::ReceiveMessage(
							GUI_Broadcaster *		inSrc,
							intptr_t				inMsg,
							intptr_t				inParam)
{
	if (inMsg == GUI_SCROLL_CONTENT_SIZE_CHANGED)
		BroadcastMessage(inMsg, inParam);
}
Beispiel #16
0
	void CClientManager::OnRecordingFileChanged(LPCWSTR pszFileName)
	{
		CMessage Message(MESSAGE_EVENT_RecordingFileChanged);

		Message.SetProperty(MESSAGE_PROPERTY_FilePath,pszFileName);

		BroadcastMessage(Message);
	}
Beispiel #17
0
	void CClientManager::OnServiceChanged(WORD ServiceID)
	{
		CMessage Message(MESSAGE_EVENT_ServiceChanged);

		Message.SetPropertyInt(MESSAGE_PROPERTY_ServiceID,ServiceID);

		BroadcastMessage(Message);
	}
Beispiel #18
0
	void CClientManager::OnBonDriverLoaded(LPCWSTR pszFileName)
	{
		CMessage Message(MESSAGE_EVENT_BonDriverLoaded);

		Message.SetProperty(MESSAGE_PROPERTY_FilePath,pszFileName);

		BroadcastMessage(Message);
	}
Beispiel #19
0
CDCMapWorkspace::~CDCMapWorkspace(void)
{
	BroadcastMessage(DCMM_PRE_DESTROY,0,0,0);
	_foreach(ObjectsSet,m_Objects,it)
	{
		(*it)->SaveConfig(&m_Config);
		g_dcmapCore.DestroyWorkspaceModule(*it);
	}
Beispiel #20
0
void Server::BroadcastMessageToAll(std::string _message){
	for (size_t i = 0; i < clientsVec.size(); i++){
		//disable the if check if you want to test on localhost
		// if(!CompareClients(&clientsVec[i], (struct sockaddr *)&remoteaddr)){
			BroadcastMessage(_message, &clientsVec[i]);
		// }
	}
}
Beispiel #21
0
		bool SendServerMessage(const std::string &body, PeerBitSet peers)
		{
			auto session = Blam::Network::GetActiveSession();
			if (!session || !session->IsEstablished() || !session->IsHost())
				return false;

			ChatMessage message(ChatMessageType::Server, body);
			return BroadcastMessage(session, session->MembershipInfo.LocalPeerIndex, &message, peers);
		}
Beispiel #22
0
 foreach_(const BigNumsInPositions::value_type& item,
          credit_secrets_that_dont_recover_currency_secrets)
 {
     uint32_t position = item.first;
     CBigNum bad_credit_secret = item.second;
     RelayComplaint complaint(message_hash,
                              ASK,
                              position,
                              bad_credit_secret);
     BroadcastMessage(complaint);
 }
Beispiel #23
0
void CControlPanel::ListenToMessage(MessageT	 inMessage, void* ioParam)
{
	LStaticText *theCaption;
	
	switch (inMessage) {
	
		case msg_BroadcasterDied:
			// maybe you should just
			StopListening();
			break;
		
		case msg_RenderModeChanged:
			_renderingMode = *((UInt32*)ioParam);
			BroadcastMessage(msg_RenderModeChanged, ioParam);
			break;
	}
	
	UpdateValues(true);
	BroadcastMessage(msg_ControllerChanged ,nil);
}
Beispiel #24
0
	void CClientManager::OnChannelChanged(DWORD Space,DWORD Channel,WORD ServiceID)
	{
		CMessage Message(MESSAGE_EVENT_ChannelChanged);

		Message.SetPropertyInt(MESSAGE_PROPERTY_TuningSpace,Space);
		Message.SetPropertyInt(MESSAGE_PROPERTY_Channel,Channel);
		if (ServiceID!=0)
			Message.SetPropertyInt(MESSAGE_PROPERTY_ServiceID,ServiceID);

		BroadcastMessage(Message);
	}
int		XPCPushButtonMessageAttachment::HandleWidgetMessage(
								XPCWidget *		inObject,
								XPWidgetMessage	inMessage,
								XPWidgetID		inWidget,
								long			inParam1,
								long			inParam2)
{
	if ((inMessage == xpMsg_PushButtonPressed) && ((XPWidgetID) inParam1 == mWidget))
	{
		BroadcastMessage(mMsg, mParam);
		return 1;
	}

	if ((inMessage == xpMsg_ButtonStateChanged) && ((XPWidgetID) inParam1 == mWidget))
	{
		BroadcastMessage(mMsg, mParam);
		return 1;
	}
	return 0;	
}					
Beispiel #26
0
void MythPianoService::StartPlayback() {
	BroadcastMessage("Starting playback... \n");
	
	rlen = sprintf(request, "stop now\n");
	SendPianodRequest(200);
	rlen = sprintf(request, "select station \"%s\"\n", stations[current_station].c_str());
	SendPianodRequest(200);
	rlen = sprintf(request, "play\n");
	SendPianodRequest(200);

	if(response->back().code != 200) {
		BroadcastMessage("Failed to start playback!\n");
		return;
	}


	if(playlist.size() == 0) {
		BroadcastMessage("Empty playlist");
		return;
	}
}
Beispiel #27
0
//============================================================================
//		NPreferences::SetValue : Set a value.
//----------------------------------------------------------------------------
void NPreferences::SetValue(const NString &theKey, const NVariant &theValue)
{


	// Validate our parameters
	NN_ASSERT(!theKey.IsEmpty());
	


	// Set the value
	NTargetPreferences::SetValue(theKey, theValue);
	BroadcastMessage(kMsgNPreferenceValueChanged, &theKey);
}
Beispiel #28
0
void MythPianoService::GetPlaylist()
{
  PianoReturn_t pRet;
  WaitressReturn_t wRet;
  PianoRequestDataGetPlaylist_t reqData;
  reqData.station = m_CurrentStation;
  reqData.format = PIANO_AF_AACPLUS;

  BroadcastMessage("Receiving new playlist... ");
  if (!PianoCall(PIANO_REQUEST_GET_PLAYLIST, &reqData, &pRet, &wRet)) {
    m_CurrentStation = NULL;
    m_CurrentSong = NULL;
  } else {
    m_Playlist = reqData.retPlaylist; 
    m_CurrentSong = m_Playlist;
    if (m_Playlist == NULL) {
      BroadcastMessage("No tracks left.\n");
      m_CurrentStation = NULL;
      m_CurrentSong = NULL;
    }
  }
}
Beispiel #29
0
	void CClientManager::OnRecordingStarted(const RecordingInfo &Info)
	{
		CMessage Message(MESSAGE_EVENT_RecordingStarted);

		String Directory,FileName;
		PathUtility::Split(Info.FilePaths.front(),&Directory,&FileName);

		Message.SetProperty(MESSAGE_PROPERTY_FileName,FileName);
		Message.SetProperty(MESSAGE_PROPERTY_Directory,Directory);
		Message.SetProperty(MESSAGE_PROPERTY_ServiceSelect,CMessageProperty::IntType(Info.Settings.ServiceSelect));

		BroadcastMessage(Message);
	}
Beispiel #30
0
void		WED_PackageMgr::RenameCustomPackage(int n, const string& new_name)
{
	string oldn = system_path + DIR_STR CUSTOM_PACKAGE_PATH DIR_STR + custom_package_names[n];
	string newn = system_path + DIR_STR CUSTOM_PACKAGE_PATH DIR_STR + new_name;
	int res = FILE_rename_file(oldn.c_str(), newn.c_str());
	if (res != 0)
	{
		wed_error_exception e(res, __FILE__ , __LINE__);
		WED_ReportExceptionUI(e, "Unable to rename package %s to %s",oldn.c_str(), newn.c_str());
	} else
		custom_package_names[n] = new_name;

	BroadcastMessage(msg_SystemFolderUpdated,0);
}