Browse Source

Merge pull request #275 from sendssf/dev

Chore: Fix Some File Bugs
tags/0.1.0
OctaAcid GitHub 2 years ago
parent
commit
b0bbd7c1ab
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 3413 additions and 3184 deletions
  1. +1721
    -1533
      CAPI/cpp/proto/Message2Clients.pb.cc
  2. +805
    -912
      CAPI/cpp/proto/Message2Clients.pb.h
  3. +503
    -467
      CAPI/cpp/proto/Message2Server.pb.cc
  4. +182
    -223
      CAPI/cpp/proto/Message2Server.pb.h
  5. +6
    -10
      CAPI/cpp/proto/MessageType.pb.cc
  6. +8
    -2
      CAPI/cpp/proto/MessageType.pb.h
  7. +9
    -13
      CAPI/cpp/proto/Services.pb.cc
  8. +8
    -2
      CAPI/cpp/proto/Services.pb.h
  9. +16
    -10
      dependency/Dockerfile/Dockerfile_cpp
  10. +134
    -11
      installer/Installer/Model.cs
  11. +21
    -1
      installer/Installer/ViewModel.cs

+ 1721
- 1533
CAPI/cpp/proto/Message2Clients.pb.cc
File diff suppressed because it is too large
View File


+ 805
- 912
CAPI/cpp/proto/Message2Clients.pb.h
File diff suppressed because it is too large
View File


+ 503
- 467
CAPI/cpp/proto/Message2Server.pb.cc
File diff suppressed because it is too large
View File


+ 182
- 223
CAPI/cpp/proto/Message2Server.pb.h
File diff suppressed because it is too large
View File


+ 6
- 10
CAPI/cpp/proto/MessageType.pb.cc View File

@@ -16,18 +16,14 @@
#include <google/protobuf/port_def.inc>

PROTOBUF_PRAGMA_INIT_SEG

namespace _pb = ::PROTOBUF_NAMESPACE_ID;
namespace _pbi = _pb::internal;

namespace protobuf
{
} // namespace protobuf
static const ::_pb::EnumDescriptor* file_level_enum_descriptors_MessageType_2eproto[11];
static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_MessageType_2eproto = nullptr;
static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_MessageType_2eproto[11];
static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_MessageType_2eproto = nullptr;
const uint32_t TableStruct_MessageType_2eproto::offsets[1] = {};
static constexpr ::_pbi::MigrationSchema* schemas = nullptr;
static constexpr ::_pb::Message* const* file_default_instances = nullptr;
static constexpr ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema* schemas = nullptr;
static constexpr ::PROTOBUF_NAMESPACE_ID::Message* const* file_default_instances = nullptr;

const char descriptor_table_protodef_MessageType_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
"\n\021MessageType.proto\022\010protobuf*\202\001\n\nBullet"
@@ -86,13 +82,13 @@ const ::_pbi::DescriptorTable descriptor_table_MessageType_2eproto = {
file_level_enum_descriptors_MessageType_2eproto,
file_level_service_descriptors_MessageType_2eproto,
};
PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_MessageType_2eproto_getter()
PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_MessageType_2eproto_getter()
{
return &descriptor_table_MessageType_2eproto;
}

// Force running AddDescriptors() at dynamic initialization time.
PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_MessageType_2eproto(&descriptor_table_MessageType_2eproto);
PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_MessageType_2eproto(&descriptor_table_MessageType_2eproto);
namespace protobuf
{
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* BulletType_descriptor()


+ 8
- 2
CAPI/cpp/proto/MessageType.pb.h View File

@@ -8,12 +8,12 @@
#include <string>

#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3021000
#if PROTOBUF_VERSION < 3019000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION
#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
@@ -23,6 +23,7 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
@@ -42,6 +43,11 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct TableStruct_MessageType_2eproto
{
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1] PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const uint32_t offsets[];
};
extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_MessageType_2eproto;


+ 9
- 13
CAPI/cpp/proto/Services.pb.cc View File

@@ -16,18 +16,14 @@
#include <google/protobuf/port_def.inc>

PROTOBUF_PRAGMA_INIT_SEG

namespace _pb = ::PROTOBUF_NAMESPACE_ID;
namespace _pbi = _pb::internal;

namespace protobuf
{
} // namespace protobuf
static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_Services_2eproto = nullptr;
static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_Services_2eproto = nullptr;
static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_Services_2eproto = nullptr;
static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_Services_2eproto = nullptr;
const uint32_t TableStruct_Services_2eproto::offsets[1] = {};
static constexpr ::_pbi::MigrationSchema* schemas = nullptr;
static constexpr ::_pb::Message* const* file_default_instances = nullptr;
static constexpr ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema* schemas = nullptr;
static constexpr ::PROTOBUF_NAMESPACE_ID::Message* const* file_default_instances = nullptr;

const char descriptor_table_protodef_Services_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
"\n\016Services.proto\022\010protobuf\032\025Message2Clie"
@@ -58,12 +54,12 @@ const char descriptor_table_protodef_Services_2eproto[] PROTOBUF_SECTION_VARIABL
"tOpenChest\022\017.protobuf.IDMsg\032\021.protobuf.B"
"oolRes\0222\n\014EndAllAction\022\017.protobuf.IDMsg\032"
"\021.protobuf.BoolResb\006proto3";
static const ::_pbi::DescriptorTable* const descriptor_table_Services_2eproto_deps[2] = {
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* const descriptor_table_Services_2eproto_deps[2] = {
&::descriptor_table_Message2Clients_2eproto,
&::descriptor_table_Message2Server_2eproto,
};
static ::_pbi::once_flag descriptor_table_Services_2eproto_once;
const ::_pbi::DescriptorTable descriptor_table_Services_2eproto = {
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_Services_2eproto_once;
const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_Services_2eproto = {
false,
false,
1106,
@@ -80,13 +76,13 @@ const ::_pbi::DescriptorTable descriptor_table_Services_2eproto = {
file_level_enum_descriptors_Services_2eproto,
file_level_service_descriptors_Services_2eproto,
};
PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_Services_2eproto_getter()
PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_Services_2eproto_getter()
{
return &descriptor_table_Services_2eproto;
}

// Force running AddDescriptors() at dynamic initialization time.
PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_Services_2eproto(&descriptor_table_Services_2eproto);
PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_Services_2eproto(&descriptor_table_Services_2eproto);
namespace protobuf
{



+ 8
- 2
CAPI/cpp/proto/Services.pb.h View File

@@ -8,12 +8,12 @@
#include <string>

#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3021000
#if PROTOBUF_VERSION < 3019000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION
#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
@@ -23,6 +23,7 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
@@ -43,6 +44,11 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct TableStruct_Services_2eproto
{
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1] PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const uint32_t offsets[];
};
extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_Services_2eproto;


dependency/Dockerfile/Dockerfile → dependency/Dockerfile/Dockerfile_cpp View File

@@ -8,31 +8,37 @@ RUN apt-get update && apt-get install --no-install-recommends -y gcc g++ make wg
RUN git clone -b v1.46.3 --depth 1 --shallow-submodules https://gitee.com/mirrors/grpc.git
RUN wget -P . https://cloud.tsinghua.edu.cn/f/1f2713efd9e44255abd6/?dl=1
RUN mv 'index.html?dl=1' third_party.tar.gz
RUN cd grpc
WORKDIR /usr/local/grpc
RUN rm -rf third_party
RUN mv ../third_party.tar.gz .
RUN tar -zxvf third_party.tar.gz
RUN mkdir -p cmake/build
RUN pushd cmake/build
WORKDIR /usr/local/grpc/cmake/build
RUN cmake -DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
../..
RUN make -j$(nproc)
RUN make install
RUN popd

#安装protobuf
RUN cd /usr/local
WORKDIR /usr/local
RUN git clone https://gitee.com/mirrors/protobuf_source.git ./protobuf
RUN cd protobuf
RUN git checkout 3.22.1
RUN ./autogen.sh
WORKDIR /usr/local/protobuf
RUN git checkout 3.20.x
RUN ./autogen.sh
RUN ./configure
RUN make -j$(nproc)
RUN make install
RUN ldconfig
#RUN git submodule update --init --recursive
#RUN cmake .
#RUN cmake --build . --parallel 10
#RUN make install

COPY ./CAPI /usr/local/PlayerCode
RUN cd /usr/local/PlayerCode/CAPI
RUN cmake CMakeLists.txt
COPY ./CAPI /usr/local/PlayerCode/CAPI
COPY ./dependency /usr/local/PlayerCode/dependency
WORKDIR /usr/local/PlayerCode/dependency/proto
RUN ./cpp_output.sh
WORKDIR /usr/local/PlayerCode/CAPI/cpp
RUN cmake ./CMakeLists.txt
RUN make

+ 134
- 11
installer/Installer/Model.cs View File

@@ -292,8 +292,8 @@ namespace Downloader
public static string dataPath = ""; // C盘的文档文件夹
public Data(string path)
{
// dataPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
dataPath = new DirectoryInfo(".").FullName;
dataPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
//dataPath = new DirectoryInfo(".").FullName;
Data.path = System.IO.Path.Combine(dataPath, "THUAI6.json");
if (File.Exists(Data.path))
{
@@ -397,8 +397,9 @@ namespace Downloader
.Build(); // 创建 CosXmlConfig 对象

// 永久密钥访问凭证
string secretId = "***"; //"云 API 密钥 SecretId";
string secretKey = "***"; //"云 API 密钥 SecretKey";
string secretId = "***"; //"云 API 密钥 SecretId";
string secretKey = "***"; //"云 API 密钥 SecretKey";


long durationSecond = 1000; // 每次请求签名有效时长,单位为秒
QCloudCredentialProvider cosCredentialProvider = new DefaultQCloudCredentialProvider(
@@ -515,11 +516,14 @@ namespace Downloader
Dictionary<string, string> jsonDict = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
foreach (KeyValuePair<string, string> pair in jsonDict)
{
MD5 = GetFileMd5Hash(System.IO.Path.Combine(Data.FilePath, pair.Key));
if (MD5.Length == 0) // 文档不存在
newFileName.Add(pair.Key);
else if (MD5 != pair.Value) // MD5不匹配
updateFileName.Add(pair.Key);
if (System.IO.Path.GetFileName(pair.Key) != "AI.cpp" && System.IO.Path.GetFileName(pair.Key) != "AI.py")
{
MD5 = GetFileMd5Hash(System.IO.Path.Combine(Data.FilePath, pair.Key));
if (MD5.Length == 0) // 文档不存在
newFileName.Add(pair.Key);
else if (MD5 != pair.Value) // MD5不匹配
updateFileName.Add(pair.Key);
}
}

newFile = newFileName.Count;
@@ -817,7 +821,7 @@ namespace Downloader
}
foreach (FileInfo file in player.GetFiles())
{
if (file.Name == "README.md")
if (file.Name == "AI.cpp" || file.Name == "AI.py")
{
continue;
}
@@ -1120,7 +1124,7 @@ namespace WebConnect
try
{
string content;
client.DefaultRequestHeaders.Authorization = new("bearertoken", logintoken);
client.DefaultRequestHeaders.Authorization = new("Bearer", logintoken);
if (!File.Exists(tarfile))
{
//Console.WriteLine("文件不存在!");
@@ -1290,6 +1294,125 @@ namespace WebConnect
Console.WriteLine("写入token.dat发生冲突!请检查token.dat是否被其它程序占用!");
}
}

public static int WriteUserEmail(string email)
{
try
{
string savepath = System.IO.Path.Combine(Data.dataPath, "THUAI6.json");
FileStream fs = new FileStream(savepath, FileMode.Open, FileAccess.ReadWrite);
StreamReader sr = new StreamReader(fs);
string json = sr.ReadToEnd();
if (json == null || json == "")
{
json += @"{""THUAI6""" + ":" + @"""2023""}";
}
Dictionary<string, string> dict = new Dictionary<string, string>();
dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
if (!dict.ContainsKey("email"))
{
dict.Add("email", email);
}
else
{
dict["email"] = email;
}
sr.Close();
fs.Close();
FileStream fs2 = new FileStream(savepath, FileMode.Open, FileAccess.ReadWrite);
StreamWriter sw = new StreamWriter(fs2);
sw.WriteLine(JsonConvert.SerializeObject(dict));
sw.Close();
fs2.Close();
return 0;//成功
}
catch
{
return -1;//失败
}
}

public static int WriteUserPassword(string password)
{
try
{
string savepath = System.IO.Path.Combine(Data.dataPath, "THUAI6.json");
FileStream fs = new FileStream(savepath, FileMode.Open, FileAccess.ReadWrite);
StreamReader sr = new StreamReader(fs);
string json = sr.ReadToEnd();
if (json == null || json == "")
{
json += @"{""THUAI6""" + ":" + @"""2023""}";
}
Dictionary<string, string> dict = new Dictionary<string, string>();
dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
if (!dict.ContainsKey("password"))
{
dict.Add("password", password);
}
else
{
dict["password"] = password;
}
sr.Close();
fs.Close();
FileStream fs2 = new FileStream(savepath, FileMode.Open, FileAccess.ReadWrite);
StreamWriter sw = new StreamWriter(fs2);
sw.WriteLine(JsonConvert.SerializeObject(dict));
sw.Close();
fs2.Close();
return 0;//成功
}
catch
{
return -1;//失败,THUAI6.json 文件不存在或者已被占用
}
}

public static string ReadUserPassword()
{
try
{
string savepath = System.IO.Path.Combine(Data.dataPath, "THUAI6.json");
FileStream fs = new FileStream(savepath, FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs);
string json = sr.ReadToEnd();
Dictionary<string, string> dict = new Dictionary<string, string>();
if (json == null || json == "")
{
json += @"{""THUAI6""" + ":" + @"""2023""}";
}
dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
return dict["password"];

}
catch
{
return null; //文件不存在或者已被占用
}
}

public static string ReadUserEmail()
{
try
{
string savepath = System.IO.Path.Combine(Data.dataPath, "THUAI6.json");
FileStream fs = new FileStream(savepath, FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs);
string json = sr.ReadToEnd();
Dictionary<string, string> dict = new Dictionary<string, string>();
if (json == null || json == "")
{
json += @"{""THUAI6""" + ":" + @"""2023""}";
}
dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
return dict["email"];
}
catch
{
return null;
}
}
public bool ReadToken() // 读取token
{
try


+ 21
- 1
installer/Installer/ViewModel.cs View File

@@ -19,9 +19,11 @@ namespace starter.viewmodel.settings
/// <summary>
/// initializer
/// </summary>

public SettingsViewModel()
{
//Program.Tencent_cos_download.UpdateHash();
//WebConnect.Web.WriteUserEmail("wangsk21@mails.tsinghua.edu.cn");
if (Downloader.Program.Tencent_cos_download.CheckAlreadyDownload())
{
obj.checkUpdate();
@@ -558,7 +560,10 @@ namespace starter.viewmodel.settings
{
clickBackCommand = new BaseCommand(new Action<object>(o =>
{
Status = SettingsModel.Status.login;
if (Downloader.Program.Tencent_cos_download.CheckAlreadyDownload())
Status = SettingsModel.Status.login;
else
Status = SettingsModel.Status.newUser;
}));
}
return clickBackCommand;
@@ -657,6 +662,21 @@ namespace starter.viewmodel.settings
return clickReselectCommand;
}
}
private BaseCommand clickExitCommand;
public BaseCommand ClickExitCommand
{
get
{
if (clickExitCommand == null)
{
clickExitCommand = new BaseCommand(new Action<object>(o =>
{
System.Windows.Application.Current.Shutdown();
}));
}
return clickExitCommand;
}
}
}

}

Loading…
Cancel
Save