Skip to content

Commit

Permalink
Merge pull request #20 from BensonLaur/change-soui-version-and-fix-bug
Browse files Browse the repository at this point in the history
Change soui version and fix bug
  • Loading branch information
BensonLaur authored Nov 27, 2017
2 parents 7257cc4 + ec3e9da commit 7be9bd6
Show file tree
Hide file tree
Showing 21 changed files with 82 additions and 49 deletions.
Binary file modified BesLyric/BesLyric.cpp
Binary file not shown.
5 changes: 3 additions & 2 deletions BesLyric/BesLyric.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>$(SOUIPATH)\config;$(SOUIPATH)\components;$(SOUIPATH)\SOUI\include;$(SOUIPATH)\utilities\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;STRICT;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<BrowseInformation>true</BrowseInformation>
<Optimization>Disabled</Optimization>
Expand All @@ -74,7 +74,7 @@
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>$(SOUIPATH)\config;$(SOUIPATH)\components;$(SOUIPATH)\SOUI\include;$(SOUIPATH)\utilities\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile>
Expand All @@ -83,6 +83,7 @@
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>$(ProjectDir)lib\json\;$(SOUIPATH)\bin;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>utilities.lib;soui.lib;%(AdditionalDependencies);lib_json_release.lib</AdditionalDependencies>
<AdditionalOptions>/LTCG %(AdditionalOptions)</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
20 changes: 11 additions & 9 deletions BesLyric/Define.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,17 @@ typedef struct _PATH_STATE
bool isInited;
}PATH_STATE;

enum ENCODING_TYPE //文件编码类型
{
ASCII,
UNICODE_LITTLE_ENDIAN,
UNICODE_BIG_ENDIAN,
UTF_8,
UTF_8_NO_BOM,
OTHER
};
namespace ENCODING_TYPE{
enum encoding_type //文件编码类型
{
ASCII,
UNICODE_LITTLE_ENDIAN,
UNICODE_BIG_ENDIAN,
UTF_8,
UTF_8_NO_BOM,
OTHER
};
}//为了避免 warning (nonstandard extension used: enum 'ENCODING_TYPE' used in qualified name) 而定义的命名空间

//储存获取的单个歌词信息
struct LyricInfo
Expand Down
6 changes: 3 additions & 3 deletions BesLyric/MainDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ void CMainDlg::OnSize(UINT nType, CSize size)
//设置程序窗口的背景图片
void CMainDlg::setBackSkin()
{
SSkinImgList * pSkin = sobj_cast<SSkinImgList>(GETSKIN(_T("skin_bkimg")));
SASSERT(pSkin);
FindChildByID(R.id.img_skin_layer)->SetAttribute(L"skin",_T("skin_bkimg"));
//SSkinImgList * pSkin = sobj_cast<SSkinImgList>(GETSKIN(_T("skin_bkimg")));
//SASSERT(pSkin);
//FindChildByID(R.id.img_skin_layer)->SetAttribute(L"skin",_T("skin_bkimg"));

//COLORREF crAvg = SDIBHelper::CalcAvarageColor(pSkin->GetImage());
//DoColorize(crAvg);
Expand Down
16 changes: 5 additions & 11 deletions BesLyric/controlEx/LyricListView.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@ class CLyricListView: public SMCListView
{
SHDITEM item;
item.mask = 0 | SHDI_TEXT| SHDI_WIDTH| SHDI_LPARAM| SHDI_SORTFLAG| SHDI_ORDER;
item.cchTextMax = MAX_BUFFER_SIZE/2;
//item.cchTextMax = MAX_BUFFER_SIZE/2;

int count = m_pHeader->GetItemCount();
vector<SHDITEM> items(count,item); //存储项信息
vector<WCHAR*> pszText(count, nullptr); //存储项字符串指针

//获取项的信息
for(int i=0; i<count; i++)
{
pszText[i] = new WCHAR[MAX_BUFFER_SIZE/2]; //分配内存存储项名称
items[i].pszText = pszText[i];
m_pHeader->GetItem(i, &items[i]);
m_pHeader->GetItem(i, &items[i]);
items[i].text.SetCtxProvider(this);
items[i].text.TranslateText(); //获得执行翻译得到翻译文本
}

//设置修改后的各个项的宽度
Expand All @@ -43,12 +42,7 @@ class CLyricListView: public SMCListView

//添加修改宽度后的项
for(int i=0; i<count; i++)
m_pHeader->InsertItem(i,items[i].pszText, items[i].cx, items[i].stFlag, items[i].lParam);

for(int i=0; i<count; i++)
{
delete pszText[i]; //释放 分配的存储项名称的内存
}
m_pHeader->InsertItem(i,items[i].text.GetText(), items[i].cx, items[i].stFlag, items[i].lParam);

SMCListView::OnSize(nType, size);
}
Expand Down
2 changes: 1 addition & 1 deletion BesLyric/entity/LyricSearcherFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
enum SEARCH_FROM{
SF_NETEASE = 0,
SF_GECIMI = 1,
UNDEFINED //将 UNDEFINED 置于最后,PageSearchLyric.cpp 中会遍历UNDEFINED 前的所有搜索来源
SF_UNDEFINED //将 UNDEFINED 置于最后,PageSearchLyric.cpp 中会遍历UNDEFINED 前的所有搜索来源
};


Expand Down
8 changes: 7 additions & 1 deletion BesLyric/entity/MusicPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void MusicPlayer::openStart()
else
{
//重头开始播放
play(0);
play(0);
}
}
else
Expand All @@ -85,6 +85,12 @@ void MusicPlayer::play(int milliSecondPosition)
//设置音量再播放
this->setVolumn(this->m_nVolumn);

if(milliSecondPosition < 200)
milliSecondPosition = 200; //经过调试发现,有些歌曲在滚动预览时,滚动出现延迟(估计是 MCI获取 歌曲位置时返回了一个偏小的值)
//进一步调试发现,当 play(n) 中 n 小于约59毫秒,是出现这种情况的一个必要条件
//所以,当这里设置初始播放位置总是大于59毫秒(这里设置为200毫秒),来避免这种情况
//设置为从200毫秒播放,基本不影响歌词制作

m_mciPlay.dwCallback=(DWORD)this->m_hdlHostWnd;
m_mciPlay.dwFrom = (DWORD)milliSecondPosition; //播放起始位置ms为单位
mciSendCommand(m_mciOpen.wDeviceID, MCI_PLAY, MCI_NOTIFY|MCI_FROM, (DWORD)(LPVOID)&m_mciPlay);
Expand Down
2 changes: 1 addition & 1 deletion BesLyric/entity/SearchLyricThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ DWORD WINAPI CSearchLyricThread::ProcSearch(LPVOID pParam)
SStringW strResultTip = L"";

int nTotalCount = 0;
for( int i= 0; i < (int)SEARCH_FROM::UNDEFINED; i++) //遍历每一种定义的歌词获取方式
for( int i= 0; i < (int)SF_UNDEFINED; i++) //遍历每一种定义的歌词获取方式
{
pSearcher = nullptr;//在 CreateSearcher 中对 SOUI智能指针取 地址& 前,先置为空(释放上一次分配的堆对象)
CLyricSearcherFactory::CreateSearcher((SEARCH_FROM)i, pSearcher);
Expand Down
1 change: 0 additions & 1 deletion BesLyric/entity/SearcherGecimi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ void SearcherGecimi::GetOneLyricInfoFromLyricBuffer(wstring strLyricBuffer,Lyric
wstring strPlaneText = L"";
wstring strLabelText = L"";;

WCHAR szTimeBuf[MAX_BUFFER_SIZE/2];
for(auto iter = vecTimeLineInfo.begin(); iter != vecTimeLineInfo.end(); iter++)
{
strPlaneText += iter->m_strLine;
Expand Down
3 changes: 1 addition & 2 deletions BesLyric/entity/SearcherNetEaseCloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ bool SearcherNetEaseCloud::SearchLyric(SStringW strSong, SStringW strArtist, vec
char szID[MAX_BUFFER_SIZE];

//获取id对应的歌词
if(!httpRequest.Get("music.163.com/api/song/lyric",string("os=osx&id=") + itoa( iter->nID,szID, 10) + string("&lv=-1&kv=-1&tv=-1"), strLyricJson))
if(!httpRequest.Get("music.163.com/api/song/lyric",string("os=osx&id=") + _itoa( iter->nID,szID, 10) + string("&lv=-1&kv=-1&tv=-1"), strLyricJson))
{
m_strLastResult = L"网络连接失败,无法获取歌词内容数据";
return false;
Expand Down Expand Up @@ -128,7 +128,6 @@ void SearcherNetEaseCloud::GetOneLyricInfoFromLyricBuffer(wstring strLyricBuffer
wstring strPlaneText = L"";
wstring strLabelText = L"";;

WCHAR szTimeBuf[MAX_BUFFER_SIZE/2];
for(auto iter = vecTimeLineInfo.begin(); iter != vecTimeLineInfo.end(); iter++)
{
strPlaneText += iter->m_strLine;
Expand Down
4 changes: 2 additions & 2 deletions BesLyric/entity/SendLoginThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using namespace SOUI;


//开始线程
bool SendLoginThread::Start(bool bAnonymity)
bool SendLoginThread::Start(BOOL bAnonymity)
{
//启动线程
if(m_handleThread != NULL)
Expand Down Expand Up @@ -40,7 +40,7 @@ DWORD WINAPI SendLoginThread::ThreadProc(LPVOID pParam)
}

//发送登录信息(ip地址)
void SendLoginThread::SendLoginInfo(bool bAnonymity)
void SendLoginThread::SendLoginInfo(BOOL bAnonymity)
{
//获得ip地址
//DownloadFile(L"https://whatismyipaddress.com/",L"E://git//BesLyric//Release//ip.txt");
Expand Down
6 changes: 3 additions & 3 deletions BesLyric/entity/SendLoginThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ class SendLoginThread : public Singleton<SendLoginThread>
SendLoginThread():m_handleThread(NULL){}

//开始线程
bool Start(bool bAnonymity);
bool Start(BOOL bAnonymity);

private:

//线程执行地址
static DWORD WINAPI ThreadProc(LPVOID pParam);

//发送登录信息(ip地址)
void SendLoginInfo(bool bAnonymity);
void SendLoginInfo(BOOL bAnonymity);

private:

HANDLE m_handleThread; /* 当前线程句柄 */
bool m_bAnonymity; /* 线程循环标记 */
BOOL m_bAnonymity; /* 线程循环标记 */
};

Binary file modified BesLyric/res/resource.h
Binary file not shown.
18 changes: 18 additions & 0 deletions BesLyric/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
//

#pragma once

#include <WinSock2.h>

#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif

#define DLL_SOUI
#include <souistd.h>
#include <core/SHostDialog.h>
Expand All @@ -31,3 +35,17 @@ extern int _MessageBox(HWND hwnd,LPCTSTR content, LPCTSTR tiltle, UINT uType);
//仅用于测试时,快速写出 弹框提示的代码 : MB("content");
void MB(LPCTSTR content);

//禁用第三方库的警告
//#pragma warning(disable:4127)
//#pragma warning(disable:4244)
//#pragma warning(disable:4311)
//#pragma warning(disable:4312)
//#pragma warning(disable:4512)
//#pragma warning(disable:4571)
//#pragma warning(disable:4640)
//#pragma warning(disable:4706)
//#pragma warning(disable:4710)
//#pragma warning(disable:4800)
//#pragma warning(disable:4804)
//#pragma warning(disable:4820)
#pragma warning(disable:4996) //在这里消除jsoncpp 库中的警告
2 changes: 1 addition & 1 deletion BesLyric/uires/xml/dlg_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
>

<root skin="_skin.sys.wnd.bkgnd" cache="1">
<img pos="0,0,-0,-0" name="img_skin_layer"/>
<img pos="0,0,-0,-0" name="img_skin_layer" skin="skin_bkimg"/>
<caption pos="0,0,-0,50" show="1" font="adding:0">
<!--<icon pos="5,5" src="ICON_LOGO:24"/>-->
<text pos="38,10">@string/title</text>
Expand Down
4 changes: 2 additions & 2 deletions BesLyric/utility/SplitFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bool CSplitFile::SplitFile(wstring strSrcFile, wstring strToPath, wstring strToN
while( (nSize = fread(pBlockData, sizeof(char),nBlockSize, pFile)))
{
char szBuffer[MAX_BUFFER_SIZE];
string strFileNameA = strTargetFileNamePreA+ "." + itoa(nCount++, szBuffer, 10) + SERVER_FILE_EXTENTION_A;
string strFileNameA = strTargetFileNamePreA+ "." + _itoa(nCount++, szBuffer, 10) + SERVER_FILE_EXTENTION_A;

FILE *pFileTarget;
ret = fopen_s(& pFileTarget, strFileNameA.c_str(), "wb");
Expand Down Expand Up @@ -205,7 +205,7 @@ bool CSplitFile::MergeToOneFile(wstring strMergedFilePathName,wstring strTarget
{
//
char szBuffer[MAX_BUFFER_SIZE];
string strFileNameA = strTargetFileNamePreA+ "." + itoa(i, szBuffer, 10) + SERVER_FILE_EXTENTION_A;
string strFileNameA = strTargetFileNamePreA+ "." + _itoa(i, szBuffer, 10) + SERVER_FILE_EXTENTION_A;

FILE *pFileSplited;
ret = fopen_s(& pFileSplited, strFileNameA.c_str(), "rb");
Expand Down
2 changes: 1 addition & 1 deletion BesLyric/utility/UrlEncoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ string CUrlEncodinig::UrlGB2312Decode(string str)
{
string output="";
char tmp[2];
int i=0,idx=0,ndx,len=str.length();
int i=0,idx=0,len=str.length();

while(i<len){
if(str[i]=='%'){
Expand Down
20 changes: 16 additions & 4 deletions BesLyric/utility/WinDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,7 @@ BOOL CFileDialogEx::checkPathName(LPCTSTR format,LPCTSTR toChecked)

if(isFloder) //检查文件夹类型
{
if(pos == -1)//这里默认文件夹的路径不包含任何点'.'
return TRUE;
else
return FALSE;
return IsFloderExist(toChecked);
}
else //检查普通后缀名类型
{
Expand All @@ -197,6 +194,21 @@ BOOL CFileDialogEx::checkPathName(LPCTSTR format,LPCTSTR toChecked)
}
}

//判断文件夹是否存在
BOOL CFileDialogEx::IsFloderExist(const wstring &strPath)
{
WIN32_FIND_DATAW wfd;
BOOL rValue = FALSE;
HANDLE hFind = FindFirstFileW(strPath.c_str(), &wfd);
if ((hFind != INVALID_HANDLE_VALUE) && (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
rValue = TRUE;
}
FindClose(hFind);
return rValue;
}



LONG g_lOriWndProc = NULL;
BOOL g_bReplaced = FALSE;
Expand Down
2 changes: 2 additions & 0 deletions BesLyric/utility/WinDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,7 @@ class CFileDialogEx
*/
static BOOL checkPathName(LPCTSTR format,LPCTSTR toChecked);

//判断文件夹是否存在
static BOOL IsFloderExist(const wstring &strPath);
};

8 changes: 4 additions & 4 deletions BesLyric/utility/WinFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ File::File(LPCTSTR pathFile,LPCTSTR mode)
if(_tcscmp(mode,_T("r")) == 0)
{
//读取文件的前两个字节,判断编码
int len = 0;
unsigned int len = 0;
char *buf = NULL;
byte firstByte = '\0';
byte secondByte = '\0';
ifstream in(pathFile);
if(in)
{
in.seekg(0,ios::end);
len = in.tellg();
len = (unsigned int) in.tellg();
buf = new char[len];
in.seekg(0,ios::beg);
in.read(buf,len);
Expand Down Expand Up @@ -242,7 +242,7 @@ bool FileOperator::ReadAllLinesW(File& encodingFile, OUT vector<SStringW> *line
// 从文件中读取歌词,并将非空行加入到 maker.m_vLyricOrigin 向量中
while(fgetws(line,MAX_WCHAR_COUNT_OF_LINE,encodingFile.m_pf))
{
line[MAX_CHAR_COUNT_OF_LINE]='\0';//保证在最后一个字符处截断字符串
line[MAX_WCHAR_COUNT_OF_LINE]='\0';//保证在最后一个字符处截断字符串

//由变长字符转换为 unicode 宽字节字符
//MultiByteToWideChar(CP_ACP,MB_COMPOSITE,_line,strlen(_line)+1,line,MAX_WCHAR_COUNT_OF_LINE+1);
Expand Down Expand Up @@ -429,7 +429,7 @@ bool FileHelper::IsDirectory(SStringW path)
{
//查找panelFloder是否存在
WIN32_FIND_DATA FindFileData;
BOOL bValue = false;
bool bValue = false;
HANDLE hFind = FindFirstFile(path, &FindFileData);
if ((hFind != INVALID_HANDLE_VALUE) && (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
Expand Down
2 changes: 1 addition & 1 deletion BesLyric/utility/WinFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class File{
LPCTSTR m_lpszMode; /* 打开文件的模式 */

FILE *m_pf; /* 存放当前打开文件的指针*/
ENCODING_TYPE m_encodingType; /* 存放文件编码格式 */
ENCODING_TYPE::encoding_type m_encodingType; /* 存放文件编码格式 */
};


Expand Down

0 comments on commit 7be9bd6

Please sign in to comment.