CN105610908B - A kind of samba service implementing method and system based on Android device - Google Patents
A kind of samba service implementing method and system based on Android device Download PDFInfo
- Publication number
- CN105610908B CN105610908B CN201510962431.0A CN201510962431A CN105610908B CN 105610908 B CN105610908 B CN 105610908B CN 201510962431 A CN201510962431 A CN 201510962431A CN 105610908 B CN105610908 B CN 105610908B
- Authority
- CN
- China
- Prior art keywords
- configuration file
- samba
- resolved
- configuration
- android device
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
- 241001362551 Samba Species 0.000 title claims abstract description 87
- 238000000034 method Methods 0.000 title claims abstract description 51
- 230000003068 static effect Effects 0.000 claims description 28
- 230000004048 modification Effects 0.000 claims description 11
- 238000012986 modification Methods 0.000 claims description 11
- 238000012545 processing Methods 0.000 claims description 7
- 230000008569 process Effects 0.000 claims description 6
- 238000005538 encapsulation Methods 0.000 claims description 4
- 230000002688 persistence Effects 0.000 claims 2
- 238000012217 deletion Methods 0.000 claims 1
- 230000037430 deletion Effects 0.000 claims 1
- 238000007726 management method Methods 0.000 description 10
- 230000006870 function Effects 0.000 description 4
- 230000009471 action Effects 0.000 description 3
- 238000004458 analytical method Methods 0.000 description 2
- 238000001514 detection method Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 238000011084 recovery Methods 0.000 description 2
- 230000009466 transformation Effects 0.000 description 2
- 238000000844 transformation Methods 0.000 description 2
- 238000004891 communication Methods 0.000 description 1
- 230000007812 deficiency Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000001131 transforming effect Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/06—Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/2866—Architectures; Arrangements
- H04L67/30—Profiles
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Stored Programmes (AREA)
- Telephone Function (AREA)
Abstract
Description
技术领域technical field
本发明涉及通信领域,尤其涉及一种基于安卓设备的samba服务实现方法及系统。The invention relates to the communication field, in particular to a method and system for realizing samba service based on an Android device.
背景技术Background technique
现有技术中,在当前的android系统上并没有集成samba服务,而基于android设备的模块电视之家庭云,本身是带有存储功能的,需要提供一些网络服务来对文件进行管理和访问,samba是其中一种网络服务。In the prior art, the samba service is not integrated on the current android system, and the family cloud of the modular TV based on the android device itself has a storage function, and needs to provide some network services to manage and access files, samba is one of the web services.
在android的应用商店里面有在android系统上运行的samba服务的APP,但不公开源码,无法根据自己的需要做对源码进行修改,不方便开发新的功能。In the android application store, there are samba service APPs running on the android system, but the source code is not disclosed, and the source code cannot be modified according to one's own needs, which is inconvenient to develop new functions.
因此,现有技术还有待于改进和发展。Therefore, the prior art still needs to be improved and developed.
发明内容Contents of the invention
鉴于现有技术的不足,本发明目的在于提供一种基于安卓设备的samba服务实现方法及系统,旨在解决现有技术android系统上运行的samba服务的APP,但不公开源码,无法根据自己的需要做对源码进行修改,不方便开发新的功能的缺陷。In view of the deficiencies in the prior art, the purpose of the present invention is to provide a samba service implementation method and system based on an Android device, aiming at solving the problem of the samba service APP running on the android system in the prior art, but the source code is not disclosed, and it cannot be based on its own It is necessary to modify the source code, which is inconvenient to develop new functions.
本发明的技术方案如下:Technical scheme of the present invention is as follows:
提供一种基于安卓设备的samba服务实现方法,方法包括:A samba service implementation method based on an Android device is provided, and the method includes:
A、安卓设备继承Alfresco-jlan库中的CIFS协议类,定义一个指向待解析配置文件的解析类的对象;A. The Android device inherits the CIFS protocol class in the Alfresco-jlan library, and defines an object pointing to the parsing class of the configuration file to be parsed;
B、安卓设备采用ContentProvider接口对配置文件进行操作 ,实现samba服务。B. The Android device uses the ContentProvider interface to operate the configuration file and realize the samba service.
在一实施例中,所述步骤A具体包括:In one embodiment, the step A specifically includes:
A1、安卓设备加载待解析配置文件,根据待解析配置文件的定义创建CIFS对象;A1, the Android device loads the configuration file to be parsed, and creates a CIFS object according to the definition of the configuration file to be parsed;
A2、在待解析配置文件中添加需要监控的CIFS服务并启动,接收并处理CIFS客户端请求;A2. Add and start the CIFS service that needs to be monitored in the configuration file to be parsed, receive and process the CIFS client request;
A3、当检测到待解析配置文件修改时,停止CIFS服务,重新加载配置文件。A3. When it is detected that the configuration file to be parsed is modified, stop the CIFS service and reload the configuration file.
在一实施例中,所述步骤B中对配置文件进行操作具体包括:In one embodiment, operating the configuration file in step B specifically includes:
B1、通过对待解析配置文件进行配置后, windows自带的samba客户端与应用APP进行数据共享;B1. After configuring the configuration file to be parsed, the samba client that comes with windows shares data with the application APP;
B2、将针对samba服务的配置信息永久保存,当设备断电重启时,恢复到断电前的配置;B2. Permanently save the configuration information for the samba service, and restore to the configuration before the power failure when the device is powered off and restarted;
B3、当检测到待解析配置文件修改时通知samba服务启用修改后的配置。B3. When it is detected that the configuration file to be parsed is modified, the samba service is notified to enable the modified configuration.
在一实施例中,所述步骤B1中通过对待解析配置文件进行配置具体包括:通过安卓设备中的ContentProvider接口的查询、修改、删除对待解析配置文件进行配置。In an embodiment, configuring the configuration file to be parsed in step B1 specifically includes: configuring the configuration file to be parsed by querying, modifying, and deleting the configuration file to be parsed through the ContentProvider interface in the Android device.
在一实施例中,所述步骤B3具体包括:In one embodiment, the step B3 specifically includes:
B31、在封装的Samba服务的类中定义一个static bool变量以及实现一个static方法;B31, define a static bool variable and realize a static method in the class of the Samba service of encapsulation;
B32、当待解析配置文件发生变化时,就调用static方法修改static变量的值,通知samba服务启用修改后的配置。B32. When the configuration file to be parsed changes, the static method is called to modify the value of the static variable, and the samba service is notified to enable the modified configuration.
本发明还提供一种基于安卓设备的samba服务实现系统,所述系统包括:The present invention also provides a samba service realization system based on an android device, and the system includes:
协议类继承模块,用于安卓设备继承Alfresco-jlan库中的CIFS协议类,定义一个指向待解析配置文件的解析类的对象;The protocol class inheritance module is used for Android devices to inherit the CIFS protocol class in the Alfresco-jlan library, and defines an object pointing to the parsing class of the configuration file to be parsed;
配置文件管理模块,用于安卓设备采用ContentProvider接口对配置文件进行操作 ,实现samba服务。The configuration file management module is used for Android devices to use the ContentProvider interface to operate configuration files and implement samba services.
在一实施例中,所述协议类继承模块具体包括:In one embodiment, the protocol class inheritance module specifically includes:
加载与创建单元,用于安卓设备加载待解析配置文件,根据待解析配置文件的定义创建CIFS对象;The loading and creating unit is used for the Android device to load the configuration file to be parsed, and create a CIFS object according to the definition of the configuration file to be parsed;
添加与处理单元,用于在待解析配置文件中添加需要监控的CIFS服务并启动,接收并处理CIFS客户端请求;The addition and processing unit is used to add and start the CIFS service that needs to be monitored in the configuration file to be parsed, receive and process the CIFS client request;
检测与重新加载单元,用于当检测到待解析配置文件修改时,停止CIFS服务,重新加载配置文件。The detection and reloading unit is used to stop the CIFS service and reload the configuration file when it detects that the configuration file to be parsed is modified.
在一实施例中,所述对配置文件进行管理具体还包括:In an embodiment, the managing the configuration file specifically further includes:
配置单元,用于通过对待解析配置文件进行配置后, windows自带的samba客户端与应用APP进行数据共享;The configuration unit is used to share data between the samba client of windows and the application APP after configuring the configuration file to be parsed;
断电恢复单元,用于将针对samba服务的配置信息永久保存,当设备断电重启时,恢复到断电前的配置;The power failure recovery unit is used to permanently save the configuration information for the samba service, and restore the configuration before the power failure when the device is powered off and restarted;
通知单元,用于当检测到配置文件修改时通知samba服务启用修改后的配置。The notification unit is used for notifying the samba service to enable the modified configuration when the modification of the configuration file is detected.
在一实施例中,所述通过对待解析配置文件进行配置具体包括:通过安卓设备中的ContentProvider接口的查询、修改、删除对待解析配置文件进行配置。In an embodiment, configuring the configuration file to be parsed specifically includes: configuring the configuration file to be parsed through querying, modifying, and deleting the ContentProvider interface in the Android device.
在一实施例中,所述通知单元具体包括:In one embodiment, the notification unit specifically includes:
变量定义单元,用于在封装的Samba服务的类中定义一个static bool变量以及实现一个static方法;The variable definition unit is used to define a static bool variable and implement a static method in the encapsulated Samba service class;
调用与通知单元,用于当解析类的对象发生变化时,就调用static方法修改static变量的值,通知samba服务启用修改后的配置。The call and notification unit is used to call the static method to modify the value of the static variable when the object of the parsing class changes, and notify the samba service to enable the modified configuration.
本发明提供了一种基于安卓设备的samba服务实现方法及系统,本发明通过在安卓设备上实现samba服务后,可采用windows自带的samba客户端,能够正常的访问android设备上的文件。The invention provides a samba service realization method and system based on an android device. After the samba service is realized on the android device, the samba client provided by windows can be used to normally access files on the android device.
附图说明Description of drawings
图1为本发明的一种基于安卓设备的samba服务实现方法的较佳实施例的流程图。Fig. 1 is a flow chart of a preferred embodiment of a samba service implementation method based on an Android device of the present invention.
图2是本发明的一种基于安卓设备的samba服务实现方法的具体应用实施例中实现自己的子类的方法的流程图。Fig. 2 is a flow chart of the method for implementing one's own subclass in a specific application embodiment of the Android-based samba service implementation method of the present invention.
图3是本发明的一种基于安卓设备的samba服务实现方法的具体应用实施例中的查询接口的管理方法的流程图。Fig. 3 is a flow chart of the management method of the query interface in a specific application embodiment of the Android device-based samba service implementation method of the present invention.
图4是本发明的一种基于安卓设备的samba服务实现方法的具体应用实施例中的修改接口的管理方法的流程图。FIG. 4 is a flow chart of a management method for modifying an interface in a specific application embodiment of a samba service implementation method based on an Android device of the present invention.
图5是本发明的一种基于安卓设备的samba服务实现方法的具体应用实施例中实现开机启动的配置方法的流程图。FIG. 5 is a flow chart of a configuration method for realizing booting in a specific application embodiment of a method for implementing a samba service based on an Android device of the present invention.
图6为本发明的一种基于安卓设备的samba服务实现系统的较佳实施例的功能原理框图。FIG. 6 is a functional functional block diagram of a preferred embodiment of a samba service implementation system based on an Android device according to the present invention.
具体实施方式Detailed ways
为使本发明的目的、技术方案及效果更加清楚、明确,以下对本发明进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。In order to make the object, technical solution and effect of the present invention more clear and definite, the present invention will be further described in detail below. It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention.
本发明提供了一种基于安卓设备的samba服务实现方法的较佳实施例的流程图,如图1所示,所述方法包括:The present invention provides a flow chart of a preferred embodiment of a samba service implementation method based on Android devices, as shown in Figure 1, the method includes:
步骤S100、安卓设备继承Alfresco-jlan库中的CIFS协议类,定义一个指向待解析配置文件的解析类的对象。Step S100, the Android device inherits the CIFS protocol class in the Alfresco-jlan library, and defines an object pointing to the parsing class of the configuration file to be parsed.
具体实施时,Alfresco是一个免费的/自由企业包含内容存储库、一个开箱即用的web门户框架来内容管理和使用标准门户内容的系统。它提供了在Microsoft Windows和类unix操作系统的文件的兼容性,该程序由Java技术开发。其中Alfresco-jlan代表用java语言开发的开源企业内容管理系统。CIFS是 Common Internet File System的缩写,中文释义为用户网络设备间文件共享,其中待解析配置文件为XML文件,解析类的对象为XML文件解析类的对象,XML是Extensible Markup Language缩写,中文释义为可扩展标记语言。When implemented, Alfresco is a free/liberal enterprise containing content repository, an out-of-the-box web portal framework for content management and a system for using standard portal content. It provides file compatibility on Microsoft Windows and Unix-like operating systems, and the program is developed by Java technology. Among them, Alfresco-jlan represents an open source enterprise content management system developed in java language. CIFS is the abbreviation of Common Internet File System. The Chinese definition is file sharing between user network devices. The configuration file to be parsed is an XML file, and the object of the parsing class is the object of the XML file parsing class. XML is the abbreviation of Extensible Markup Language, and the Chinese definition is Extensible Markup Language.
在步骤S100后还包括如下步骤:安卓设备对Alfresco-jlan库中的用于调试的日志接口DebugInterface的所有接口进行定义。After step S100, the following steps are further included: the Android device defines all interfaces of the debug interface DebugInterface in the Alfresco-jlan library.
具体实施时, Alfresco-jlan有提供日志接口DebugInterface,做为调试的主要手段,需要实现其定义的所有接口,也可以是空函数。In the specific implementation, Alfresco-jlan provides the log interface DebugInterface, as the main means of debugging, it needs to implement all the interfaces defined by it, and it can also be an empty function.
步骤S200、安卓设备采用ContentProvider接口对待解析配置文件进行操作 ,实现samba服务。Step S200, the Android device uses the ContentProvider interface to operate on the configuration file to be parsed to implement the samba service.
具体实施时,针对待解析配置文件的管理有三方面的内容:(1) 实现与应用APP进行数据共享;(2) 需要将针对客户端的配置信息永久保存,当设备断电重启时,能够恢复到断电前的配置;(3) 待解析配置文件修改需要通知samba的服务启用新的配置。During specific implementation, there are three aspects to the management of configuration files to be parsed: (1) Realize data sharing with the application APP; (2) Need to permanently save the configuration information for the client, and when the device is powered off and restarted, it can be restored to Configuration before power failure; (3) The modification of the configuration file to be parsed needs to notify the service of samba to enable the new configuration.
进一步的实施例中,所述步骤S100具体包括:In a further embodiment, the step S100 specifically includes:
步骤S101、安卓设备加载待解析配置文件,根据待解析配置文件的定义创建CIFS对象;Step S101, the Android device loads the configuration file to be parsed, and creates a CIFS object according to the definition of the configuration file to be parsed;
步骤S102、在待解析配置文件中添加需要监控的CIFS服务并启动,接收并处理CIFS客户端请求;Step S102, adding and starting the CIFS service to be monitored in the configuration file to be parsed, receiving and processing the CIFS client request;
步骤S103、当检测到待解析配置文件修改时,停止CIFS服务,重新加载待解析配置文件。Step S103, when it is detected that the configuration file to be parsed is modified, stop the CIFS service, and reload the configuration file to be parsed.
具体实施时,安卓设备Alfresco-jlan库是采用java实现的samba服务,其已经完整的实现了samba协议,故目前只需要继承其基础类,并在其基础类上进行二次开发就可以实现samba服务。In the specific implementation, the Android device Alfresco-jlan library is a samba service implemented in java, which has completely implemented the samba protocol, so at present, only need to inherit its basic class, and carry out secondary development on the basic class to realize samba Serve.
安卓设备首先实现自己的子类,继承库已经实现了CIFS协议的类(JLANCifsServer),并且定义一个XML文件解析类(XMLServerConfiguration)的对象,该对象指向待解析配置文件。The Android device first implements its own subclass, the inheritance library has implemented the CIFS protocol class (JLANCifsServer), and defines an object of the XML file parsing class (XMLServerConfiguration), which points to the configuration file to be parsed.
具体如图2所示,图2为本发明的基于安卓设备的samba服务实现方法的具体应用实施例中实现自己的子类的方法的流程图, 其中,XMLServerConfiguration类: 此类实现了解析XML格式的解析,并采用了观察者的设计模式,将需要管理的服务添加到其观察列表中; JLANCifsServer类: 实现了CIFS协议。方法具体包括:Specifically as shown in Figure 2, Figure 2 is a flow chart of the method for realizing one's own subclass in the specific application embodiment of the samba service implementation method based on the Android device of the present invention, wherein, the XMLServerConfiguration class: This class implements the parsing XML format The analysis, and adopts the design pattern of the observer, and adds the service that needs to be managed to its observation list; JLANCifsServer class: implements the CIFS protocol. The methods specifically include:
步骤S10、开始;Step S10, start;
步骤S20、加载待解析配置文件;Step S20, loading the configuration file to be parsed;
步骤S30、根据待解析配置文件的定义创建CIFS对象;Step S30, creating a CIFS object according to the definition of the configuration file to be parsed;
步骤S40、在待解析配置文件中添加需要监控的CIFS服务;Step S40, adding the CIFS service to be monitored in the configuration file to be parsed;
步骤S50、启动CIFS服务;Step S50, starting the CIFS service;
步骤S60、接收并处理CIFS客户端请求;Step S60, receiving and processing the CIFS client request;
步骤S70、判断CIFS服务是否运行出错,如果是,则执行步骤S93,如果否,则执行步骤S80;Step S70, judging whether the CIFS service runs incorrectly, if yes, then execute step S93, if no, then execute step S80;
步骤S80、判断待解析配置文件是否被修改,如果是,则执行步骤S90,如果否,则执行步骤S60;Step S80, judging whether the configuration file to be analyzed has been modified, if yes, execute step S90, if not, execute step S60;
步骤S90、停止CIFS服务;Step S90, stop the CIFS service;
步骤S91、重新加载待解析配置文件;Step S91, reloading the configuration file to be parsed;
步骤S92、启动CIFS服务;Step S92, starting the CIFS service;
步骤S93、结束。Step S93, end.
进一步的,所述步骤S200对待解析配置文件进行管理具体包括:Further, the step S200 of managing the configuration file to be parsed specifically includes:
步骤S201、通过对待解析配置文件进行配置后, windows自带的samba客户端与应用APP进行数据共享;Step S201, after configuring the configuration file to be parsed, the samba client that comes with windows performs data sharing with the application APP;
步骤S202、将针对samba服务的配置信息永久保存,当设备断电重启时,恢复到断电前的配置;Step S202, permanently save the configuration information for the samba service, and restore to the configuration before the power failure when the device is powered off and restarted;
步骤S203、当检测到待解析配置文件修改时通知samba服务启用修改后的配置。Step S203, when it is detected that the configuration file to be parsed is modified, the samba service is notified to enable the modified configuration.
具体实施时,其中步骤S201中通过对待解析配置文件进行配置具体包括:通过安卓设备中的ContentProvider接口的查询、修改、删除对待解析配置文件进行配置。During specific implementation, configuring the configuration file to be parsed in step S201 specifically includes: configuring the configuration file to be parsed by querying, modifying, and deleting the configuration file to be parsed through the ContentProvider interface in the Android device.
具体地,如图3所示,图3为本发明基于安卓设备的samba服务实现方法的具体应用实施例中的查询接口的管理方法,具体流程:Specifically, as shown in Figure 3, Figure 3 is the management method of the query interface in the specific application embodiment of the samba service implementation method based on the Android device of the present invention, the specific process:
步骤S1、开始;Step S1, start;
步骤S2、判断是否初始化缓存,如果是,则执行步骤S4,如果否,则执行步骤S3;Step S2, judging whether to initialize the cache, if yes, execute step S4, if not, execute step S3;
步骤S3、从数据库读取用户信息初始化缓存;Step S3, read user information from the database to initialize the cache;
步骤S4、根据设计的表格结构构造数组并将数据返回给请求者;Step S4, constructing an array according to the designed table structure and returning the data to the requester;
步骤S5、结束。Step S5, end.
其中,查询接口做了特殊设计,没有采用sqlite数据库的原有查询接口,而是采用了MatrixCursor自行定制一个Cursor(光标),因为有些用户数据不需要显示在app上,还有就是当用户首次访问时并不需要将用户信息保存到数据库中,而是保存在一个缓存中,但这部分数据仍然要显示到app上,只有当用户的权限被修改时才会写入到数据库。此接口就是从缓存中读取数据并按照自行设计的表的格式将数据封装返回给应用APP。Among them, the query interface has been specially designed. Instead of using the original query interface of the sqlite database, MatrixCursor is used to customize a Cursor (cursor), because some user data does not need to be displayed on the app, and when the user visits for the first time It is not necessary to save user information in the database, but in a cache, but this part of the data still needs to be displayed on the app, and will only be written to the database when the user's permissions are modified. This interface is to read data from the cache and return the data package to the application APP in the format of a self-designed table.
具体地,如图4所示,图4为本发明基于安卓设备的samba服务实现方法的具体应用实施例中的修改接口的管理方法。具体流程为:Specifically, as shown in FIG. 4 , FIG. 4 is a management method for modifying an interface in a specific application embodiment of the Android device-based samba service implementation method of the present invention. The specific process is:
步骤S11、开始;Step S11, start;
步骤S12、判断用户是否已经在数据中建档,如果是,则执行步骤S14,如果否,则执行步骤S13;Step S12, judging whether the user has created a file in the data, if yes, then execute step S14, if not, then execute step S13;
步骤S13、更新缓存,同时更新用户在数据库中的记录;Step S13, updating the cache and updating the user's record in the database;
步骤S14、更新缓存,在数据中新建一条用户记录;Step S14, update the cache, and create a new user record in the data;
步骤S15、更新待解析配置文件 ,并且通过samba服务,并返回结果;Step S15, update the configuration file to be parsed, and pass the samba service, and return the result;
步骤S16、结束。Step S16, end.
其中,修改主要是针对用户的访问权限(全盘访问/只能访问公有盘),要考虑的点是当用户修改权限时,是否已经在数据中存储记录,如果存在,则更新即可,如果不存在,则需要在数据库中插入一条新的记录,并修改待解析配置文件,通知samba服务启用新的配置。Among them, the modification is mainly for the user's access rights (full disk access/only public disk access). The point to consider is whether the user has already stored the record in the data when modifying the permission. If it exists, it can be updated. If not If it exists, you need to insert a new record in the database, modify the configuration file to be parsed, and notify the samba service to enable the new configuration.
如果是删除接口,先从待解析配置文件中删除相关的配置,再从数据库中删除用户所在的记录,最后通知samba服务启用新配置,返回结果给调用者。If it is to delete the interface, first delete the relevant configuration from the configuration file to be parsed, then delete the record of the user from the database, and finally notify the samba service to enable the new configuration, and return the result to the caller.
其中步骤S203具体包括:Wherein step S203 specifically includes:
步骤S231、在封装的Samba服务的类中定义一个static bool变量以及实现一个static方法;Step S231, define a static bool variable and implement a static method in the class of the Samba service of encapsulation;
步骤S232、当待解析配置文件发生变化时,就调用static方法修改static变量的值,通知samba服务启用修改后的配置。Step S232, when the configuration file to be parsed changes, the static method is called to modify the value of the static variable, and the samba service is notified to enable the modified configuration.
具体实施时,待解析配置文件修改通知samba服务进行配置更新,在封装的Samba服务的类(步骤A中定义的子类)中定义一个static bool变量以及实现一个static方法,当待解析配置文件发生变化时,就调用static方法修改static变量的值。During specific implementation, the modification of the configuration file to be parsed notifies the samba service to update the configuration, defines a static bool variable and implements a static method in the packaged Samba service class (subclass defined in step A), and when the configuration file to be parsed occurs When changing, call the static method to modify the value of the static variable.
进一步的实施例中,步骤S200之后还包括:In a further embodiment, after step S200, it also includes:
步骤S300、将待解析配置文件放在assets目录下,打包android程序时一起打包。Step S300, put the configuration file to be parsed in the assets directory, and pack the android program together.
具体实施时,将待解析配置文件放在assets目录下,打包android程序时会一起打包进去,另外此文件在服务启动后,可以进入后台查看配置文件的内容,也方便调试,还有一点就是对文件大小没有限制。In the specific implementation, the configuration file to be parsed is placed in the assets directory, and it will be packaged together when the android program is packaged. In addition, after the service is started, this file can enter the background to view the content of the configuration file, which is also convenient for debugging. Another point is to There is no limit to the file size.
本发明还提供了一种基于安卓设备的samba服务实现方法的具体实施例,其中待解析配置文件操作的一种实现方式:待解析配置文件是XML格式的文件,可以自己根据xml结构去实现对其的解析,也可以采用已经存在的类,org.w3c.dom以及javax.xml.transform(将在内存中的xml数据存储到文件)。其中org.w3c.dom为文档对象模型(DOM)提供接口,该模型是JAVA API FOR XML Processing的组件API,javax.xml.transform中java包定义了从源到结果进行转换的指定接口。ContentProvider为存储和获取数据提供统一的接口;可以在不同的应用程序之间共享数据; Cursor为提供任意访问读写从数据库返回的结果接口; MatrixCursor为可变的Cursor, 当结果无法通过查询数据库直接返回时,此时需要实现一个类似数据返回结果。The present invention also provides a specific embodiment of a samba service implementation method based on an Android device, wherein an implementation of the operation of the configuration file to be parsed: the configuration file to be parsed is a file in XML format, and can be implemented according to the xml structure. Its analysis can also use the existing classes, org.w3c.dom and javax.xml.transform (store the xml data in memory to a file). Among them, org.w3c.dom provides an interface for the Document Object Model (DOM), which is a component API of the JAVA API FOR XML Processing, and the java package in javax.xml.transform defines a specified interface for transforming from source to result. ContentProvider provides a unified interface for storing and obtaining data; data can be shared between different applications; Cursor provides arbitrary access to read and write the result interface returned from the database; MatrixCursor is a variable Cursor, when the result cannot be directly queried by the database When returning, it is necessary to implement a similar data return result at this time.
其中待解析配置文件配置方法具体包括:The configuration method of the configuration file to be parsed specifically includes:
步骤S1001、开始;Step S1001, start;
步骤S1002、将待解析配置文件以XML的格式加载到内存中,并构建索引树;Step S1002, loading the configuration file to be parsed into memory in XML format, and building an index tree;
步骤S1003、判断是否对节点进行删除/修改,如果是,则执行步骤S1004,如果否,则执行步骤S1031;Step S1003, judging whether to delete/modify the node, if yes, execute step S1004, if not, execute step S1031;
步骤S1004、判断对应的节点是否在配置树中,如果是,则执行步骤S1005,如果否,则执行步骤S1007;Step S1004, judging whether the corresponding node is in the configuration tree, if yes, execute step S1005, if not, execute step S1007;
步骤S1005、执行删除/修改操作;Step S1005, performing a delete/modify operation;
步骤S1006、将更新的内容保存到待解析配置文件中;Step S1006, saving the updated content in the configuration file to be parsed;
步骤S1007、返回错误;Step S1007, return an error;
步骤S1031、判断是否对增加,如果是,则执行步骤S1032,如果否,则执行步骤S1033;Step S1031, judging whether to increase, if yes, then execute step S1032, if not, then execute step S1033;
步骤S1032、查找其父节点;Step S1032, finding its parent node;
步骤S1033、判断是否查找,如果是,则执行步骤S1035,如果否,则执行步骤S1034;Step S1033, judging whether to search, if yes, execute step S1035, if not, execute step S1034;
步骤S1034、返回错误;Step S1034, returning an error;
步骤S1035、对应的节点在配置树中;Step S1035, the corresponding node is in the configuration tree;
步骤S1036、返回对应的值;Step S1036, return the corresponding value;
步骤S1008、结束。Step S1008, end.
其中查出对应的节点是否在配置树中,采用递归的方式查找。实现开机启动,这个可以捕获系统启动完毕或者系统网络已经建立成功所发送的消息来进行。Among them, whether the corresponding node is found in the configuration tree is searched in a recursive manner. To achieve booting, this can be done by capturing the message sent after the system has been started or the system network has been successfully established.
在配置时实现开机启动,这个可以捕获系统启动完毕或者系统网络已经建立成功所发送的消息来进行。实现开机启动的配置流程具体如图5所示,具体包括:To achieve booting during configuration, this can be done by capturing the message sent after the system has been started or the system network has been successfully established. Figure 5 shows the configuration process for booting, including:
步骤S111、开始;Step S111, start;
步骤S112、判断是否接收到BOOT_COMPLETED信号,如果是,则执行步骤S113,如果否,则执行步骤S112;Step S112, judging whether the BOOT_COMPLETED signal is received, if yes, then execute step S113, if no, then execute step S112;
步骤S113、通过Intent启动服务;Step S113, start the service through Intent;
步骤S114、结束。Step S114, end.
具体地, BOOT_COMPLETED是广播消息, 当android系统启动完毕之后,会广播此消息,但只广播一次。 Intent是动作描述,负责对应用中一次操作的动作、动作涉及数据、附加数据进行描述,Android则根据此Intent的描述,负责找到对应的组件,将 Intent传递给调用的组件,并完成组件的调用。Specifically, BOOT_COMPLETED is a broadcast message. After the android system is started, the message will be broadcast, but only once. Intent is an action description, which is responsible for describing the action of an operation in the application, the data involved in the action, and the additional data. Android is responsible for finding the corresponding component according to the description of the Intent, passing the Intent to the called component, and completing the call of the component .
在上述方法实施例的基础上,本发明还提供了一种基于安卓设备的samba服务实现系统的较佳实施例的功能原理框图,如图6所示,所述系统包括:On the basis of the foregoing method embodiments, the present invention also provides a functional principle block diagram of a preferred embodiment of a samba service implementation system based on Android devices, as shown in Figure 6, the system includes:
协议类继承模块100,用于安卓设备继承Alfresco-jlan库中的CIFS协议类,定义一个指向待解析配置文件的解析类的对象;具体如上所述。The protocol class inheritance module 100 is used for the Android device to inherit the CIFS protocol class in the Alfresco-jlan library, and defines an object pointing to the parsing class of the configuration file to be parsed; specifically as described above.
配置文件管理模块200,用于安卓设备采用ContentProvider接口对待解析配置文件进行操作 ,实现samba服务;具体如上所述。The configuration file management module 200 is used for the Android device to use the ContentProvider interface to operate the configuration file to be parsed to realize the samba service; specifically as described above.
所述的基于安卓设备的samba服务实现系统,其中,所述协议类继承模块具体包括:The described samba service implementation system based on the Android device, wherein the protocol class inheritance module specifically includes:
加载与创建单元,用于安卓设备加载待解析配置文件,根据待解析配置文件的定义创建CIFS对象;具体如上所述。The loading and creating unit is used for the Android device to load the configuration file to be parsed, and create a CIFS object according to the definition of the configuration file to be parsed; the details are as described above.
添加与处理单元,用于在待解析配置文件中添加需要监控的CIFS服务并启动,接收并处理CIFS客户端请求;具体如上所述。The adding and processing unit is used for adding and starting the CIFS service to be monitored in the configuration file to be parsed, receiving and processing the CIFS client request; the details are as described above.
检测与重新加载单元,用于当检测到待解析配置文件修改时,停止CIFS服务,重新加载待解析配置文件;具体如上所述。The detection and reloading unit is used to stop the CIFS service and reload the configuration file to be parsed when it detects that the configuration file to be parsed is modified; the details are as described above.
所述的基于安卓设备的samba服务实现系统,其中,所述对待解析配置文件进行管理具体还包括:The described samba service implementation system based on the Android device, wherein the management of the configuration file to be parsed specifically also includes:
配置单元,用于通过对待解析配置文件进行配置后, windows自带的samba客户端与应用APP进行数据共享;具体如上所述。The configuration unit is used to share data between the samba client provided by windows and the application APP after configuring the configuration file to be parsed; the details are as described above.
断电恢复单元,用于将针对samba服务的配置信息永久保存,当设备断电重启时,恢复到断电前的配置;具体如上所述。The power-off recovery unit is used to permanently save the configuration information for the samba service, and restore to the configuration before the power-off when the device is powered off and restarted; the details are as described above.
通知单元,用于当检测到待解析配置文件修改时通知samba服务启用修改后的配置;具体如上所述。The notification unit is used to notify the samba service to enable the modified configuration when it detects that the configuration file to be parsed is modified; the details are as described above.
所述的基于安卓设备的samba服务实现系统,其中,所述通过对待解析配置文件进行配置具体包括:通过安卓设备中的ContentProvider接口的查询、修改、删除对待解析配置文件进行配置;具体如上所述。The described samba service implementation system based on the Android device, wherein, said configuring the configuration file to be parsed specifically includes: configuring the configuration file to be parsed by querying, modifying, and deleting the ContentProvider interface in the Android device; specifically as described above .
所述的基于安卓设备的samba服务实现系统,其中,所述通知单元具体包括:The described samba service implementation system based on the Android device, wherein the notification unit specifically includes:
变量定义单元,用于在封装的Samba服务的类中定义一个static bool变量以及实现一个static方法;具体如上所述。The variable definition unit is used to define a static bool variable and implement a static method in the encapsulated Samba service class; the details are as described above.
调用与通知单元,用于当待解析配置文件发生变化时,就调用static方法修改static变量的值,通知samba服务启用修改后的配置;具体如上所述。The call and notification unit is used to call the static method to modify the value of the static variable when the configuration file to be parsed changes, and notify the samba service to enable the modified configuration; the details are as described above.
综上所述,本发明提供了一种基于安卓设备的samba服务实现方法及系统,所述方法包括:安卓设备继承Alfresco-jlan库中的CIFS协议类,定义一个指向待解析配置文件的解析类的对象;安卓设备采用ContentProvider接口对配置文件进行操作 ,实现samba服务。本发明通过在安卓设备上实现samba服务后,可采用windows自带的samba客户端,能够正常的访问android设备上的文件。In summary, the present invention provides a samba service implementation method and system based on an Android device, the method comprising: the Android device inherits the CIFS protocol class in the Alfresco-jlan library, and defines a resolution class pointing to a configuration file to be parsed object; the Android device uses the ContentProvider interface to operate the configuration file to implement the samba service. After realizing the samba service on the android device, the present invention can adopt the samba client provided by windows to normally access files on the android device.
应当理解的是,本发明的应用不限于上述的举例,对本领域普通技术人员来说,可以根据上述说明加以改进或变换,所有这些改进和变换都应属于本发明所附权利要求的保护范围。It should be understood that the application of the present invention is not limited to the above examples, and those skilled in the art can make improvements or transformations according to the above descriptions, and all these improvements and transformations should belong to the protection scope of the appended claims of the present invention.
Claims (6)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201510962431.0A CN105610908B (en) | 2015-12-21 | 2015-12-21 | A kind of samba service implementing method and system based on Android device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201510962431.0A CN105610908B (en) | 2015-12-21 | 2015-12-21 | A kind of samba service implementing method and system based on Android device |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN105610908A CN105610908A (en) | 2016-05-25 |
| CN105610908B true CN105610908B (en) | 2019-09-10 |
Family
ID=55990442
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201510962431.0A Expired - Fee Related CN105610908B (en) | 2015-12-21 | 2015-12-21 | A kind of samba service implementing method and system based on Android device |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN105610908B (en) |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106484553B (en) * | 2016-09-13 | 2019-06-28 | 天脉聚源(北京)传媒科技有限公司 | A kind of method and device solving samba failure |
| CN116233301B (en) * | 2023-02-20 | 2025-03-25 | 深圳感臻智能股份有限公司 | Method, system and device for configuring WiFi perception using Android system |
Citations (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103324537A (en) * | 2013-05-17 | 2013-09-25 | Tcl集团股份有限公司 | Resource sharing method and device |
-
2015
- 2015-12-21 CN CN201510962431.0A patent/CN105610908B/en not_active Expired - Fee Related
Patent Citations (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103324537A (en) * | 2013-05-17 | 2013-09-25 | Tcl集团股份有限公司 | Resource sharing method and device |
Non-Patent Citations (3)
| Title |
|---|
| 使用Samba实现Windows和Unix/Linux不同平台间的资源共享;刘海宁;《首都医科大学学报(社会科学版)》;20061230;第122-124页 |
| 基于Samba服务器的手机文件共享系统;靳娜;《中国优秀硕士学位论文全文数据库信息科技辑》;20150331;第1-43页 |
| 基于Samba的Windows与Linux(UNIX)互连技术;何青;张晓春;《培训与研究(湖北教育学院学报)》;20021031;第19卷(第5期);第31-34页 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN105610908A (en) | 2016-05-25 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN102754073B (en) | For the method and system that virtualized extension point is declaratively registered | |
| US20150067167A1 (en) | Hot pluggable extensions for access management system | |
| CN105094922A (en) | Application installation-free operation control method and device | |
| CN108491216A (en) | A kind of method of android system unaware application installation upgrading | |
| US11477179B2 (en) | Searching content associated with multiple applications | |
| CN112698921A (en) | Logic code operation method and device, computer equipment and storage medium | |
| CN115136133A (en) | Single use execution environment for on-demand code execution | |
| CN112579307A (en) | Physical lock resource allocation detection method and device and electronic equipment | |
| US20080040656A1 (en) | Instance annotation in object-oriented programming | |
| US12061901B2 (en) | Documentation enforcement during compilation | |
| CN117827365A (en) | Port allocation method, device, equipment, medium and product for application container | |
| WO2025194648A1 (en) | Container management method and apparatus, device, and medium | |
| US20240103818A1 (en) | Annotation driven just in time and state-based rbac policy control | |
| JP2025525551A (en) | Method, system, electronic device and computer-readable storage medium for handling data collisions | |
| CN105610908B (en) | A kind of samba service implementing method and system based on Android device | |
| CN110377328A (en) | A kind of data capture method, device, equipment and storage medium | |
| CN102216901B (en) | Component extension method and device | |
| US20080127301A1 (en) | Delivering Callbacks Into Secure Application Areas | |
| CN118192965A (en) | Page component processing method, device, computer equipment, storage medium and product | |
| US10140155B2 (en) | Dynamically provisioning, managing, and executing tasks | |
| Ito et al. | Application Push & Play–Proposal on Dynamic Execution Environment Combined with Personal Devices and Cloud Computing.- | |
| WO2012089893A1 (en) | Method, apparatus, system and computer program product for managing data in database | |
| KR20110067787A (en) | Framework device based on domain object interface | |
| US20230385075A1 (en) | Networked Universal Code Package Provider | |
| HK40040790A (en) | Physical lock resource allocation detection method, device and electronic equipment |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant | ||
| CF01 | Termination of patent right due to non-payment of annual fee | ||
| CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20190910 |