aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Communication/PMR/Connection/ConnectRequest.pb-c.h
blob: 9dfd424a21cef34a588ac839a85690a331768542 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* Generated by the protocol buffer compiler.  DO NOT EDIT! */
/* Generated from: ConnectRequest.proto */

#ifndef PROTOBUF_C_ConnectRequest_2eproto__INCLUDED
#define PROTOBUF_C_ConnectRequest_2eproto__INCLUDED

#include <protobuf-c/protobuf-c.h>

PROTOBUF_C__BEGIN_DECLS

#if PROTOBUF_C_VERSION_NUMBER < 1003000
# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers.
#elif 1003000 < PROTOBUF_C_MIN_COMPILER_VERSION
# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c.
#endif


typedef struct _ConnectRequest ConnectRequest;


/* --- enums --- */


/* --- messages --- */

struct  _ConnectRequest
{
  ProtobufCMessage base;
  char *password;
  protobuf_c_boolean has_unixtime;
  int64_t unixtime;
};
#define CONNECT_REQUEST__INIT \
 { PROTOBUF_C_MESSAGE_INIT (&connect_request__descriptor) \
    , NULL, 0, 0 }


/* ConnectRequest methods */
void   connect_request__init
                     (ConnectRequest         *message);
size_t connect_request__get_packed_size
                     (const ConnectRequest   *message);
size_t connect_request__pack
                     (const ConnectRequest   *message,
                      uint8_t             *out);
size_t connect_request__pack_to_buffer
                     (const ConnectRequest   *message,
                      ProtobufCBuffer     *buffer);
ConnectRequest *
       connect_request__unpack
                     (ProtobufCAllocator  *allocator,
                      size_t               len,
                      const uint8_t       *data);
void   connect_request__free_unpacked
                     (ConnectRequest *message,
                      ProtobufCAllocator *allocator);
/* --- per-message closures --- */

typedef void (*ConnectRequest_Closure)
                 (const ConnectRequest *message,
                  void *closure_data);

/* --- services --- */


/* --- descriptors --- */

extern const ProtobufCMessageDescriptor connect_request__descriptor;

PROTOBUF_C__END_DECLS


#endif  /* PROTOBUF_C_ConnectRequest_2eproto__INCLUDED */
span>; } private set { _isEnabled = value; RaisePropertyChangedAuto(); } } /// <summary> /// Initializes a new instance of the <see cref="DefaultRemoteAssistanceProvider"/> class. /// </summary> /// <param name="machineProvider">The machine provider.</param> public DefaultRemoteAssistanceProvider(IMachineProvider machineProvider) { _machineProvider = machineProvider; } /// <summary> /// Enables the remote assistance. /// </summary> /// <returns></returns> public async Task EnableRemoteAssistance() { if (!IsEnabled) { try { CmdCommand command = new CmdCommand("sc.exe", "config TeamViewer start=auto"); command.Timeout = TimeSpan.FromSeconds(10); await command.Run(); command = new CmdCommand("net", "start TeamViewer"); command.Timeout = TimeSpan.FromSeconds(10); await command.Run(); IsEnabled = true; } catch (Exception ex) { LogManager.Log(ex, "Error enabling remote assistance."); } } } /// <summary> /// Disables the remote assistance. /// </summary> /// <returns></returns> public async Task DisableRemoteAssistance() { if (IsEnabled) { try { CmdCommand command = new CmdCommand("sc.exe", "config TeamViewer start=disabled"); command.Timeout = TimeSpan.FromSeconds(10); await command.Run(); command = new CmdCommand("net", "stop TeamViewer"); command.Timeout = TimeSpan.FromSeconds(10); await command.Run(); IsEnabled = false; } catch (Exception ex) { LogManager.Log(ex, "Error disabling remote assistance."); } } } /// <summary> /// Installs the remote assistance. /// </summary> /// <param name="machineSerialNumber">The machine serial number.</param> /// <param name="group">The remote assistance group.</param> /// <param name="environment">The machine working environment.</param> /// <returns></returns> /// <exception cref="FileNotFoundException"></exception> /// <exception cref="ApplicationException">The remote assistance service was installed but could not be found.</exception> public async Task InstallRemoteAssistance(String machineSerialNumber, String group, String environment) { try { if (!File.Exists(_installer_path)) { throw new FileNotFoundException($"The remote assistance installer file could not be found at {_installer_path}."); } String q = "\""; //CmdCommand command = new CmdCommand("msiexec.exe", $"/i \"{_installer_path}\" /qn CUSTOMCONFIGID=ke43ann APITOKEN=4765529-gon1LwO1N1TTrlLI21ji ASSIGNMENTOPTIONS=\" --reassign --alias {"TANGO-" + machineSerialNumber}-{environment} --grant-easy-access\""); CmdCommand command = new CmdCommand("msiexec.exe", $"/i {q}{_installer_path}{q} /qn CUSTOMCONFIGID=ke43ann APITOKEN=4765529-gon1LwO1N1TTrlLI21ji ASSIGNMENTOPTIONS={q} --group {q}{q} {group} {q}{q} --reassign --alias TANGO-{machineSerialNumber}-{environment} --grant-easy-access{q}"); command.Timeout = TimeSpan.FromSeconds(30); await command.Run(); bool exist = await IsRemoteAssistanceInstalled(); if (exist) { await DisableRemoteAssistance(); } else { throw new ApplicationException("The remote assistance service was installed but could not be found."); } } catch (Exception ex) { LogManager.Log(ex, "Error installing remote assistance."); throw; } } /// <summary> /// Determines whether remote assistance is currently installed. /// </summary> /// <returns></returns> private async Task<bool> IsRemoteAssistanceInstalled() { bool exist = false; for (int i = 0; i < 6; i++) { LogManager.Log("Checking remote assistance service..."); await Task.Delay(1000); CmdCommand command = new CmdCommand("sc.exe", "query TeamViewer"); try { await command.Run(); exist = true; break; } catch { } } if (exist) { LogManager.Log("Remote assistance service found."); } else { LogManager.Log("Remote assistance service was not found."); } return exist; } } }