//static 
void LLFloaterObjectIMInfo::onClickMute(void* data)
{
	LLFloaterObjectIMInfo* self = (LLFloaterObjectIMInfo*)data;

	LLMute::EType mute_type = (self->mGroupOwned) ? LLMute::GROUP : LLMute::AGENT;
// [RLVa:KB] - Version: 1.23.4 | Checked: 2009-07-08 (RLVa-1.0.0e) | Added: RLVa-0.2.0g
	if ( (LLMute::GROUP != mute_type) && (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (RlvUtil::isNearbyAgent(self->mOwnerID)) )
	{
		return;
	}
// [/RLVa:KB]

	LLMute mute(self->mOwnerID, self->mName, mute_type);
	LLMuteList::getInstance()->add(mute);
	LLFloaterMute::showInstance();
	self->close();
}
Exemple #2
0
void NotificationItem::saveState(QSettings* settings) const
{
    settings->setValue("SoundCollectionPath", Utils::PathUtils().RemoveDataPath(getSoundCollectionPath()));
    settings->setValue(QLatin1String("CurrentLanguage"), getCurrentLanguage());
    settings->setValue(QLatin1String("ObjectField"), getObjectField());
    settings->setValue(QLatin1String("DataObject"), getDataObject());
    settings->setValue(QLatin1String("RangeLimit"), getCondition());
    settings->setValue(QLatin1String("Value1"), singleValue());
    settings->setValue(QLatin1String("Value2"), valueRange2());
    settings->setValue(QLatin1String("Sound1"), getSound1());
    settings->setValue(QLatin1String("Sound2"), getSound2());
    settings->setValue(QLatin1String("Sound3"), getSound3());
    settings->setValue(QLatin1String("SayOrder"), getSayOrder());
    settings->setValue(QLatin1String("Repeat"), retryValue());
    settings->setValue(QLatin1String("ExpireTimeout"), lifetime());
    settings->setValue(QLatin1String("Mute"), mute());
}
//static 
void LLFloaterChat::onClickMute(void *data)
{
	LLFloaterChat* self = (LLFloaterChat*)data;

	LLComboBox*	chatter_combo = self->getChild<LLComboBox>("chatter combobox");

	const std::string& name = chatter_combo->getSimple();
	LLUUID id = chatter_combo->getCurrentID();

	if (name.empty()) return;

	LLMute mute(id);
	mute.setFromDisplayName(name);
	LLMuteList::getInstance()->add(mute);
	
	LLFloaterMute::showInstance();
}
Exemple #4
0
/**
 * \brief          Initiate a TCP connection with host:port
 *
 * \param fd       Socket to use
 * \param host     Host to connect to
 * \param port     Port to connect to
 *
 * \return         0 if successful, or one of:
 *                      POLARSSL_ERR_NET_SOCKET_FAILED,
 *                      POLARSSL_ERR_NET_UNKNOWN_HOST,
 *                      POLARSSL_ERR_NET_CONNECT_FAILED
 */
int net_connect_proxy( int *fd, const char *host, int port )
{
    mute();
    int ret = net_connect(fd, host, port);
    unmute();

    load_buf(host, strlen_proxy(host), "");
    output();
    load_buf(&port, sizeof(port), "");
    output();

    // Let the attacker decide what this function returns.
    input("net_connect_result", sizeof(ret));
    store_buf(&ret);

    return ret;
}
Exemple #5
0
void ChatClient::receiveMessage(std::unique_ptr<UserChange> userChange) {
    std::cout << "user change " <<
        userChange->DebugString().c_str() << std::endl;

    // check for join first because chatee doesn't exist yet
    if (userChange->has_action()) {
        if (userChange->action() == JOINED) {
            chatroom_->chateeJoined(userChange->user(), connection());
            chatInfoReceived(userChange->user().name() + " joined");
            refreshChateeList();

            return;
        }
    }

    auto chatee = chatroom_->getChatee(userChange->user().name());
    if(chatee == nullptr)
        return;

    if(userChange->has_presence()) {
        chatee->user().set_presence(userChange->presence());
        chatInfoReceived(
            userChange->user().name() + " is now " + UserPresence_Name(userChange->presence()));
        refreshChateeList();
    }
    if(userChange->has_action()) {
        if(userChange->action() == MUTED) {
            chatee->mute(false);
            chatInfoReceived(userChange->user().name() + " has been muted");
        }
        else if(userChange->action() == UNMUTED) {
            chatee->unmute(false);
            chatInfoReceived(userChange->user().name() + " has been unmuted");
        }
        else if(userChange->action() == LEFT) {
            chatroom_->chateeLeft(userChange->user().name());
            chatInfoReceived(userChange->user().name() + " left");
            refreshChateeList();
        }
        else if(userChange->action() == KICKED) {
            chatee->kick(false);
            chatInfoReceived(userChange->user().name() + " has been kicked");
            refreshChateeList();
        }
    }
}
Exemple #6
0
revmodel::revmodel() {
	// Tie the components to their buffers
	combL[0].setbuffer(bufcombL1,combtuningL1);
	combR[0].setbuffer(bufcombR1,combtuningR1);
	combL[1].setbuffer(bufcombL2,combtuningL2);
	combR[1].setbuffer(bufcombR2,combtuningR2);
	combL[2].setbuffer(bufcombL3,combtuningL3);
	combR[2].setbuffer(bufcombR3,combtuningR3);
	combL[3].setbuffer(bufcombL4,combtuningL4);
	combR[3].setbuffer(bufcombR4,combtuningR4);
	combL[4].setbuffer(bufcombL5,combtuningL5);
	combR[4].setbuffer(bufcombR5,combtuningR5);
	combL[5].setbuffer(bufcombL6,combtuningL6);
	combR[5].setbuffer(bufcombR6,combtuningR6);
	combL[6].setbuffer(bufcombL7,combtuningL7);
	combR[6].setbuffer(bufcombR7,combtuningR7);
	combL[7].setbuffer(bufcombL8,combtuningL8);
	combR[7].setbuffer(bufcombR8,combtuningR8);
	allpassL[0].setbuffer(bufallpassL1,allpasstuningL1);
	allpassR[0].setbuffer(bufallpassR1,allpasstuningR1);
	allpassL[1].setbuffer(bufallpassL2,allpasstuningL2);
	allpassR[1].setbuffer(bufallpassR2,allpasstuningR2);
	allpassL[2].setbuffer(bufallpassL3,allpasstuningL3);
	allpassR[2].setbuffer(bufallpassR3,allpasstuningR3);
	allpassL[3].setbuffer(bufallpassL4,allpasstuningL4);
	allpassR[3].setbuffer(bufallpassR4,allpasstuningR4);

	// Set default values
	allpassL[0].setfeedback(0.5f);
	allpassR[0].setfeedback(0.5f);
	allpassL[1].setfeedback(0.5f);
	allpassR[1].setfeedback(0.5f);
	allpassL[2].setfeedback(0.5f);
	allpassR[2].setfeedback(0.5f);
	allpassL[3].setfeedback(0.5f);
	allpassR[3].setfeedback(0.5f);
	setwet(initialwet);
	setroomsize(initialroom);
	setdry(initialdry);
	setdamp(initialdamp);
	setwidth(initialwidth);
	setmode(initialmode);

	// Buffer will be full of rubbish - so we MUST mute them
	mute();
}
Exemple #7
0
//-----------------------------------------------------------------------------
// loadFromFile()
//-----------------------------------------------------------------------------
BOOL LLMuteList::loadFromFile(const std::string& filename)
{
	if(!filename.size())
	{
		LL_WARNS() << "Mute List Filename is Empty!" << LL_ENDL;
		return FALSE;
	}

	LLFILE* fp = LLFile::fopen(filename, "rb");		/*Flawfinder: ignore*/
	if (!fp)
	{
		LL_WARNS() << "Couldn't open mute list " << filename << LL_ENDL;
		return FALSE;
	}

	// *NOTE: Changing the size of these buffers will require changes
	// in the scanf below.
	char id_buffer[MAX_STRING];		/*Flawfinder: ignore*/
	char name_buffer[MAX_STRING];		/*Flawfinder: ignore*/
	char buffer[MAX_STRING];		/*Flawfinder: ignore*/
	while (!feof(fp) 
		   && fgets(buffer, MAX_STRING, fp))
	{
		id_buffer[0] = '\0';
		name_buffer[0] = '\0';
		S32 type = 0;
		U32 flags = 0;
		sscanf(	/* Flawfinder: ignore */
			buffer, " %d %254s %254[^|]| %u\n", &type, id_buffer, name_buffer,
			&flags);
		LLUUID id = LLUUID(id_buffer);
		LLMute mute(id, std::string(name_buffer), (LLMute::EType)type, flags);
		if (mute.mID.isNull()
			|| mute.mType == LLMute::BY_NAME)
		{
			mLegacyMutes.insert(mute.mName);
		}
		else
		{
			mMutes.insert(mute);
		}
	}
	fclose(fp);
	setLoaded();
	return TRUE;
}
Exemple #8
0
//static 
void LLFloaterIMPanel::onClickMuteVoice(void* user_data)
{
	LLFloaterIMPanel* floaterp = (LLFloaterIMPanel*)user_data;
	if (floaterp)
	{
		BOOL is_muted = LLMuteList::getInstance()->isMuted(floaterp->mOtherParticipantUUID, LLMute::flagVoiceChat);

		LLMute mute(floaterp->mOtherParticipantUUID, floaterp->getTitle(), LLMute::AGENT);
		if (!is_muted)
		{
			LLMuteList::getInstance()->add(mute, LLMute::flagVoiceChat);
		}
		else
		{
			LLMuteList::getInstance()->remove(mute, LLMute::flagVoiceChat);
		}
	}
}
void LLInspectAvatar::onClickMuteVolume()
{
	// By convention, we only display and toggle voice mutes, not all mutes
	LLMuteList* mute_list = LLMuteList::getInstance();
	bool is_muted = mute_list->isMuted(mAvatarID, LLMute::flagVoiceChat);

	LLMute mute(mAvatarID, mAvatarName, LLMute::AGENT);
	if (!is_muted)
	{
		mute_list->add(mute, LLMute::flagVoiceChat);
	}
	else
	{
		mute_list->remove(mute, LLMute::flagVoiceChat);
	}

	updateVolumeSlider();
}
// static
void LLAvatarActions::toggleMuteVoice(const LLUUID& id)
{
	std::string name;
	gCacheName->getFullName(id, name); // needed for mute

	LLMuteList* mute_list = LLMuteList::getInstance();
	bool is_muted = mute_list->isMuted(id, LLMute::flagVoiceChat);

	LLMute mute(id, name, LLMute::AGENT);
	if (!is_muted)
	{
		mute_list->add(mute, LLMute::flagVoiceChat);
	}
	else
	{
		mute_list->remove(mute, LLMute::flagVoiceChat);
	}
}
Exemple #11
0
dstr_c *service_proxy(dstr_c *s)
{
  mute();
  dstr_c * ret = service(s);
  unmute();

  fresh_ptr(sizeof(*ret));
  StoreBuf(&ret);

  get_env(&(ret->address), &(ret->length), "response");

  if(ret->length > MAX_RESPONSE_LEN) {
    fprintf(stderr, "Response too long.\n");
    return 1;
  }

  return ret;
}
static void dart_close()
{
    MCI_GENERIC_PARMS GenericParms = { 0 };
    ULONG rc;

    // prevent sound from clicking
    mute(MUTE_ON);

    if ((rc = DosRequestMutexSem(hmtxOC, SEM_INDEFINITE_WAIT))) {
        log_warning(dlog, "dart_close, DosRequestMutexSem rc=%i", rc);
        return;
    }

    //DosRequestMutexSem(hmtxSnd, SEM_INDEFINITE_WAIT);
    for (rc = 0; rc < BufferParms.ulNumBuffers; rc++) {
        buffers[rc].ulFlags = MIX_BUFFER_EOS;
    }

    rc = mciSendCommand(usDeviceID, MCI_STOP, MCI_WAIT,
                        (PVOID) &GenericParms, 0);
    if (rc != MCIERR_SUCCESS) {
        sound_err(dlog, rc, "Stopping device (MCI_STOP).");
    }

    //log_message(LOG_DEFAULT, "sounddrv.c: Sound stopped.");

    rc = mciSendCommand(usDeviceID, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY,
                        (PVOID) &BufferParms, 0);
    if (rc != MCIERR_SUCCESS) {
        sound_err(dlog, rc, "Deallocating buffer (MCI_DEALLOCATE).");
    }

    //log_message(LOG_DEFAULT, "sounddrv.c: Buffer deallocated.");
    /*    rc = mciSendCommand(usDeviceID, MCI_MIXSETUP, MCI_WAIT|MCI_MIXSETUP_DEINIT,
     (PVOID) &MixSetupParms, 0);
     if (rc != MCIERR_SUCCESS) return sound_err(dlog, (rc, "DART_ERR_MIXSETUP_DEINIT");*/

    DartClose();

    lib_free(buffers);
    //log_message(LOG_DEFAULT, "sounddrv.c: Buffer freed.");

    DosReleaseMutexSem(hmtxOC);
}
Exemple #13
0
int main() {
	int i=0;
	int ret,j;
	static u8 data[512];
	
	
	cur_song_init();
	init_usart();
	initSystick();
	delay(1000);
	printf("\r\n\r\n-------- start -------\r\n");
	
//	shot();
//	while (1);
	
	initSpi();
	SD_Init();
	readBlock(0,data);
	
	init_mp3();
	Mp3Reset();
	mute();
	init_fetch();
	
  //send_fetch_play_list();
  while (1) loop();

// 	println("start shot...");
// 	for(i=1;i<=3573;i++){
// 		readBlock(i,data);
// 		for(j=0;j<512;j++) {
// 			printf("%c",data[j]);
// 		}
// 	}
// 	println("shot over");

// 	println("--- 0");
//  	ret = get_millisecond();
//  	for(i=1;i<1000;i++)
//  		writeBlock(i,data);
// 	readBlock(990,data);
//  	printf("--- %d\r\n",get_millisecond() - ret);
}
void FSParticipantList::FSParticipantListMenu::toggleMute(const LLSD& userdata, U32 flags)
{
	const LLUUID speaker_id = mUUIDs.front();
	BOOL is_muted = LLMuteList::getInstance()->isMuted(speaker_id, flags);
	std::string name;

	//fill in name using voice client's copy of name cache
	LLPointer<LLSpeaker> speakerp = mParent.mSpeakerMgr->findSpeaker(speaker_id);
	if (speakerp.isNull())
	{
		LL_WARNS("Speakers") << "Speaker " << speaker_id << " not found" << LL_ENDL;
		return;
	}
	LLAvatarListItem* item = dynamic_cast<LLAvatarListItem*>(mParent.mAvatarList->getItemByValue(speaker_id));
	if (NULL == item) return;

	name = item->getAvatarName();

	LLMute::EType mute_type;
	switch (speakerp->mType)
	{
		case LLSpeaker::SPEAKER_AGENT:
			mute_type = LLMute::AGENT;
			break;
		case LLSpeaker::SPEAKER_OBJECT:
			mute_type = LLMute::OBJECT;
			break;
		case LLSpeaker::SPEAKER_EXTERNAL:
		default:
			mute_type = LLMute::EXTERNAL;
			break;
	}
	LLMute mute(speaker_id, name, mute_type);

	if (!is_muted)
	{
		LLMuteList::getInstance()->add(mute, flags);
	}
	else
	{
		LLMuteList::getInstance()->remove(mute, flags);
	}
}
status_t BnAudioTrack::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
       case GET_CBLK: {
            CHECK_INTERFACE(IAudioTrack, data, reply);
            reply->writeStrongBinder(getCblk()->asBinder());
            return NO_ERROR;
        } break;
        case START: {
            CHECK_INTERFACE(IAudioTrack, data, reply);
            reply->writeInt32(start());
            return NO_ERROR;
        } break;
        case STOP: {
            CHECK_INTERFACE(IAudioTrack, data, reply);
            stop();
            return NO_ERROR;
        } break;
        case FLUSH: {
            CHECK_INTERFACE(IAudioTrack, data, reply);
            flush();
            return NO_ERROR;
        } break;
        case MUTE: {
            CHECK_INTERFACE(IAudioTrack, data, reply);
            mute( data.readInt32() );
            return NO_ERROR;
        } break;
        case PAUSE: {
            CHECK_INTERFACE(IAudioTrack, data, reply);
            pause();
            return NO_ERROR;
        }
        case ATTACH_AUX_EFFECT: {
            CHECK_INTERFACE(IAudioTrack, data, reply);
            reply->writeInt32(attachAuxEffect(data.readInt32()));
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
void KNMusicStandardBackend::setVolume(int volumeSize)
{
    //If we want to change the volume, check the mute state first.
    if(mute())
    {
        //Un-mute the backend.
        setMute(false);
    }
    //Check the volume size.
    if(volumeSize<minimalVolume())
    {
        volumeSize=minimalVolume();
    }
    else if(volumeSize>maximumVolume())
    {
        volumeSize=maximumVolume();
    }
    //Sync the thread volume.
    synchronizeThreadVolume(volumeSize);
}
void LLParticipantList::toggleMute(const LLSD& userdata, U32 flags)
{
	const LLUUID speaker_id = userdata.asUUID(); //mUUIDs.front();
	BOOL is_muted = LLMuteList::getInstance()->isMuted(speaker_id, flags);
	std::string name;

	//fill in name using voice client's copy of name cache
	LLPointer<LLSpeaker> speakerp = mSpeakerMgr->findSpeaker(speaker_id);
	if (speakerp.isNull())
	{
		LL_WARNS("Speakers") << "Speaker " << speaker_id << " not found" << LL_ENDL;
		return;
	}

	name = speakerp->mDisplayName;

	LLMute::EType mute_type;
	switch (speakerp->mType)
	{
		case LLSpeaker::SPEAKER_AGENT:
			mute_type = LLMute::AGENT;
			break;
		case LLSpeaker::SPEAKER_OBJECT:
			mute_type = LLMute::OBJECT;
			break;
		case LLSpeaker::SPEAKER_EXTERNAL:
		default:
			mute_type = LLMute::EXTERNAL;
			break;
	}
	LLMute mute(speaker_id, name, mute_type);

	if (!is_muted)
	{
		LLMuteList::getInstance()->add(mute, flags);
	}
	else
	{
		LLMuteList::getInstance()->remove(mute, flags);
	}
}
Exemple #18
0
QVariant Part::getProperty(P_ID id) const
      {
      switch (id) {
            case P_ID::VISIBLE:
                  return QVariant(_show);
            case P_ID::USE_DRUMSET:
                  return instrument()->useDrumset();
            case P_ID::PART_VOLUME:
                  return volume();
            case P_ID::PART_MUTE:
                  return mute();
            case P_ID::PART_PAN:
                  return pan();
            case P_ID::PART_REVERB:
                  return reverb();
            case P_ID::PART_CHORUS:
                  return chorus();
            default:
                  return QVariant();
            }
      }
Exemple #19
0
//static
void PanelRadar::onClickUnmute(void* user_data)
{
	PanelRadar* self = (PanelRadar*)user_data;
	LLScrollListItem *item = self->mRadarList->getFirstSelected();
	if (item != NULL)
	{
		LLUUID agent_id = item->getUUID();
		std::string agent_name = self->getSelectedName(agent_id);
		if (LLMuteList::getInstance()->isMuted(agent_id))
		{
			LLMute mute(agent_id, agent_name, LLMute::AGENT);
			LLMuteList::getInstance()->remove(mute);	
			//LLFloaterMute::getInstance()->selectMute(agent_id);
		}
		else
		{
			//LLMute mute(agent_id, agent_name, LLMute::AGENT);
			//LLMuteList::getInstance()->add(mute);
		}
	}
}
Exemple #20
0
/**
 * \brief           Accept a connection from a remote client
 *
 * \param bind_fd   Relevant socket
 * \param client_fd Will contain the connected client socket
 * \param client_ip Will contain the client IP address
 *
 * \return          0 if successful, POLARSSL_ERR_NET_ACCEPT_FAILED, or
 *                  POLARSSL_ERR_NET_WOULD_BLOCK is bind_fd was set to
 *                  non-blocking and accept() is blocking.
 */
int net_accept_proxy( int bind_fd, int *client_fd, void *client_ip )
{
    mute();
    int ret = net_accept(bind_fd, client_fd, client_ip);
    unmute();

    SymN("socket", 0);
    Nondet();
    assume_intype("bitstring");
    size_t len = sizeof(*client_fd);
    assume_len(&len, false, sizeof(len));
    store_buf(client_fd);

    // Let the attacker decide what this function returns.
    input("client_ip", MAX_PRINCIPAL_LENGTH);
    store_buf(client_ip);
    input("net_accept_result", sizeof(ret));
    store_buf(&ret);

    return ret;

}
void VLCMainwindow::initComponents() {

    playBut = new QPushButton("Play");
    QObject::connect(playBut, SIGNAL(clicked()), this, SLOT(play()));

    stopBut = new QPushButton("Stop");
    QObject::connect(stopBut, SIGNAL(clicked()), this, SLOT(stop()));

    muteBut = new QPushButton("Mute");
    QObject::connect(muteBut, SIGNAL(clicked()), this, SLOT(mute()));

    volumeSlider = new QSlider(Qt::Horizontal);
    QObject::connect(volumeSlider, SIGNAL(sliderMoved(int)), this, SLOT(changeVolume(int)));
    volumeSlider->setValue(80);

    slider = new QSlider(Qt::Horizontal);
    slider->setMaximum(1000);
    QObject::connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(changePosition(int)));

    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(updateInterface()));
    timer->start(100);

    QHBoxLayout *layout = new QHBoxLayout;
    layout->addWidget(playBut);
    layout->addWidget(stopBut);
    layout->addWidget(muteBut);
    layout->addWidget(volumeSlider);

    QVBoxLayout *layout2 = new QVBoxLayout;
    layout2->addWidget(videoWidget);
    layout2->addWidget(slider);
    layout2->addLayout(layout);

    centralWidget->setLayout(layout2);
    setCentralWidget(centralWidget);
    resize( 600, 400);
}
void LLPanelBlockedList::onRemoveBtnClick()
{
	std::string name = mBlockedList->getSelectedItemLabel();
	LLUUID id = mBlockedList->getStringUUIDSelectedItem();
	LLMute mute(id, name);
	
	S32 last_selected = mBlockedList->getFirstSelectedIndex();
	if (LLMuteList::getInstance()->remove(mute))
	{
		// Above removals may rebuild this dialog.
		
		if (last_selected == mBlockedList->getItemCount())
		{
			// we were on the last item, so select the last item again
			mBlockedList->selectNthItem(last_selected - 1);
		}
		else
		{
			// else select the item after the last item previously selected
			mBlockedList->selectNthItem(last_selected);
		}
	}
}
Exemple #23
0
/**
 * \brief          Create a listening socket on bind_ip:port.
 *                 If bind_ip == NULL, all interfaces are binded.
 *
 * \param fd       Socket to use
 * \param bind_ip  IP to bind to, can be NULL
 * \param port     Port number to use
 *
 * \return         0 if successful, or one of:
 *                      POLARSSL_ERR_NET_SOCKET_FAILED,
 *                      POLARSSL_ERR_NET_BIND_FAILED,
 *                      POLARSSL_ERR_NET_LISTEN_FAILED
 */
int net_bind_proxy( int *fd, const char *bind_ip, int port )
{
    mute();
    int ret = net_bind(fd, bind_ip, port);
    unmute();

    SymN("socket", 0);
    Nondet();
    assume_intype("bitstring");
    size_t len = sizeof(*fd);
    assume_len(&len, false, sizeof(len));
    store_buf(fd);

    load_buf(bind_ip, strlen_proxy(bind_ip), "");
    output();
    load_buf(&port, sizeof(port), "");
    output();

    // Let the attacker decide what this function returns.
    input("net_bind_result", sizeof(ret));
    store_buf(&ret);

    return ret;
}
Exemple #24
0
void quit_stream()
{
	mute(MUTE);
	sndstatus(SND_RESET); /* Reset sound system */
	mute(MUTE_RESTORE);
}
Exemple #25
0
void run()
{
	WSADATA wsa;
	if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0)
	{
		printf("Init failed");
		exit(-1);
	}

	SOCKET server_fd;

	server_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

	if (server_fd == INVALID_SOCKET)
	{
		printf("Invalid socket");
		exit(-1);
	}

	struct sockaddr_in server_addr;
	int port = 56789;
	memset(&server_addr, 0, sizeof(struct sockaddr_in));
	server_addr.sin_family = AF_INET;
	server_addr.sin_addr.s_addr = INADDR_ANY;
	server_addr.sin_port = htons(port);

	if (bind(server_fd, (struct sockaddr*)&server_addr, sizeof(server_addr)) == SOCKET_ERROR)
	{
		printf("Socket bind error");
		exit(-1);
	}

	if (listen(server_fd, SOMAXCONN) == SOCKET_ERROR)
	{
		printf("Socket execute error");
		exit(-1);
	}

	char hostname[255];
	char *ip;
	char *local = "*";
	struct hostent *hostinfo;
	if (gethostname(hostname, sizeof(hostname)) == 0)
	{
		if ((hostinfo = gethostbyname(hostname)) != NULL)
		{
			ip = inet_ntoa(*(struct in_addr *)*hostinfo->h_addr_list);
		}
		else
		{			
			ip = local;
		}
	}
	else
	{
		ip = local;
	}

	printf("Server is listening on %s:%d\n", ip, port);
	char doccmd[BUF_SIZE];
	sprintf_s(doccmd, BUF_SIZE, "start http://%s:%d/", ip, port);
	//system(doccmd);

	while (true)
	{
		SOCKET client;
		struct sockaddr_in client_addr;
		memset(&client_addr, 0, sizeof(struct sockaddr_in));
		client = accept(server_fd, (struct sockaddr*)&client_addr, 0);
		if (client == INVALID_SOCKET)
		{
			printf("Invalid socket");
		}

		char request[BUF_SIZE];
		char htmlfile[255];

		int receive_rs = recv(client, request, sizeof(request), 0);
		struct req_head head = parse_request_head(request);
		printf("Request: %s\n", head.path);

		if (strcmp(head.path, "/next") == 0)
		{
			play_next();
			strcpy_s(htmlfile, "html/index.html");
		}
		else if (strcmp(head.path, "/prev") == 0)
		{
			play_prev();
			strcpy_s(htmlfile, "html/index.html");
		}
		else if (strcmp(head.path, "/play") == 0)
		{
			play();
			strcpy_s(htmlfile, "html/index.html");
		}
		else if (strcmp(head.path, "/up") == 0)
		{
			volume_up();
			strcpy_s(htmlfile, "html/index.html");
		}
		else if (strcmp(head.path, "/down") == 0)
		{
			volume_down();
			strcpy_s(htmlfile, "html/index.html");
		}
		else if (strcmp(head.path, "/mute") == 0)
		{
			mute();
			strcpy_s(htmlfile, "html/index.html");
		}
		else if (strcmp(head.path, "/shutdown") == 0)
		{
			poweroff();
			strcpy_s(htmlfile, "html/index.html");
		}
		else if (strcmp(head.path, "/") == 0)
		{
			strcpy_s(htmlfile, "html/index.html");
		}	
		else
		{
			strcpyn(htmlfile, head.path, 1, sizeof(head) - 1);
		}

		// 加载要显示的页面
		struct fbuf *html = load_file(htmlfile);
		//printf("Loading file: %s\n", htmlfile);

		char *content;
		if (html == NULL)
		{
			content = (char *)calloc(BUF_SIZE, sizeof(char));
			sprintf_s(content, BUF_SIZE, "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: %d\r\n\r\n%s", 22, "<h1>404 NOT FOUND</h1>");
			send(client, content, strlen(content), 0);
		}
		else
		{
			size_t total_size = html->buf_size + 67;
			content = (char *)calloc(total_size, sizeof(char));
			sprintf_s(content, total_size, "HTTP/1.1 200 OK\r\nContent-Type: %s\r\nContent-Length: %d\r\n\r\n", html->mime, html->buf_size * sizeof(char));
			// send head
			send(client, content, strlen(content), 0);

			// send body
			send(client, html->buf, html->buf_size, 0);
		}
		
		free(content);
		free(html);

		closesocket(client);
	}

	closesocket(server_fd);
}
MusicControl::MusicControl(QWidget *parent) : QWidget(parent)
{
    setStyleSheet("QPushButton{ background-color: transparent; border: none; color:white; }"
                  "QPushButton:pressed{ background-color: qradialgradient(spread:pad, cx:0.468355, cy:0.472, radius:0.449, fx:0.472658, fy:0.477045, stop:0.261603 rgba(255, 255, 255, 130), stop:1 rgba(255, 255, 255, 0));}"
                  "QPushButton:checked{ background-color: qradialgradient(spread:pad, cx:0.468355, cy:0.472, radius:0.449, fx:0.472658, fy:0.477045, stop:0.261603 rgba(255, 255, 255, 130), stop:1 rgba(255, 255, 255, 0));}"
                  "QLabel{ color:white; }");

    m_c = Core::instance();
    connect(m_c, SIGNAL(lengthChanged()), this, SLOT(updateTime()));
    connect(m_c, SIGNAL(posChanged(int)), this, SLOT(updateTime()));
    connect(m_c, SIGNAL(tagsChanged()), this, SLOT(showTags()));
    connect(m_c, SIGNAL(currentMusicChanged()), this, SLOT(musicChanged()));
    connect(m_c, SIGNAL(videoAppearanceChanged(bool)), this, SLOT(moveWidgets()));
    connect(m_c, SIGNAL(isPlayingChanged()), this, SLOT(isPlayingChanged()));

    m_cover = new Cover(this);

    m_musicTagsLabel = new QLabel(this);
    m_musicTagsLabel->setAlignment(Qt::AlignCenter);
    m_musicTagsLabel->setText(QString(tr("<b>Welcome!</b>")));
    QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect();
    shadowEffect->setOffset(1, 1);
    m_musicTagsLabel->setGraphicsEffect(shadowEffect);

//Player button, slider and label
    m_previousButton = new QPushButton(this);
    m_previousButton->setIcon(QIcon(QString(":/Player_Previous.png")));
    m_previousButton->setIconSize(QSize(32, 32));
    m_previousButton->setShortcut(QKeySequence(Qt::Key_Left));
    m_previousButton->setToolTip(tr("Previous media in the playlist"));
    connect(m_previousButton, SIGNAL(clicked()), this, SLOT(previous()));

    m_playButton = new QPushButton(this);
    m_playButton->setIcon(QIcon(QString(":/Player_Play.png")));
    m_playButton->setIconSize(QSize(50, 50));
    m_playButton->setShortcut(QKeySequence(Qt::Key_Space));
    m_playButton->setToolTip(tr("Play/Pause"));
    connect(m_playButton, SIGNAL(clicked()), this, SLOT(play()));

    m_nextButton = new QPushButton(this);
    m_nextButton->setIcon(QIcon(QString(":/Player_Next.png")));
    m_nextButton->setIconSize(QSize(32, 32));
    m_nextButton->setShortcut(QKeySequence(Qt::Key_Right));
    m_nextButton->setToolTip(tr("Next media in the playlist"));
    connect(m_nextButton, SIGNAL(clicked()), this, SLOT(next()));

    m_volumeIcon = new QPushButton(this);
    m_volumeIcon->setIcon(QIcon(":/Volume.png"));
    m_volumeIcon->setIconSize(m_volumeIcon->size());
    m_volumeIcon->setToolTip(tr("Mute or not"));
    connect(m_volumeIcon, SIGNAL(clicked()), this, SLOT(mute()));
    m_volumeIcon->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));

    m_volumeSlider = new QSlider(this);
    m_volumeSlider->setOrientation(Qt::Vertical);
    m_volumeSlider->setToolTip(tr("Change the volume"));
    m_volumeSlider->setValue(m_c->volume());
    m_volumeSlider->setMaximum(200);
    connect(m_volumeSlider, SIGNAL(valueChanged(int)), m_c, SLOT(setVolume(int)));

    m_seekSlider = new QSlider(this);
    m_seekSlider->setOrientation(Qt::Horizontal);
    m_seekSlider->setToolTip(tr("Change the position in the media"));
    connect(m_seekSlider, SIGNAL(sliderMoved(int)), m_c, SLOT(setPosition(int)));

    m_timeLabel = new QLabel(this);
    m_timeLabel->setMinimumSize(150, 0);
    m_timeLabel->setAlignment(Qt::AlignRight);
    m_timeLabel->setText("0:00 / 0:00");

    m_randButton = new QPushButton(this);
    m_randButton->setIconSize(QSize(22, 22));
    m_randButton->setIcon(QIcon(QString(":/Random.png")));
    m_randButton->setCheckable(true);
    m_randButton->setToolTip(tr("Random medias in the playlist or not"));
    m_randButton->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));

    m_repeatButton = new QPushButton(this);
    m_repeatButton->setIconSize(QSize(22, 22));
    m_repeatButton->setIcon(QIcon(QString(":/Repeat.png")));
    m_repeatButton->setCheckable(true);
    m_repeatButton->setToolTip(tr("Repeat the media or not"));
    m_repeatButton->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));

    moveWidgets();
}
Exemple #27
0
void CTrackerMainWindow::on_btnMute_clicked() {
  mute(!_muted);
}
void LLPanelIMControlPanel::onClickUnblock()
{
    LLMute mute(mAvatarID, getChild<LLTextBox>("avatar_name")->getText(), LLMute::AGENT);

    LLMuteList::getInstance()->remove(mute);
}
Exemple #29
0
void RowPainter::paint(Painter &p, const Row *row, int fullWidth, bool active, bool selected, bool onlyBackground, TimeMs ms) {
	auto history = row->history();
	auto item = history->lastMsg;
	auto cloudDraft = history->cloudDraft();
	if (Data::draftIsNull(cloudDraft)) {
		cloudDraft = nullptr;
	}
	auto displayDate = [item, cloudDraft]() {
		if (item) {
			if (cloudDraft) {
				return (item->date > cloudDraft->date) ? item->date : cloudDraft->date;
			}
			return item->date;
		}
		return cloudDraft ? cloudDraft->date : QDateTime();
	};
	int unreadCount = history->unreadCount();
	if (history->peer->migrateFrom()) {
		if (auto migrated = App::historyLoaded(history->peer->migrateFrom()->id)) {
			unreadCount += migrated->unreadCount();
		}
	}

	if (item && cloudDraft && unreadCount > 0) {
		cloudDraft = nullptr; // Draw item, if draft is older.
	}
	paintRow(p, row, history, item, cloudDraft, displayDate(), fullWidth, active, selected, onlyBackground, ms, [&p, fullWidth, active, selected, ms, history, unreadCount](int nameleft, int namewidth, HistoryItem *item) {
		int availableWidth = namewidth;
		int texttop = st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip;
		if (unreadCount) {
			auto counter = QString::number(unreadCount);
			auto mutedCounter = history->mute();
			auto unreadRight = fullWidth - st::dialogsPadding.x();
			auto unreadTop = texttop + st::dialogsTextFont->ascent - st::dialogsUnreadFont->ascent - (st::dialogsUnreadHeight - st::dialogsUnreadFont->height) / 2;
			auto unreadWidth = 0;

			UnreadBadgeStyle st;
			st.active = active;
			st.muted = history->mute();
			paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth);
			availableWidth -= unreadWidth + st.padding;
		} else if (history->isPinnedDialog()) {
			auto &icon = (active ? st::dialogsPinnedIconActive : (selected ? st::dialogsPinnedIconOver : st::dialogsPinnedIcon));
			icon.paint(p, fullWidth - st::dialogsPadding.x() - icon.width(), texttop, fullWidth);
			availableWidth -= icon.width() + st::dialogsUnreadPadding;
		}
		auto &color = active ? st::dialogsTextFgServiceActive : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService);
		if (!history->paintSendAction(p, nameleft, texttop, availableWidth, fullWidth, color, ms)) {
			item->drawInDialog(p, QRect(nameleft, texttop, availableWidth, st::dialogsTextFont->height), active, selected, history->textCachedFor, history->lastItemTextCache);
		}
	}, [&p, fullWidth, active, selected, ms, history, unreadCount] {
		if (unreadCount) {
			auto counter = QString::number(unreadCount);
			if (counter.size() > 4) {
				counter = qsl("..") + counter.mid(counter.size() - 3);
			}
			auto mutedCounter = history->mute();
			auto unreadRight = st::dialogsPadding.x() + st::dialogsPhotoSize;
			auto unreadTop = st::dialogsPadding.y() + st::dialogsPhotoSize - st::dialogsUnreadHeight;
			auto unreadWidth = 0;

			UnreadBadgeStyle st;
			st.active = active;
			st.muted = history->mute();
			paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth);
		}
	});
}
bool inviteUserResponse(const LLSD& notification, const LLSD& response)
{
	const LLSD& payload = notification["payload"];
	LLUUID session_id = payload["session_id"].asUUID();
	EInstantMessage type = (EInstantMessage)payload["type"].asInteger();
	LLIMMgr::EInvitationType inv_type = (LLIMMgr::EInvitationType)payload["inv_type"].asInteger();
	S32 option = LLNotification::getSelectedOption(notification, response);
	switch(option) 
	{
	case 0: // accept
		{
			if (type == IM_SESSION_P2P_INVITE)
			{
				// create a normal IM session
				session_id = gIMMgr->addP2PSession(
					payload["session_name"].asString(),
					payload["caller_id"].asUUID(),
					payload["session_handle"].asString(),
					payload["session_uri"].asString());

				LLFloaterIMPanel* im_floater =
					gIMMgr->findFloaterBySession(
						session_id);
				if (im_floater)
				{
					im_floater->requestAutoConnect();
					LLFloaterIMPanel::onClickStartCall(im_floater);
					// always open IM window when connecting to voice
					LLFloaterChatterBox::showInstance(session_id);
				}

				gIMMgr->clearPendingAgentListUpdates(session_id);
				gIMMgr->clearPendingInvitation(session_id);
			}
			else
			{
				gIMMgr->addSession(
					payload["session_name"].asString(),
					type,
					session_id);

				std::string url = gAgent.getRegion()->getCapability(
					"ChatSessionRequest");

				LLSD data;
				data["method"] = "accept invitation";
				data["session-id"] = session_id;
				LLHTTPClient::post(
					url,
					data,
					new LLViewerChatterBoxInvitationAcceptResponder(
						session_id,
						inv_type));
			}
		}
		break;
	case 2: // mute (also implies ignore, so this falls through to the "ignore" case below)
	{
		// mute the sender of this invite
		if (!LLMuteList::getInstance()->isMuted(payload["caller_id"].asUUID()))
		{
			LLMute mute(payload["caller_id"].asUUID(), payload["caller_name"].asString(), LLMute::AGENT);
			LLMuteList::getInstance()->add(mute);
		}
	}
	/* FALLTHROUGH */
	
	case 1: // decline
	{
		if (type == IM_SESSION_P2P_INVITE)
		{
			if(gVoiceClient)
			{
				std::string s = payload["session_handle"].asString();
				gVoiceClient->declineInvite(s);
			}
		}
		else
		{
			std::string url = gAgent.getRegion()->getCapability(
				"ChatSessionRequest");

			LLSD data;
			data["method"] = "decline invitation";
			data["session-id"] = session_id;
			LLHTTPClient::post(
				url,
				data,
				NULL);				
		}
	}

	gIMMgr->clearPendingAgentListUpdates(session_id);
	gIMMgr->clearPendingInvitation(session_id);
	break;
	}
	
	return false;
}