Esempio n. 1
0
void Thread::uploadYun()
{
    QString url;
    emit start_upload(-1);
    CurlUpload *curlUpload = new CurlUpload();
    bool ok = curlUpload->uploadYQDyun(_filename, _localpath, url, retSize);

    emit resultYun(url, ok);
}
Esempio n. 2
0
static int process_journal_input(Uploader *u, int skip) {
    int r;

    r = sd_journal_next_skip(u->journal, skip);
    if (r < 0)
        return log_error_errno(r, "Failed to skip to next entry: %m");
    else if (r < skip)
        return 0;

    /* have data */
    u->entry_state = ENTRY_CURSOR;
    return start_upload(u, journal_input_callback, u);
}
Esempio n. 3
0
void Thread::uploadActor()
{
    if(singer == NULL || sql == NULL)
    {
        emit result(-1);
        return;
    }

    for(int i=0; i<actors.count(); i++)
    {
        Actor actor = actors.at(i);
        QString path = actor.image;
        if(!path.isEmpty())
        {
            QFile file(path);
            if(file.exists())
            {
                emit start_upload(actor.serial_id.toLongLong());
                QString retStr = "";
                CurlUpload *curlUpload = new CurlUpload();
                retStr = curlUpload->uploadActorImage(path, retSize);
                if(retStr.compare("0") == 0){///类型不合法
                    emit result(0);
                }
                else if(retStr.compare("1") == 0){///上传的⽂文件已经存在于服务器,并不可覆盖
                   emit result(1);
                }
                singer->setImageOnlineRetPath(retStr);

                delete curlUpload;
            }
        }

#ifndef YQC_TECH
        if(sql->insertActor_PS(actor))
#else
        if(sql->insertActor(actor))
#endif
//        if(sql->insertActor(actor))
        {
            emit result(actor.serial_id.toLongLong());
        }
        else
        {
            emit result(-1);
        }
    }
}
Esempio n. 4
0
/*
	main

	Initiate communication with the XBee module, then accept AT commands from
	STDIO, pass them to the XBee module and print the result.
*/
int main( int argc, char *argv[])
{
   char cmdstr[80];
	int status;
	xbee_serial_t XBEE_SERPORT;
	uint16_t params[3];

	parse_serial_arguments( argc, argv, &XBEE_SERPORT);

	// initialize the serial and device layer for this XBee device
	if (xbee_dev_init( &my_xbee, &XBEE_SERPORT, NULL, NULL))
	{
		printf( "Failed to initialize device.\n");
		return 0;
	}

	// Initialize the WPAN layer of the XBee device driver.  This layer enables
	// endpoints and clusters, and is required for all ZigBee layers.
	xbee_wpan_init( &my_xbee, sample_endpoints);

	// Initialize the AT Command layer for this XBee device and have the
	// driver query it for basic information (hardware version, firmware version,
	// serial number, IEEE address, etc.)
	xbee_cmd_init_device( &my_xbee);
	printf( "Waiting for driver to query the XBee device...\n");
	do {
		xbee_dev_tick( &my_xbee);
		status = xbee_cmd_query_status( &my_xbee);
	} while (status == -EBUSY);
	if (status)
	{
		printf( "Error %d waiting for query to complete.\n", status);
	}

	// report on the settings
	xbee_dev_dump_settings( &my_xbee, XBEE_DEV_DUMP_FLAG_DEFAULT);

	xbee_gpm_envelope_local( &envelope_self, &my_xbee.wpan_dev);
	if (envelope_self.ieee_address.u[0] == 0x0000)
	{
		// We're connected to a Wi-Fi XBee and need to use an IP address
		// (localhost, 127.0.0.1) as the target.
		envelope_self.ieee_address.l[0] = 0;
		envelope_self.ieee_address.l[1] = htobe32( 0x7F000001);
	}

	// get flash info, for use by later commands
	xbee_gpm_get_flash_info( &envelope_self);

   while (1)
   {
      while (xbee_readline( cmdstr, sizeof cmdstr) == -EAGAIN)
      {
      	xbee_dev_tick( &my_xbee);
      }

		if (! strcmpi( cmdstr, "help") || ! strcmp( cmdstr, "?"))
		{
			print_menu();
		}
      else if (! strcmpi( cmdstr, "quit"))
      {
			return 0;
		}
      else if (! strcmpi( cmdstr, "info"))
      {
      	printf( "Sending platform info request (result %d)\n",
      			xbee_gpm_get_flash_info( &envelope_self));
      }
      else if (! strcmpi( cmdstr, "erase all"))
      {
   		printf( "Erasing entire GPM (result %d)\n",
   				xbee_gpm_erase_flash( &envelope_self));
      }
      else if (! strncmpi( cmdstr, "erase ", 6))
      {
      	if (blocksize == 0)
      	{
      		puts( "Need to get 'info' response to learn blocksize before"
      				"erasing a page.");
      	}
      	else if (parse_uint16( params, &cmdstr[6], 1) == 1)
      	{
      		printf( "Erasing block %u (result %d)\n", params[0],
      				xbee_gpm_erase_block( &envelope_self, params[0], blocksize));
      	}
      	else
      	{
      		printf( "Couldn't parse block number from [%s]\n", &cmdstr[6]);
      	}
      }
      else if (! strncmpi( cmdstr, "read", 4))
      {
      	if (parse_uint16( params, &cmdstr[5], 3) == 3)
      	{
      		printf( "Read %u bytes from offset %u of block %u (result %d)\n",
      				params[2], params[1], params[0],
      				xbee_gpm_read( &envelope_self,
      						params[0], params[1], params[2]));
      	}
      	else
      	{
      		printf( "Couldn't parse three values from [%s]\n", &cmdstr[5]);
      	}
      }
      else if (! strcmpi( cmdstr, "pagesize"))
      {
      	printf( "upload page size is %u\n", upload_pagesize);
      }
      else if (! strncmpi( cmdstr, "pagesize ", 9))
      {
      	if (parse_uint16( params, &cmdstr[9], 1) == 1)
			{
				if (params[0] > xbee_gpm_max_write( &my_xbee.wpan_dev))
				{
					printf( "page size of %u exceeds maximum of %u\n",
							params[0], xbee_gpm_max_write( &my_xbee.wpan_dev));
				}
				else
				{
					upload_pagesize = params[0];
					printf( "upload page size is now %u\n", upload_pagesize);
				}
			}
			else
			{
				printf( "Couldn't parse page size from [%s]\n", &cmdstr[9]);
			}
      }
      else if (! strncmpi( cmdstr, "upload ", 7))
      {
      	start_upload( &cmdstr[7]);
      }
      else if (! strcmpi( cmdstr, "verify"))
      {
   		printf( "Verify firmware in GPM (result %d)\n",
   				xbee_gpm_firmware_verify( &envelope_self));
      }
      else if (! strcmpi( cmdstr, "install"))
      {
   		printf( "Install firmware in GPM (result %d)\n",
   				xbee_gpm_firmware_install( &envelope_self));
      }
		else if (! strncmpi( cmdstr, "AT", 2))
		{
			process_command( &my_xbee, &cmdstr[2]);
		}
	   else
	   {
	   	printf( "unknown command: '%s'\n", cmdstr);
	   }
   }
}
Esempio n. 5
0
void Thread::uploadMedia()
{
    if(song == NULL || sql == NULL)
    {
        emit result(-1);
        return;
    }

    for (int i=0; i<medias.count(); i++)
    {
        Media media = medias.at(i);
        QFile file(media.path);/*c:/test/12345678.mp4*/

        if(!media.path.isEmpty())
        {  

//            ///修改文件名为serial_id后六位
//            int before = path.lastIndexOf("/");
//            int after = path.lastIndexOf(".");

//            QString mediaName = media.serial_id.right(6);
//            path = path.replace(before+1, after-before-1, mediaName);
//            file.rename(path);

            ConvertionMP4 mp4;
#ifndef YQC_TECH
            QString path = mp4.convertionFilePS(media.path, media.mid);
#else
            QString path = mp4.convertionFile(media.path, media.serial_id);
#endif

            qDebug() << " dest path : " << path;
//            QTime time;
//            time.start();
            if(!path.isEmpty())
            {
                file.setFileName(path);
                if(file.exists())
                {
#ifndef YQC_TECH
                    emit start_upload(media.mid.toLongLong());
#else
                    emit start_upload(media.serial_id.toLongLong());
#endif
//                    emit start_upload(media.serial_id.toLongLong());
                    QString retPath = song->uploadV(path, retSize);
                    if(retPath.compare("0") == 0)
                    {
                        ///类型不合法
                        emit result(0);
                        return;
                    }
                    else if(retPath.compare("1") == 0)
                    {
                        ///上传的⽂文件已经存在于服务器,并不可覆盖
//                        QMessageBox::information(NULL, "提示", "上传的视频已经存在于服务器,并不可覆盖\n数据上传失败");
                         emit result(1);
                        qDebug() << "重复";
                        return;
                    }
                    retPath.insert(0, "/");
                    media.path = retPath;
                    qDebug() << "path: " << retPath;
                }
                //    file.rename(media.path);
//                qDebug()<< time.elapsed()/1000.0<<"s";
            }
        }

        if(!media.lyric.isEmpty())
        {
            file.setFileName(media.lyric);
            if(file.exists())
                media.lyric = song->uploadL(media.lyric);
        }

#ifndef YQC_TECH
        if(sql->insertMedia_PS(media))
        {
            emit result(media.mid.toLongLong());
        }
#else
        if(sql->insertMedia(media))
        {
            emit result(media.serial_id.toLongLong());
        }
#endif
        else
        {
            emit result(-1);
        }
    }
}