Exemplo n.º 1
0
	void ContactDropFilter::HandleImageDropped (const QImage& image, const QUrl& url)
	{
		QStringList choiceItems
		{
			tr ("Send directly in chat")
		};

		QList<std::function<void ()>> functions
		{
			[this, &image] { SendInChat (image, EntryId_, ChatTab_); }
		};

		if (url.scheme () != "file")
		{
			choiceItems << tr ("Send link");
			functions.append ([this, url] { SendLink (url, EntryId_, ChatTab_); });
		}
		else
		{
			choiceItems.prepend (tr ("Send as file"));
			functions.prepend ([this, &url]
				{
					Core::Instance ().GetTransferJobManager ()->
							OfferURLs (GetEntry<ICLEntry> (EntryId_), { url });
				});

			CollectDataFilters (choiceItems, functions, image);
		}

		PerformChoice (choiceItems, functions);
	}
Exemplo n.º 2
0
/*返回1表示连接成功,返回0表示连接失败*/
uint8_t OrderSendLink(void)
{
	uint8_t RetryFre;
	
	LinkTime =0;
	RetryFre =0;
	SendLink();
	delay_ms(5);
	while(1)
	{
		if( machinerec.reack ==1)	  //ack
		{
			LinkTime =0;
			machinerec.reack = 0;
			machinerec.renack = 0;
			return 1;
		}
		
		if( LinkTime >1)  //超时
		{
			LinkTime =0;
			return 0;
		}
		
		if(machinerec.renack ==1)  //nack
		{
			machinerec.reack = 0;
			machinerec.renack = 0;
			RetryFre ++;
			SendLink();			
		} 
		
		if( RetryFre>=3)
		{
			LinkTime =0;
			machinerec.reack = 0;
			machinerec.renack = 0; 
			return 0;
		}
		
	}
	
}